How odaiahmed99/fastapi-mvt works
fastapi-mvt is a productivity library for ordinary FastAPI applications: it adds an async Django-style ORM, request-scoped transactions, safe Alembic migrations, project scaffolding and CLI workflows, plus optional authentication, admin, and WebSocket fan-out. A typical API request enters the app, uses ORM queries within the request transaction, and returns model data; developers also create projects and evolve schemas through the CLI. The README documents a migration-built, rollback-isolated test harness. Some subsystems are represented at their exact enclosing paths because their implementation was not sampled.
Main entry points: commands.py Migration workflow · database.py Database sessions · cli.py CLI commands · __init__.py Authentication
Components 23
ORM and requests
- Request transactions
fastapi_mvt/db/database.py - Models and fields
fastapi_mvt/db/models.py - QuerySet ORM
fastapi_mvt/db/query.py - Database sessions
fastapi_mvt/db/database.py - Model schemas
fastapi_mvt/db/schemas.py - Pagination
fastapi_mvt/db/pagination.py
Schema evolution
- Migration workflow
fastapi_mvt/migrations/commands.py - Migration safety
fastapi_mvt/migrations/autogen.py - Migration history
fastapi_mvt/migrations
Project tools
- Project loading
fastapi_mvt/project.py - CLI commands
fastapi_mvt/cli.py - Project scaffolding
fastapi_mvt/scaffold - Test harness
fastapi_mvt/testing/plugin.py
Optional capabilities
- Authentication
fastapi_mvt/auth/__init__.py - Password hashing
fastapi_mvt/auth/passwords.py - Admin site
fastapi_mvt/admin.py - WebSocket fan-out
fastapi_mvt/websockets.py
Other components
- API developer
- API client
- FastAPI app
- CLI user
- SQL database
- Redis
Connections 31
- API client → FastAPI app: sends requests
- FastAPI app → Request transactions: handles requests
- Request transactions → Database sessions: opens session
- Request transactions → FastAPI app: commits before response
- FastAPI app → API client: returns response
- API developer → FastAPI app: defines API
- Models and fields → QuerySet ORM: provides models
- QuerySet ORM → Database sessions: executes queries
- Database sessions → SQL database: reads and writes
- API developer → Model schemas: defines schemas
- Model schemas → Models and fields: derives from models
- API developer → Pagination: uses pagination
- Pagination → QuerySet ORM: paginates queries
- CLI user → CLI commands: runs commands
- CLI commands → Project loading: loads project
- CLI commands → Project scaffolding: generates projects
- CLI commands → Migration workflow: dispatches migration commands
- Migration workflow → Project loading: loads project settings
- Migration workflow → Migration safety: checks model changes
- Migration workflow → Migration history: applies and records migrations
- Migration safety → Models and fields: compares model metadata
- Test harness → Project loading: loads project
- Test harness → Migration workflow: builds test database
- Test harness → Database sessions: isolates test transactions
- FastAPI app → Authentication: serves auth routes
- Authentication → QuerySet ORM: looks up users
- Authentication → Password hashing: hashes passwords
- Admin site → Database sessions: uses session maker
- Admin site → Authentication: authenticates admins
- FastAPI app → WebSocket fan-out: serves WebSockets
- WebSocket fan-out → Redis: publishes across processes