{"id":50119620,"url":"https://github.com/amha-kindu/fidel-api","last_synced_at":"2026-05-23T18:04:54.265Z","repository":{"id":355916295,"uuid":"1228269593","full_name":"amha-kindu/fidel-api","owner":"amha-kindu","description":"FastAPI backend for Fidel AI with JWT authentication, async SQLAlchemy/PostgreSQL persistence, Redis caching, rate limiting, and SSE chat streaming.","archived":false,"fork":false,"pushed_at":"2026-05-05T19:47:52.000Z","size":188,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-05T21:29:09.296Z","etag":null,"topics":["alembic","api","backend","fastapi","jwt-authentication","postgresql","python","rate-limiting","redis","sqlalchemy","sse"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amha-kindu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-03T20:16:04.000Z","updated_at":"2026-05-05T19:47:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/amha-kindu/fidel-api","commit_stats":null,"previous_names":["amha-kindu/fidel-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/amha-kindu/fidel-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amha-kindu%2Ffidel-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amha-kindu%2Ffidel-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amha-kindu%2Ffidel-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amha-kindu%2Ffidel-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amha-kindu","download_url":"https://codeload.github.com/amha-kindu/fidel-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amha-kindu%2Ffidel-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33406482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alembic","api","backend","fastapi","jwt-authentication","postgresql","python","rate-limiting","redis","sqlalchemy","sse"],"created_at":"2026-05-23T18:04:21.838Z","updated_at":"2026-05-23T18:04:54.257Z","avatar_url":"https://github.com/amha-kindu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eFidel API\u003c/h1\u003e\n  \u003cp\u003e\u003cstrong\u003eReal-time FastAPI backend for conversational applications\u003c/strong\u003e\u003c/p\u003e\n  \u003cp\u003e\n    Authentication, conversation management, SSE chat streaming, Redis-backed caching,\n    rate limiting, and an inference proxy layer in a single service.\n  \u003c/p\u003e\n  \u003cp\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Python-3.12%2B-3776AB?logo=python\u0026logoColor=white\" alt=\"Python 3.11+\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/FastAPI-0.124-009688?logo=fastapi\u0026logoColor=white\" alt=\"FastAPI 0.124\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Pydantic-v2-E92063?logo=pydantic\u0026logoColor=white\" alt=\"Pydantic v2\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/SQLAlchemy-2.0-D71F00?logo=sqlalchemy\u0026logoColor=white\" alt=\"SQLAlchemy 2.0\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/PostgreSQL-Database-4169E1?logo=postgresql\u0026logoColor=white\" alt=\"PostgreSQL\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Redis-Cache%20%26%20Rate%20Limits-DC382D?logo=redis\u0026logoColor=white\" alt=\"Redis\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/OpenAPI-Docs-6BA539?logo=openapiinitiative\u0026logoColor=white\" alt=\"OpenAPI\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Coverage-90%25%2B-brightgreen\" alt=\"Coverage 90%+\"\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## Overview\n\nFidel API is a production-oriented FastAPI backend for ChatGPT-style experiences. It exposes authenticated APIs for users, conversations, and message history, then proxies streaming chat completions from an inference backend over Server-Sent Events.\n\nThe codebase is structured around clear application layers:\n\n- `api` for HTTP routes and dependency wiring\n- `services` for orchestration and business logic\n- `repositories` for data access\n- `models` and `schemas` for persistence and contract boundaries\n- `core` for configuration, security, logging, caching, and rate limiting\n\n## Why This Project\n\n- JWT-based authentication with Argon2 password hashing\n- Conversation and message persistence with async SQLAlchemy and Postgres\n- Streaming chat via `POST /api/v1/chats/stream`\n- Optional conversation reuse through the `id` query parameter\n- Redis-backed history caching and SlowAPI rate limiting\n- Structured JSON logging with `structlog`\n- OpenAPI documentation out of the box\n- Test suite with coverage enforcement\n\n## Stack At A Glance\n\n| Layer | Technology |\n| --- | --- |\n| API | FastAPI, ORJSON responses, OpenAPI |\n| Validation | Pydantic v2, pydantic-settings |\n| Database | PostgreSQL, SQLAlchemy 2.x, Alembic |\n| Caching | Redis |\n| Auth | JWT, `python-jose`, Argon2 |\n| Streaming | SSE via `sse-starlette` |\n| HTTP Client | `httpx` |\n| Testing | `pytest`, `pytest-asyncio`, coverage |\n\n## API Surface\n\n| Method | Route | Purpose |\n| --- | --- | --- |\n| `POST` | `/api/v1/auth/register` | Create a user account |\n| `POST` | `/api/v1/auth/login` | Authenticate and return a bearer token |\n| `GET` | `/api/v1/users/me` | Fetch the current authenticated user |\n| `POST` | `/api/v1/chats` | Create a conversation |\n| `GET` | `/api/v1/chats` | List conversations |\n| `GET` | `/api/v1/chats/{id}` | Return conversation message history |\n| `DELETE` | `/api/v1/chats/{id}` | Delete a conversation |\n| `POST` | `/api/v1/chats/stream?id=\u003cconversation_id\u003e` | Stream an assistant reply and optionally reuse a conversation |\n| `GET` | `/health` | Basic healthcheck |\n\nAuthentication uses:\n\n```http\nAuthorization: Bearer \u003ctoken\u003e\n```\n\nInteractive docs are available at:\n\n- `/docs` for Swagger UI\n- `/redoc` for ReDoc\n- `/openapi.json` for the raw spec\n\n## Quick Start\n\n### Prerequisites\n\n- Python `3.12+`\n- Docker and Docker Compose\n- PostgreSQL and Redis if running outside Docker\n\n### Environment Setup\n\nCreate a local environment file from the example:\n\n```bash\ncp .env.example .env\n```\n\nImportant settings:\n\n- `DATABASE_URL`\n- `TEST_DATABASE_URL`\n- `REDIS_URL`\n- `JWT_SECRET`\n- `INFERENCE_BASE_URL`\n- `RATE_LIMIT_STORAGE_URI`\n\nIf you want in-memory rate limiting in development or tests, set:\n\n```env\nRATE_LIMIT_STORAGE_URI=memory://\n```\n\n## Run With Docker\n\nBring the stack up from the repo root:\n\n```bash\ndocker-compose up --build\n```\n\nDefault local endpoints:\n\n- API: `http://localhost:8000`\n- Swagger UI: `http://localhost:8000/docs`\n- ReDoc: `http://localhost:8000/redoc`\n- Adminer: `http://localhost:8080`\n\n## Local Development\n\nInstall dependencies in your preferred Python environment, then run:\n\n```bash\nalembic upgrade head\nuvicorn app.main:app --host 0.0.0.0 --port 8000 --reload\n```\n\nWhen running locally, make sure Postgres and Redis are reachable from the values in `.env`.\n\n## Project Structure\n\n```text\napp/\n  api/              # FastAPI routes and dependency wiring\n  core/             # config, logging, security, caching, rate limiting\n  db/               # session management and Alembic migrations\n  models/           # SQLAlchemy ORM models\n  repositories/     # persistence helpers\n  schemas/          # request/response schemas\n  services/         # business logic and orchestration\n  main.py           # app creation and lifespan wiring\ntests/              # unit and API tests\nscripts/            # utility scripts such as OpenAPI export\n```\n\n## Testing\n\nRun the full test suite:\n\n```bash\npytest\n```\n\nThe repository enforces:\n\n- strict pytest markers\n- HTML coverage output\n- minimum coverage threshold of `90%`\n\n## OpenAPI Export\n\nTo export a static OpenAPI document from the repo root, ensure the repo root is on `PYTHONPATH` and run:\n\n```bash\nPYTHONPATH=. python scripts/export_openapi.py\n```\n\nThis writes `openapi.json` at the project root.\n\n## Production Notes\n\n- Run behind a reverse proxy or ingress that terminates TLS\n- Use a strong `JWT_SECRET`\n- Point `DATABASE_URL` and `REDIS_URL` at production-grade services\n- Use Redis for both history caching and distributed rate limiting\n- Keep the inference backend reachable and monitored separately from the API\n\n## Development Focus\n\nThis codebase is optimized for:\n\n- preserving a stable API surface\n- keeping service and repository responsibilities clear\n- making streaming chat behavior testable\n- supporting iterative backend cleanup without breaking clients\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famha-kindu%2Ffidel-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famha-kindu%2Ffidel-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famha-kindu%2Ffidel-api/lists"}