[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-72537":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":38,"readmeContent":39,"aiSummary":40,"trendingCount":16,"starSnapshotCount":16,"syncStatus":41,"lastSyncTime":42,"discoverSource":43},72537,"fastapi-langgraph-agent-production-ready-template","wassim249\u002Ffastapi-langgraph-agent-production-ready-template","wassim249","A production-ready FastAPI template for building AI agent applications with LangGraph integration. This template provides a robust foundation for building scalable, secure, and maintainable AI agent services.","",null,"Python",2386,559,11,4,0,25,51,136,75,30.24,"MIT License",false,"master",true,[27,28,29,30,31,32,33,34,35,36,37],"agent","agentic-ai","docker","fastapi","fastapi-template","langchain","langchain-python","langgraph","langgraph-python","llm","memory","2026-06-12 02:03:04","# FastAPI LangGraph Agent Template\n\nA production-ready template for building AI agent backends with FastAPI and LangGraph. Handles the hard parts — stateful conversations, long-term memory, tool calling, observability, rate limiting, auth — so you can focus on your agent logic.\n\n**Built for AI engineers** who want a solid foundation, not a tutorial project.\n\n## What's included\n\n- **LangGraph** stateful agent with checkpointing, tool calling, and human-in-the-loop support\n- **Long-term memory** via mem0 + pgvector — semantic search per user, cache-backed\n- **LLM service** with circular model fallback, exponential backoff retries, and total timeout budget\n- **Langfuse** tracing on all LLM calls; Prometheus metrics + Grafana dashboards\n- **JWT auth** with session management; rate limiting via slowapi\n- **Alembic** migrations; optional Valkey\u002FRedis cache layer\n- **Structured logging** with request\u002Fsession\u002Fuser context on every line\n\n## Quickstart\n\n```bash\ngit clone \u003Crepo-url> my-agent && cd my-agent\ncp .env.example .env.development   # fill in your keys\nmake install\nmake docker-up                     # starts API + PostgreSQL\n```\n\nOpen [http:\u002F\u002Flocalhost:8000\u002Fdocs](http:\u002F\u002Flocalhost:8000\u002Fdocs) to see the interactive API.\n\n> For local development without Docker see [docs\u002Fgetting-started.md](docs\u002Fgetting-started.md).\n\n## Documentation\n\n| Guide | What it covers |\n|---|---|\n| [Getting Started](docs\u002Fgetting-started.md) | Prerequisites, local setup, first API call |\n| [Architecture](docs\u002Farchitecture.md) | System design, request flow, component diagrams |\n| [Configuration](docs\u002Fconfiguration.md) | All environment variables with defaults |\n| [Authentication](docs\u002Fauthentication.md) | JWT flow, sessions, endpoint reference |\n| [Database & Migrations](docs\u002Fdatabase.md) | Schema, Alembic migrations, pgvector |\n| [LLM Service](docs\u002Fllm-service.md) | Models, retries, fallback, timeout budget |\n| [Memory](docs\u002Fmemory.md) | mem0 long-term memory, cache layer |\n| [Observability](docs\u002Fobservability.md) | Langfuse, structured logging, Prometheus, profiling |\n| [Evaluation](docs\u002Fevaluation.md) | Eval framework, custom metrics, reports |\n| [Docker](docs\u002Fdocker.md) | Docker, Compose, full monitoring stack |\n\n## Project structure\n\n```\napp\u002F\n  api\u002Fv1\u002F          # Route handlers\n  core\u002F\n    langgraph\u002F     # Agent graph + tools\n    prompts\u002F       # System prompt template\n    cache.py       # Valkey\u002FRedis + in-memory fallback\n    config.py      # Settings\n    middleware.py  # Metrics, logging context, profiling\n    limiter.py     # Rate limiting\n  models\u002F          # SQLModel ORM models\n  schemas\u002F         # Pydantic request\u002Fresponse schemas\n  services\u002F        # LLM, database, memory services\nalembic\u002F           # Database migrations\nevals\u002F             # LLM evaluation framework\n```\n\n## Contributing\n\nPRs welcome. Please read [docs\u002Fgetting-started.md](docs\u002Fgetting-started.md) to get your environment set up, then follow the coding conventions in [AGENTS.md](AGENTS.md).\n\nReport security issues privately — see [SECURITY.md](SECURITY.md).\n\n## License\n\nSee [LICENSE](LICENSE).\n\n## FAQ\n\n### General\n\n**What is this template?**\nA production-ready foundation for AI agent backends built on FastAPI + LangGraph. It bundles the components you'd otherwise wire up by hand: stateful conversations, long-term memory, tool calling, observability, rate limiting, and JWT auth.\n\n**How does this differ from a basic LangGraph setup?**\nThe base LangGraph quickstart stops at \"agent runs locally\". This template adds Alembic migrations, mem0 + pgvector long-term memory, Langfuse tracing, Prometheus + Grafana dashboards, JWT sessions, slowapi rate limiting, structured logging with per-request context, and a circular-fallback LLM service — production concerns you'd otherwise build separately.\n\n### Setup & Configuration\n\n**Do I need Docker?**\nRecommended but not required. `make docker-up` starts the API + PostgreSQL together. For local-only setup see [docs\u002Fgetting-started.md](docs\u002Fgetting-started.md).\n\n**Which LLM providers are supported?**\nToday: **OpenAI only** via the `LLMRegistry` in `app\u002Fservices\u002Fllm\u002Fregistry.py`. Multi-provider support (Anthropic, Google, OpenRouter) via LangChain's `init_chat_model` is planned — see [#51](https:\u002F\u002Fgithub.com\u002Fwassim249\u002Ffastapi-langgraph-agent-production-ready-template\u002Fissues\u002F51). Configure your model via `DEFAULT_LLM_MODEL` in `.env.development`.\n\n**How do I configure long-term memory?**\nLong-term memory is self-hosted: mem0 runs in-process and persists into your existing PostgreSQL via pgvector — there is no separate mem0 cloud account or API key. You only need a working `OPENAI_API_KEY` (used for fact extraction + embeddings) and the pgvector extension enabled. See [docs\u002Fmemory.md](docs\u002Fmemory.md) for details.\n\n### Development\n\n**How do I add a custom tool?**\nDrop a LangChain `@tool`-decorated function in `app\u002Fcore\u002Flanggraph\u002Ftools\u002F` and register it in the `tools` list exported from that package. The agent picks it up on next start; no graph changes needed.\n\n**How does the LLM service handle failures?**\nTwo layers: (1) per-call exponential-backoff retry via `tenacity`, (2) **circular fallback** — if the active model exhausts its retries, the service rotates to the next model in `LLMRegistry` and continues. A total timeout budget caps the whole call so latency stays bounded. See [docs\u002Fllm-service.md](docs\u002Fllm-service.md).\n\n**Can I use this without Langfuse?**\nYes. Set `LANGFUSE_TRACING_ENABLED=false` (or omit the Langfuse keys). The agent runs unchanged; structured logs still capture request\u002Fsession\u002Fuser context.\n\n### Troubleshooting\n\n**The API won't start**\n- Ensure PostgreSQL is running (`make docker-up` brings it up alongside the API)\n- Confirm `.env.development` exists — copy from `.env.example` and fill in required keys\n- Apply migrations: `make migrate`\n\n**Memory \u002F semantic search returns nothing**\n- Verify the `pgvector` extension is enabled in your PostgreSQL instance\n- Confirm `OPENAI_API_KEY` is valid (mem0 calls OpenAI for fact extraction + embeddings)\n- Check `LONG_TERM_MEMORY_MODEL` and `LONG_TERM_MEMORY_EMBEDDER_MODEL` are set in `.env.development`\n\n**Rate limiting is too aggressive**\nLimits are defined in `app\u002Fcore\u002Flimiter.py` (slowapi). Adjust per-route decorators or the default rate in that file. See [docs\u002Fconfiguration.md](docs\u002Fconfiguration.md) for the related env vars.\n","该项目提供了一个用于构建集成LangGraph的AI代理应用的生产就绪FastAPI模板，旨在为开发可扩展、安全且易于维护的AI代理服务奠定坚实基础。核心功能包括支持状态对话和长期记忆管理、工具调用、以及通过Langfuse进行链路追踪等高级特性；同时内置了基于JWT的身份验证机制、慢速API限流策略，并对所有LLM调用实施了超时控制与重试逻辑。适用于希望快速搭建高效能AI后端服务的研发团队或个人开发者，在无需从零开始的情况下专注于实现具体的业务逻辑。",2,"2026-06-11 03:42:29","high_star"]