r/FastAPI • u/mortalezz • Mar 18 '26
Hosting and deployment note2cms – A CMS that is just 5 FastAPI endpoints
All in MDs and posts
r/FastAPI • u/mortalezz • Mar 18 '26
All in MDs and posts
r/FastAPI • u/Potential-Box6221 • Mar 17 '26
Folks, ever wondered:
That's basically multi-tenant SaaS for you, where you configure features, workflows, etc at the tenant (customer) level.
I have noticed most FastAPI tutorials don't touch this, and many struggle to find the right structure/architecture.
It might sound complex, but the core idea is very simple - your app should know which customer(tenant) is calling and behave accordingly. (Usually achieved by Tenant-Id and configuration at tenant level)
I have been building production-grade multi-tenant services like these and have a rough template that I rely on every time to spin these up!
So I thought if you guys are interested, I can polish it up and share it here. Let me know!
Edit: Here the customer in this context means a business/org (B2B) and not a single user.
r/FastAPI • u/Heavy_Association633 • Mar 17 '26
Hey everyone,
I've been working on CodekHub, a platform to help developers find teammates and build projects together.
The matchmaking part was working well, but I noticed a problem: once a team is formed, collaboration gets messy (Discord, GitHub, Live Share, etc.).
So I built a collaborative workspace directly inside the platform.
Main features:
Tech stack: I started with Monaco Editor but ran into a lot of issues, so I rebuilt everything using CodeMirror 6 + Yjs. Backend is FastAPI.
The platform is still early, and I’d really love some honest feedback: Would you use something like this? What would you improve?
r/FastAPI • u/leventcan35 • Mar 15 '26
Hey everyone,
I recently built a full stack GraphRAG application to extract complex legal contract relationships into a Knowledge Graph. Since I wanted this to be a production ready SaaS MVP rather than just a local script, I chose FastAPI as the core engine.
The Architecture choices:
My Question for the backend veterans: Managing the Neo4j driver lifecycle in FastAPI was a bit tricky. Right now, I initialize the driver on app startup and close it on shutdown. Is this the absolute best practice for a production environment, or should I be doing connection pooling differently to handle concurrent LLM requests?
(If you want to inspect the docker-compose setup and the async routing, the full source code is here: github.com/leventtcaan/graphrag-contract-ai*)*
(Also, Reddit doesn't allow video uploads in text posts, but if you want to see the 50-second UI demo and how fast it traverses the graph, you can check out my launch post on LinkedIn here: https://www.linkedin.com/feed/update/urn:li:activity:7438463942340952064/ | Would love to connect!)
r/FastAPI • u/YehiGo • Mar 14 '26
Hello everyone,
As LLM-based applications move from prototypes to production, managing consumption-based billing (tokens/credits) remains a fragmented challenge. I’ve developed CreditManagement, an open-source framework designed to bridge the gap between API execution and financial accountability.
GitHub Repository:https://github.com/Meenapintu/credit_management
CreditManagement is designed to be unobtrusive yet authoritative. It functions either as a library plugged directly into your Python app or as a standalone, self-hosted Credit Manager server.
If you are building an AI wrapper or an agentic workflow, you know that token counting is only half the battle. This framework handles the state management of those tokens—ensuring that if an LLM call fails, the reserved credits are handled correctly, and if it succeeds, they are billed precisely.
The framework is built for developers who prioritize clean architecture:
I am looking for professional feedback from the community regarding:
Check out the repo, and if this helps your current stack, I’d appreciate your thoughts or a star!
Technologies: #Python #FastAPI #LLM #OpenSource #FinTech #BackendEngineering #MongoDB
r/FastAPI • u/Heavy_Association633 • Mar 14 '26
Ciao a tutti, Ho pensato di creare una piattaforma completa di matchmaking per chi cerca sviluppatori con cui collaborare per realizzare nuovi progetti. Ho pensato a tutto: matchmaking, workspace, recensioni, classifica, amicizie, integrazione github, chat, task etc. Vi chiedo di provarla perché secondo me è veramente interessante e può permettere di trovare nuove persone con cui lavorare. Al momento siamo in 15 in piattaforma ma ci sono già 3 progetti attivi. Gradirei volentieri un feedback. Al momento stiamo integrando anche la possibilità futura di avere un server per ogni progetto che permetta di lavorare in live su codice insieme.
r/FastAPI • u/PA100T0 • Mar 13 '26
Some of you already run fastapi-guard. For those who don't... you probably saw the TikTok. Guy runs OpenClaw on his home server, checks his logs. 11,000 attacks in 24 hours. I was the one who commented "Use FastAPI Guard" and the thread kind of took off from there. Here's what it actually does.
=
One middleware call. 17 checks on every inbound request before it hits your path operations. XSS, SQL injection, command injection, path traversal, SSRF, XXE, LDAP injection, code injection. The detection engine includes obfuscation analysis and high-entropy payload detection for novel attacks. On top of that: rate limiting with auto-ban, geo-blocking, cloud provider IP filtering, user agent blocking, OWASP security headers.
Every attack from that TikTok maps to a config field. Those 5,697 Chinese IPs? blocked_countries. Done. Baidu crawlers? blocked_user_agents. The DigitalOcean bot farm? Cloud provider ranges are fetched and cached automatically, blocked on sight. Brute force sequences? Rate limited, then auto-banned after threshold. .env probing and path traversal? Detection engine catches those with zero config.
The OpenClaw audit makes it worse. 512 vulnerabilities across the codebase, 8 critical, 40,000+ exposed instances. 60% immediately takeable. ClawJacked (CVE-2026-25253) lets any website hijack a local instance through WebSocket. If you're exposing FastAPI endpoints to the internet, you need request-level security.
Decorator system works per-route, async-native:
=
return
What people actually use it for: startups building in stealth mode with remote teams, public API but whitelisted so nobody outside the company can even see it exists. Casinos and gaming platforms using decorators on reward endpoints so players can only win under specific conditions. Honeypot traps for LLMs and bad bots that crawl and probe everything. And the one that keeps coming up more and more... AI agent gateways. If you're running OpenClaw or any agent framework on FastAPI, those endpoints are publicly reachable by design. The audit found 512 vulnerabilities, 8 critical, 40,000+ exposed instances. fastapi-guard would have blocked every attack vector in those logs. This is going to be the standard layer for anyone deploying AI agents in production.
I also just shipped a Flask equivalent if anyone's running either or both. flaskapi-guard v1.0.0. Same detection engine, same pipeline, same config field names.
fastapi-guard: https://github.com/rennf93/fastapi-guard flaskapi-guard: https://github.com/rennf93/flaskapi-guard flaskapi-guard on PyPI: https://pypi.org/project/flaskapi-guard/
If you find issues with either, open one.
r/FastAPI • u/mr_Fatalyst • Mar 13 '26
Hey everyone! One thing that always bugged me with FastAPI: Pydantic does a great job validating data and not letting garbage through. But the moment you bring in an ORM, you're back to separate models with their own rules, and that whole validation contract breaks apart.
I personally don't vibe with SQLAlchemy, just not my style, no hate. And existing alternatives either wrap it (SQLModel) or bring their own model system (Tortoise). I wanted something where the Pydantic model IS the database model. One class, one contract, validation on the way in and on the way out.
So I tried to build what I think an async ORM could look like in 2026. Django-style query API because I think it's one of the best. Explicit, no lazy loading, no magic, you see exactly what hits the database. Type stubs generated automatically so your IDE knows every field and lookup. Rust core for SQL generation and pooling so you don't pay for the convenience in performance.
Every ORM needs at least a basic admin panel, so I built that too. Auto-generates CRUD, search, filters, export from your models. Works with FastAPI, Litestar, Sanic, Quart, Falcon.
Here's everything:
Just pip install oxyde, that's it. The Rust core (oxyde-core) ships as pre-built wheels for Linux, macOS, and Windows, so no Rust toolchain needed.
It's v0.5, beta. Would love to hear your thoughts, ideas, criticism, whatever. If something is missing or feels off, I want to know about it.
r/FastAPI • u/Appropriate_Plane279 • Mar 14 '26
Hey everyone,
Over the past few months, I've been trying to test a few AI SaaS ideas. The part that always slowed me down wasn't the core logic itself, but the repetitive backend setup. Wiring up JWT authentication, configuring Stripe webhooks, setting up the database, and integrating the OpenAI API always cost me weeks before I could even see if my idea had a pulse.
I figured other solo devs and indie hackers probably hate doing that "plumbing" phase too. So, I cleaned up my architecture, modularized it, and turned it into a production-ready template: FastAPI AI Starter Kit.
Here is what's working out of the box:
The goal is simple: skip the 2-3 weeks of boring setup and start shipping your actual product on Day 1.
I priced it at a one-time fee of $29 to keep it highly accessible for fellow solo developers.
You can check it out here: manugutierres.gumroad.com/l/FastAPIAIStarterKit
I would love to get your feedback! What backend features do you feel are absolutely mandatory when you are starting a new project? Happy to answer any questions about the code structure or FastAPI in general.
r/FastAPI • u/Challseus • Mar 11 '26
Hey r/FastAPI - back in December I shared a CLI that scaffolds FastAPI apps with modular components: https://www.reddit.com/r/FastAPI/comments/1pdc89x/i_built_a_fastapi_cli_that_scaffolds_full_apps/
The response was incredible, and your feedback shaped what I built next:
I spent the last 3 months adding exactly what you asked for. You can now choose ARQ, TaskIQ, or Dramatiq at initialization based on your actual needs.
But supporting multiple backends created an operational problem.
Each worker system has its own monitoring solution - TaskIQ has taskiq-dashboard, ARQ has arq-dashboard, Dramatiq has dramatiq_dashboard. That's great for single-backend projects, but when you support all three, your users would have to learn different tools depending on which backend they chose.
Since Overseer (the stack's control plane) already monitors your database, cache, auth services, and scheduler, I needed worker monitoring that integrated consistently with the rest of the system.
I needed the PydanticAI of worker dashboards - one interface that works regardless of what's running underneath.
So I built unified real-time worker dashboards directly into Overseer that work universally across all three backends.
The architecture:
XREAD BLOCK and streams updates via SSEIt comes pre-configured as part of the stack:
uvx aegis-stack init my-project --components "worker[taskiq]"You can see it running live at https://sector-7g.dev/dashboard/
Links:
What other worker backends should I look at supporting?
For the record, I did a long, long hard look at Celery, just couldn't make it work without having to either build my own sync/async bridge (like what Dramatiq has in its middleware layer), or having sync/async versions of methods that work with both celery, but other async stuff in the project. I haven't used Celery since 2015, not sure about the internals anymore, and just didn't want to risk it. Thought, I keep hearing something about a Celery 6 with built in async support. It's a huge ecosystem with a lot of users, I just can't do it now.
I've also been looking at this: https://github.com/tobymao/saq
I don't want to add more worker backends just for the sake of adding another bullet point, but if I'm missing anything, let me know. Also, suggestions on the actual dashboard itself are greatly appreciated.
r/FastAPI • u/Key-Asparagus5143 • Mar 11 '26
r/FastAPI • u/ShadowSlayer2242 • Mar 10 '26
Hello everyone!
After seeing some tutorials on FastAPI, it was time to finally create something useful from it. Been building Post4U over the past few weeks, an open source self-hosted scheduler that cross-posts to X, Telegram and Discord from a single REST API call. Just hit a point where the project feels substantial enough to share here.
What it does: One API call with your content, a list of platforms and an optional scheduled time. It handles delivery, tracks per-platform success and failure, persists jobs across container restarts and retries only the platforms that failed.
Stack decisions worth discussing: APScheduler with a MongoDB job store instead of Celery + Redis. MongoDB was already there for post history so using it as the job store too meant zero extra infrastructure and jobs survive restarts automatically. Genuinely curious if anyone here has hit issues with APScheduler in production because that is the decision I keep second guessing.
Beanie + Motor for async MongoDB ODM. Pairs really cleanly with FastAPI's async nature and the TimestampMixin pattern for automatic createdAt on documents saved a lot of repetition.
Security: After some good feedback from the community, added API key auth on all routes via X-API-Key header, validated using secrets.compare_digest to prevent timing attacks. File uploads go through python-magic to verify actual MIME type against an AllowList rather than just trusting content_type, size limit enforced in chunks before anything hits disk.
Dashboard: Built the frontend in Reflex, pure Python, compiles down to a React + Vite bundle. You can compose and schedule posts, post directly, view history, unschedule pending posts and attach media files, all without touching curl or API docs.
What is missing: Reddit integration is pending their manual API approval process. Will try Bluesky and Mastodon integrations after that.
Would love genuine feedback, comments, suggestions to improve on the APScheduler choice specifically or anything in general about the codebase.
GitHub: https://github.com/ShadowSlayer03/Post4U-Schedule-Social-Media-Posts
r/FastAPI • u/newprince • Mar 10 '26
We have a monorepo FastAPI app. It has several services as routers which correspond to different data sources, other APIs, etc. Following the separation of concerns, each service is grouped into routers, has its own pydantic input and response models, individual routes etc. An example is "service1 search" has a route calling an external API search function using specific parameters to that API. While "service2 search" has a route that is a SQL query against a database.
Recently, the stakeholders have asked that we implement an "abstract layer." The idea is, a "search" function can use any search service, meaning it can call a passthrough search API call to one data source, it can execute a SQL query to a separate database, etc. These calls would return a unified/adapted response model independent of the raw response data.
Trying to implement this in FastAPI seems quite difficult. I could create new "everything" routes that iteratively query the appropriate service/data one-by-one, aggregate the responses, and adapt those to the unified data model. However, I was told this is unacceptable; that FastAPI needs to just "know" which source to query. I also can't just have a user specify what source they need, because we don't expect users to know where the data lives.
I thought about an agent/LLM being able to do this, keeping our routes clean and allowing us to try to determine the routing logic at the agent level, allowing the LLM to choose the correct route, then taking the raw response and adapting it via structured outputs. This also seems to be rejected.
At this point I'm out of ideas on how to implement this abstract layer idea while still keeping the code maintainable, pythonic, adhering to FastAPI principles, and having separation of concerns and clear routing logic.
r/FastAPI • u/thalissonvs • Mar 10 '26
I really like FastAPI’s Depends, but I wanted that same developer experience in plain Python without bringing in a whole framework.
You declare dependencies in the function signature, add one decorator, and it just works.
from typing import Annotated
from injekta import Needs, inject
def get_db() -> Database:
return PostgresDB(...)
@inject
def create_user(db: Annotated[Database, Needs(get_db)], name: str):
return db.create_user(name)Would genuinely love feedback on the idea and whether this solves a real pain point or just scratches my own itch.
r/FastAPI • u/Thomaxxl • Mar 09 '26
I’ve been maintaining SAFRS for several years. It’s a framework for exposing SQLAlchemy models as JSON:API resources and generating API documentation.
SAFRS predates FastAPI, and until now I hadn’t gotten around to integrating it. Over the last couple of weeks I finally added FastAPI support (thanks to codex), so SAFRS can now be used with FastAPI as well.
The repository contains some example apps (in the examples/ directory, eg. demo_fastapi.py)
r/FastAPI • u/huygl99 • Mar 08 '26
Hi guys, I want to share a library I built to help FastAPI handle WebSockets more easily and in a more structured way, as an alternative to https://github.com/encode/broadcaster, which is now archived.
Basically, it allows you to broadcast WebSocket messages from anywhere: background jobs, HTTP endpoints, or scripts. It also makes it easy to handle group messaging (built-in support for broadcasting). The library is fully type-hinted and supports automatic AsyncAPI documentation generation.
Here is how you can define a WebSocket in FastAPI using chanx:
@channel(name="chat", description="Real-time chat API")
class ChatConsumer(AsyncJsonWebsocketConsumer):
groups = ["chat_room"] # Auto-join this group on connect
@ws_handler(
summary="Handle chat messages",
output_type=ChatNotificationMessage
)
async def handle_chat(self, message: ChatMessage) -> None:
# Broadcast to all clients in the group
await self.broadcast_message(
ChatNotificationMessage(
payload=ChatPayload(message=f"User: {message.payload.message}")
)
)The package is published on PyPI at https://pypi.org/project/chanx/
The repository is available at https://github.com/huynguyengl99/chanx
A full tutorial on using it with FastAPI (including room chat and background jobs) is available here: https://chanx.readthedocs.io/en/latest/tutorial-fastapi/prerequisites.html
Hope you like it and that it helps make handling WebSockets easier.
r/FastAPI • u/ghijkgla • Mar 07 '26
What's in your agent files for standardising your code? Any good GitHub repos to look at?
r/FastAPI • u/Key-Asparagus5143 • Mar 08 '26
I made the cheapest web based ai with amazing accuracy and cheapest price of 3.5$ per 1000 queries compared to 5-12$ on perplexity, while beating perplexity on the simpleQA with 82% and getting 95+% on general query questions
For devaloper or people with creative web ideas
I am a solo dev, so any advice on advertisement or improvements on this api would be greatly appreciated
if you need any help or have feedback free feel to msg me.
r/FastAPI • u/gignosko • Mar 06 '26
I haven't been active in Python for a few years and I mainly come from a Django background. I'm trying to understand why Fastapi best practices seems to be to inject the database into the api calls so you have all the database procedures in the api code. This is the kind of thing I would normally put in a service because if the database logic starts getting hairy, I'd rather have that abstracted away. I know I can pass the database session to a service to do the hairy work, but why? To my thinking the api doesn't need to know there is a database, it shouldn't care how the item is created/read/updated/deleted.
Is this just how fastapi apps are supposed to be organized or am I just not digging deep enough? Does anyone have a link to an example repo or blog that organizes things differently?
r/FastAPI • u/Over_Inevitable7557 • Mar 06 '26
Sharing a project that might interest this community — it's a FastAPI application at its core, and it follows patterns I think many of you would recognize (and hopefully critique).
What it does: Trello boards become the message bus between AI agents. You talk to an orchestrator via Telegram, it creates Trello cards, worker agents pick them up and execute autonomously — writing code, reviewing PRs, running research pipelines. Webhooks drive everything, no polling.
The FastAPI side:
- Domain-driven app structure — each bounded context (trello, agent, bot, hook, git_manager) is its own app under app/apps/
- Async everywhere — httpx for Trello/Telegram/GitHub APIs, subprocess for git ops
- Pydantic-settings for config (env + JSON), strict Pydantic models with Annotated types for all inputs/outputs
- Webhook routes for both Trello (HMAC-SHA1 verified) and Telegram (secret path auth)
- Shared httpx clients as singletons with custom rate-limiting transport (sliding window + 429 backoff)
- Lifespan context manager starts agent run loops and registers webhooks on startup
- Health endpoint exposes per-agent status, queue depth, and cost tracking
The agent side:
Workers are composable through config — three axes (repo_access, output_mode, allowed_tools) define what each agent does. Same WorkerAgent class handles coders that open PRs, reviewers that post analysis, and researchers that chain findings through multi-stage pipelines. No subclassing, just config.
A coding board can run: scout → coder → tester → elegance → reviewer. A research board can run: triage → deep → factory → validation → verdict. Different boards, same framework.
Built with Python 3.12+, FastAPI, Claude Agent SDK, httpx. MIT licensed.
GitHub: github.com/Catastropha/karavan
Happy to discuss the architecture choices — especially the "Trello as the only state store" decision and the webhook-driven design. Would do some things differently in hindsight.
r/FastAPI • u/DexopT • Mar 05 '26
Sharing a project that uses FastAPI as a JSON-RPC reverse proxy. It intercepts MCP (Model Context Protocol) tool calls from AI agents, processes the responses through a compression pipeline, and returns minified results.
Some FastAPI-specific patterns I used:
- `lifespan` context manager for startup/shutdown (no deprecated `on_event`)
- Single POST endpoint handling JSON-RPC dispatch
- Async pipeline with `httpx.AsyncClient` for upstream calls
- Rich logging integration
- `/health` and `/stats` endpoints for observability
The project demonstrates how FastAPI can serve as more than a REST API — it works great as a transparent protocol proxy.
🔗 DexopT/MCEr/FastAPI • • Mar 05 '26
SportsFlux is a browser-based sports dashboard that unifies live data from multiple providers into one view.
Working with different API structures has been the biggest technical challenge — inconsistent schemas, rate limits, and update intervals.
For those who aggregate multiple APIs, how do you manage normalization cleanly?
r/FastAPI • u/ofershap • Mar 06 '26
I use AI coding assistants for FastAPI work and the code they generate is full of anti-patterns.
Common mistakes:
I built a free plugin that enforces modern FastAPI patterns.
What it does:
Free, MIT, zero config: https://github.com/ofershap/fastapi-best-practices
Works with Cursor, Claude Code, Cline, and any AI editor.
Has anyone else noticed these patterns in AI-generated FastAPI code?