How olukeye/fastapi-shop-app works
Main Components
• API Layer: Represented by the FastAPI application itself. This includes the main entry point (main.py) and the “routes” directory. Within “routes”, you have dedicated modules for auth, business, category, order, product, and user endpoints.
• Business Logic & Service Layer: Include the “app” directory (which has mail handling and helper functions) and possibly parts of “utils” focused on authentication (e.g., oauth2) and date or hashing functionalities.
• Data Model & Domain Layer: Captured by the “models” directory, which defines ORM models (business, category, orders, product, user). The “pydantic_schemas” directory provides data validation and serialization using Pydantic, ensuring correct data formats between layers.
• Data Access & Repository Layer: Modules in the “repositories” directory abstract direct database interactions for business, category, order, product, and user data.
• Database Layer & Migrations: The “db” directory (specifically database.py) is responsible for the database connection and operations, while the “alembic” folder contains migration scripts that manage schema changes.
• Configuration & Environment Management: The “setttings” directory (with its config.py) likely handles environment variables and other configuration parameters.
• External Integrations & Utilities:
• The flutterwave.py file indicates integration with a payment service.
• Deployment and containerization are facilitated via Dockerfile, docker-compose.yml, and Procfile.
• Email functionalities are managed in the “app/mails” folder.
Relationships and Data Flow
• Reverse data flow for returning response objects back to the client.
Architectural Patterns
• The separation of concerns is clear: routing (API layer), business logic (service layer), data persistence (repository & database layers), and configuration.
• Dependency inversion: routes depend on repository interfaces (abstracting direct DB calls) and utilize Pydantic schemas for data validation/serialization.