Skip to content

feat: add FastAPI Blog API integration (test-apps/03-fastapi-blog-api)#9

Merged
Maneesh-Relanto merged 1 commit intomainfrom
feat/fastapi-blog-api
Feb 23, 2026
Merged

feat: add FastAPI Blog API integration (test-apps/03-fastapi-blog-api)#9
Maneesh-Relanto merged 1 commit intomainfrom
feat/fastapi-blog-api

Conversation

@Maneesh-Relanto
Copy link
Owner

Complete FastAPI Blog API demonstrating RBAC integration with FastAPI patterns. Mirrors the Flask test-app (02) but using idiomatic FastAPI conventions.

Architecture:

  • Pydantic v2 models for request/response validation + auto OpenAPI docs
  • FastAPI Depends() DI system replaces Flask decorators
  • HTTPBearer authentication with optional auth support
  • Lifespan context manager for startup/shutdown (vs Flask app factory)
  • RequirePermission / RequireRole class-based DI guards

Files added:

  • config.py Settings dataclass with env var support
  • models.py App-layer dataclasses (User, Post, Comment, SystemStats)
  • schemas.py Pydantic v2 request+response models
  • storage.py InMemoryStorage CRUD layer
  • auth.py AuthManager + FastAPI auth dependencies
  • dependencies.py RequirePermission, RequireRole DI classes + storage/rbac accessors
  • seed_data.py Demo data loader (5 users, 5 posts, 7 comments)
  • app.py FastAPI application with lifespan, CORS, all routes
  • requirements.txt fastapi, uvicorn, PyJWT, bcrypt, httpx, pytest-asyncio
  • test_api.py 39 tests covering auth, posts, comments, admin, RBAC enforcement

Tests: 39/39 passing

Complete FastAPI Blog API demonstrating RBAC integration with FastAPI patterns.
Mirrors the Flask test-app (02) but using idiomatic FastAPI conventions.

Architecture:
- Pydantic v2 models for request/response validation + auto OpenAPI docs
- FastAPI Depends() DI system replaces Flask decorators
- HTTPBearer authentication with optional auth support
- Lifespan context manager for startup/shutdown (vs Flask app factory)
- RequirePermission / RequireRole class-based DI guards

Files added:
- config.py       Settings dataclass with env var support
- models.py       App-layer dataclasses (User, Post, Comment, SystemStats)
- schemas.py      Pydantic v2 request+response models
- storage.py      InMemoryStorage CRUD layer
- auth.py         AuthManager + FastAPI auth dependencies
- dependencies.py RequirePermission, RequireRole DI classes + storage/rbac accessors
- seed_data.py    Demo data loader (5 users, 5 posts, 7 comments)
- app.py          FastAPI application with lifespan, CORS, all routes
- requirements.txt fastapi, uvicorn, PyJWT, bcrypt, httpx, pytest-asyncio
- test_api.py     39 tests covering auth, posts, comments, admin, RBAC enforcement

Tests: 39/39 passing
@Maneesh-Relanto Maneesh-Relanto merged commit 3e694b2 into main Feb 23, 2026
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant