How viktorviskov/fastapi-mvc works
Main Components
• Controllers: Represented by the files in the app/controllers folder (auth_controller.py, page_controller.py, user_controller.py). These handle incoming HTTP requests and map them to the appropriate business logic.
• Models: Located in the app/models directory (db.py, dto.py). They form the data layer and define the application’s domain models and data schemas.
• Services: Found in app/services (jwt_service.py, user_service.py). These implement core business logic and often interact with both models and external components.
• Database Layer: In the app/db folder (context.py and the initialization scripts). This component manages database connections, context, and interact with SQLAlchemy/Alembic migrations.
• Middlewares: In app/middlewares (cors_middleware.py, static_middleware.py). These intercept requests and responses to handle cross-cutting concerns like CORS and serving static files.
• Views: Although this is an API-driven application, the app/templates and app/static folders suggest that there is also some HTML rendering capability—handle views or static content to be served to the client.
• Utilities: In app/utils, containing auxiliary functions and tasks (e.g., hashing, background scheduling). These are supportive modules used across multiple layers.
• Infrastructure/Deployment: Dockerfile, docker-compose.yml, and related bash scripts (dev.bash, prod.sh, db_init.bash) indicate how the application is containerized and deployed.
• One branch directed toward the services layer (user_service, jwt_service).
• Another branch could go to serving static files or rendering templates (views) if applicable.
• Utility modules can be represented as support modules attached to both services and controllers, highlighting tasks like hashing and dependency injection.
Architectural Patterns
• Separation of concerns: Controllers handle routing and request management, services encapsulate business logic, models represent data structures, and utility functions provide common infrastructure support.
• Deployment practices with Docker and docker-compose, representing how the application is containerized and how it interacts with external database services if any.
Technologies and External Libraries
• Optionally, denote the Docker integration and bash scripts that manage development and production setups.