How do you orchestrate complex workflows in your FastAPI backend without making a mess? 🧩 Keep your API endpoints clean by moving orchestration to a Service Layer. A good service function does 4 things: 1️⃣ Fetches objects from the repository 2️⃣ Validates the request 3️⃣ Calls the pure domain service 4️⃣ Saves the new state To safely manage those database transactions, wrap your calls in the Unit of Work (UoW) Pattern. Acting as a context manager, the UoW ensures your operations are atomic—either safely committing all changes at once or rolling them back if an error occurs. Safe by default! 🛡️ Dive into our latest article to see how UoW and Service Layers can transform your API architecture. 👇 https://lnkd.in/d9D2Ztrk #SoftwareArchitecture #FastAPI #Python #API #EngineeringBestPractices
Orchestrating FastAPI Workflows with Service Layers and UoW
More Relevant Posts
-
One pattern that changed how I build FastAPI backends: Stop returning raw database models from your endpoints. When your API response mirrors your ORM model 1:1, you're creating tight coupling between your database schema and your API contract. One schema change can break every client. The fix: dedicated Pydantic response models per endpoint. Here's what you get: 1. Auto-generated OpenAPI docs that actually match your responses 2. A clear data boundary - internal fields stay internal 3. Freedom to refactor your DB without touching your API contract Bonus: Pydantic's model_validator and computed fields let you shape responses exactly how your frontend needs them - no extra serialization logic scattered across your codebase. What patterns have saved you the most headaches in your backend work? #Python #FastAPI #WebDevelopment #SoftwareEngineering #FullStackDeveloper
To view or add a comment, sign in
-
Most operational software I encounter wasn't built to talk to anything else. With FastAPI, you can build a lightweight API layer on top of almost any system, whether it's a database, a legacy application, or a third-party platform. Once that layer is in place, other systems can pull data from it, push data to it, or trigger actions automatically. The result isn't just a technical improvement. It means processes that used to require manual exports, emails back and forth, or someone running a report every morning can simply run on their own. The only thing required is a small Python application. Deployed, maintained, and adapted when business requirements change. No large dev team needed. How many manual actions does your most painful data process require? Drop a number below! D-Data #Python #FastAPI #DataEngineering #SoftwareEngineering #BusinessAutomation #APIIntegration
To view or add a comment, sign in
-
Your server is growing 50MB every hour with no explanation. Day 10 of 30 -- Memory Management and Profiling Phase 2 -- Performance and Concurrency This happened to our team in production. FastAPI server. 200MB on startup. 2GB after 24 hours. OOM killed. Restarted. Repeated. The fix took 1 line of code. The investigation took 20 minutes with tracemalloc. Python manages memory with reference counting -- every object tracks how many names point to it. When that count hits zero, memory is freed immediately. But there are 3 ways this breaks in production: Circular references that refcount cannot free Global containers growing forever with no eviction Cached objects held by closures longer than intended Today's Topic covers: How reference counting works with a visual bar diagram Stack vs heap -- where Python names and objects actually live slots -- 232 bytes vs 56 bytes per instance, 2.32GB vs 560MB at 10 million objects 6 profiling tools -- tracemalloc, cProfile, timeit, line_profiler, objgraph, memory_profiler Fully annotated syntax -- tracemalloc, gc, slots, weakref, generator vs list comparison Real production leak hunt -- 847MB in a global dict, found and fixed with WeakValueDictionary in 1 line 5-step memory debugging workflow 5 mistakes including the module-level list that kills servers at 3 AM Key insight: Memory leaks are not bugs that appear suddenly. They are architectural mistakes that accumulate silently. #Python #MemoryManagement #Performance #BackendDevelopment #SoftwareEngineering #100DaysOfCode #PythonDeveloper #TechContent #BuildInPublic #TechIndia #Profiling #SystemDesign #PythonTutorial #PythonProgramming #LinkedInCreator #LearnPython
To view or add a comment, sign in
-
Most backend projects stop at “it works.” I wanted to know — how well does it work under pressure? So I built a small performance lab comparing Flask vs FastAPI under real-world load. What I did: • Built identical REST APIs in both frameworks (same logic, same endpoints) • Simulated concurrent users using k6 • Tested both lightweight and CPU-heavy endpoints • Measured latency, throughput, and scalability behavior What I found: • Flask performance degrades sharply as concurrency increases • FastAPI handles concurrent requests more efficiently (~50% higher throughput at peak load) • Both frameworks struggle with CPU-bound workloads — async helps with concurrency, not heavy computation The most interesting part wasn’t which framework is “faster” — it was seeing where systems break and why. This project shifted my focus from just building APIs to understanding how backend systems behave under load ⚡ GitHub Repo: https://lnkd.in/gUhFmp4i #backend #fastapi #flask #python #systemdesign #performance #softwareengineering #webdevelopment
To view or add a comment, sign in
-
🎯 Precision Engineering: Beyond Basic Queries "A great API doesn't just give you data—it gives you the right data, or a clear reason why it can't. 🛡️ Today I expanded my TodoApp by implementing Path Parameters. Moving beyond fetching 'all' records, I’ve added logic to retrieve specific tasks by their ID. Key technical highlights from this update: ✅ Input Validation: Used FastAPI’s Path to ensure only valid IDs (greater than 0) are processed. ✅ Robust Error Handling: Integrated HTTPException to return a clean 404 Not Found status if a user requests an ID that doesn't exist. ✅ Clean Code: Refactored using Annotated dependencies to keep the route handlers lean and readable. Building a backend isn't just about the 'Happy Path'—it's about handling every edge case with precision. Next: Implementing POST requests to allow users to create their own tasks! 🚀" #FastAPI #Python #BackendDevelopment #WebAPI #CleanCode #SoftwareEngineering
To view or add a comment, sign in
-
-
Half my context window was gone before I typed a single prompt. Claude Code indexed my entire monorepo at session start — Python files, Airflow DAGs, three months of task logs. Then it generated a migration that referenced a table that doesn't exist. I spent weeks rebuilding my project setup from scratch. Token usage dropped over 60%. But the real win was rework time going down significantly. Here's what actually moved the needle: - permissions.deny in settings.json — the official way to block files Claude shouldn't read. Read(./.env), Read(./airflow/logs/), Read(./.venv/). The airflow/logs line alone cut 15%. - .claudeignore — an unofficial shortcut that works like .gitignore. Not in the docs yet, but a lot of people use it. Same result, cleaner syntax. - CLAUDE.md hierarchy — root file under 200 lines. Subdirectory files load only when needed. Past 200 lines, Claude starts treating your instructions as optional. - MCP servers (BigQuery + Airflow) — live database access without pre-loading schemas into context. Deferred by default, costs almost nothing until Claude actually queries one. - Skills & agents — on-demand workflows at ~100 tokens each instead of 3,000-5,000 tokens baked into CLAUDE.md every session. - /compact and /context — the two commands I run multiple times a day to manage what's eating my context window. 30 minutes of setup. Every session after that starts lean. Full walkthrough with real configs from a data pipeline project: https://lnkd.in/gaNuSUta -- What does your Claude Code project setup look like? Are you using permissions.deny or .claudeignore — or just letting it index everything? #AICoding #SoftwareEngineering #DataEngineering #ClaudeCode #DeveloperTools #AIEngineering #SystemDesign
To view or add a comment, sign in
-
I added more threads to fix my pipeline. Throughput dropped. That was the moment I realized I had been debugging the wrong thing for days. We were processing ~8 million events in a strict time window. The system was falling behind. My first instinct more threads, more parallelism. Classic move. But the system wasn't compute-bound. Every event was triggering datastore lookups, config reads, network calls. The threads weren't competing for CPU. They were all just waiting and I gave them more company. Python 3.13 introduced a free-threaded build where the GIL can be disabled. True parallel execution across cores. No more serialization. A lot of engineers read that and thought: "Finally, Python is fixed." It's not that simple. Your system's throughput is capped by three things and free-threading only addresses one: → I/O ceiling - how fast your external dependencies respond → Thread overhead ceiling - context switching cost beyond the optimal thread count → Execution ceiling - where the GIL used to apply Removing the GIL lifts the execution ceiling. If your system is sitting behind the I/O ceiling, nothing moves. What actually fixed my pipeline wasn't threads or Python versions. It was pulling config data out of the critical path and caching state locally. One design decision. More impact than any concurrency change. Removing the GIL doesn't remove bad architecture. Full breakdown with the three-ceiling model and where free-threading genuinely helps link in comments. #Python #SystemDesign #BackendEngineering #SoftwareEngineering #DistributedSystems #Concurrency
To view or add a comment, sign in
-
-
𝗙𝗮𝘀𝘁𝗔𝗣𝗜 𝗶𝘀𝗻'𝘁 𝗳𝗮𝘀𝘁 𝗯𝗲𝗰𝗮𝘂𝘀𝗲 𝗼𝗳 𝗙𝗮𝘀𝘁𝗔𝗣𝗜. 𝗜𝘁'𝘀 𝗳𝗮𝘀𝘁 𝗯𝗲𝗰𝗮𝘂𝘀𝗲 𝗼𝗳 𝘄𝗵𝗮𝘁'𝘀 𝘂𝗻𝗱𝗲𝗿𝗻𝗲𝗮𝘁𝗵. Most people stop at "FastAPI is faster than Flask." Few ask 𝘸𝘩𝘺. Here's what's actually happening: 𝗙𝗹𝗮𝘀𝗸 runs on 𝗪𝗦𝗚𝗜. One request = one thread = blocked until done. Your thread waits while the DB responds. It does nothing. Just sits there. 𝗙𝗮𝘀𝘁𝗔𝗣𝗜 runs on 𝗔𝗦𝗚𝗜. One thread handles 𝘵𝘩𝘰𝘶𝘴𝘢𝘯𝘥𝘴 of connections. While one request waits for DB, the thread picks up another. No idle time. But FastAPI doesn't do this alone. The real stack: • 𝗨𝘃𝗶𝗰𝗼𝗿𝗻 — the ASGI server (built on uvloop) • 𝗦𝘁𝗮𝗿𝗹𝗲𝘁𝘁𝗲 — the async engine (handles requests, WebSockets, middleware) • 𝗙𝗮𝘀𝘁𝗔𝗣𝗜 — the developer layer (validation, docs, type hints) Think of it this way: Starlette = 𝘵𝘩𝘦 𝘦𝘯𝘨𝘪𝘯𝘦. FastAPI = 𝘵𝘩𝘦 𝘥𝘢𝘴𝘩𝘣𝘰𝘢𝘳𝘥. Uvicorn = 𝘵𝘩𝘦 𝘧𝘶𝘦𝘭. Flask was built for a 𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀 world. FastAPI was built for an 𝗮𝘀𝘆𝗻𝗰-𝗳𝗶𝗿𝘀𝘁 world. The speed difference isn't a feature. It's a 𝗳𝗼𝘂𝗻𝗱𝗮𝘁𝗶𝗼𝗻 difference. Next time someone says "FastAPI is fast", ask them: 𝘐𝘴 𝘪𝘵 𝘍𝘢𝘴𝘵𝘈𝘗𝘐, 𝘰𝘳 𝘪𝘴 𝘪𝘵 𝘚𝘵𝘢𝘳𝘭𝘦𝘵𝘵𝘦? #FastAPI #Flask #Starlette #Python #AsyncProgramming #BackendEngineering #SystemDesign #SoftwareEngineering
To view or add a comment, sign in
-
Shipped a small end-to-end backend pipeline this month: • Ingested noisy vendor-style location events (dedupe + retries + basic health stats) • Normalized positions with a simple quality policy (accuracy / jitter / floor sanity) • Derived events: zone enter/exit + asset proximity • Sketched the relational model + example SQL for “where was X between T0–T1?” Nice reminder that most of the work isn’t algorithms—it’s clear boundaries, idempotency, and making the data trustworthy before you build features on top. #backend #python #systemdesign #dataengineering
To view or add a comment, sign in
More from this author
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development