How conqerorior/fastapi_prosept_dealer works
Main Components
• API Server: The heart of the application is built with FastAPI (app/main.py). It exposes API endpoints (including the admin and public API endpoints).
• Application Modules: The project has a modular structure with components such as:
• app/matching: Contains CRUD operations, models, schemas, routers, and scripts related to matching dealers.
• app/products: Contains product-related models and (potentially) business logic.
• app/admin: Provides the administrative interface.
• Database Layer:
• app/db/database.py, along with SQLAlchemy (and PostgreSQL as seen in the README and Docker setup), handles data persistence.
• Alembic directory and configuration (alembic.ini, alembic/env.py, versions) manage schema migrations.
• Data Loading & CSV Data:
• The app/csv directory contains CSV files and a pickled model, while load_data.py is a script to seed or update the database.
• Infra / Docker Configuration:
• The infra directory holds the Docker Compose configuration (docker-compose.yml) and server configuration (default.conf) that bring up related services including the backend container, PostgreSQL, and PGAdmin.
• Testing:
• In the tests directory, unit and integration tests validate product functionalities.
Relationships and Interactions
• The API server interacts with the Database through SQLAlchemy (with migrations managed by Alembic).
• The modular components (matching, products, admin) are integrated within the FastAPI application and communicate through defined routers.
• The Data Loading process uses CSV files to populate or update the database.
• In containerized deployment, Docker Compose brings up:
• A backend container running the FastAPI application.
• A PostgreSQL container (database service) that the backend connects to.
• A PGAdmin container for database management.
• API requests flowing from clients (or API consumers such as the redoc documentation) to the API server.
• The API server’s data flow toward the database service.
• Administrative access routed to the admin interface.
• Integration of the load_data script for initial data seeding.
Architectural Patterns and Technologies
• Modular Design: Clear separation into modules (matching, products, admin) promotes maintainability.
• FastAPI framework: Utilized for building the API endpoints.
• SQLAlchemy and Alembic: Abstract and manage interactions with the PostgreSQL database.
• Docker & Docker Compose: Containerizes the application for both development and production, isolating concerns (e.g., web service vs. database).
• Testing Layer: Structured tests ensure system reliability.
• Environment Configuration: Usage of .env files to decouple configuration from code.
Final Organizational Advice
• Be very detailed: every service, module, or script that plays an essential role should be included.
• Do not overcomplicate – simply breaking down the system into the numerous components as described is best.