How inf-inf/hackathon_more_tech_5_back works
Project Type and Purpose
• It’s a backend service with a REST API (using uvicorn to run the ASGI app) that supports functionalities such as showing branch/ATM location data, calculating walking/automobile routes, and analyzing branch load.
• The README mentions algorithmic decision-making for optimal branch selection, route building (possibly integrating third-party mapping services), logging history, and implementing security/auth flows via tokens and phone authentication.
File Structure – Main Components
• Application Layer:
• In the src/app folder, the main API application (api_app.py) is defined.
• Lifespan management (src/app/lifespan) handles startup routines, possibly initializing dependencies or database connections.
• Middleware (src/app/middleware) includes security-related routines that intercept or validate requests.
• Caching:
• The src/cache folder holds modules for caching logic like SMS and security, which may be used to optimize repeated operations (e.g., one-time token generation or throttling API calls).
• Database Layer:
• The src/database directory contains the base connection logic, models (defining ORM/schema objects), and CRUD operations separated into modules (e.g., history.py for logging or locations.py for dealing with branch details).
• Business Logic and Dependencies:
• Business logic is organized in the src/logic folder and also appears in dedicated dependencies folders:
• src/dependencies/database for connection handling.
• src/dependencies/logic with modules to process history, locations, and users.
• src/dependencies/security for security (and in src/models/security for additional structure).
• Routing and Schemas:
• API endpoints are implemented via routers (src/routers) which map URL paths to specific functionalities such as history, locations, service, and user.
• Validation and data structures are defined in the src/schemas folder.
• Supplemental Data and Documentation:
• The data folder includes JSON files (for atms and offices) which may be used as seed data or as a part of the service’s input.
• The docs folder contains a preview PDF, likely used for design or explanation of the service.
Relationships and Interactions Between Components
• The entry point (src/main.py) starts up the API application, instantiating the ASGI app.
• The API layer (src/app/api_app.py) routes incoming HTTP requests to the appropriate routers in src/routers.
• Routers interface with business logic found in src/logic and src/dependencies/logic to process requests.
• These logic layers handle interactions with the database layer (src/database) through CRUD operations to read/write the necessary data.
• Middleware and security dependencies manage authentication by leveraging components from src/dependencies/security and src/cache/security.
• Caching may be used in endpoints to avoid repeated expensive operations (e.g., sending SMS for token auth).
Architectural Patterns & Design Principles
• Layered or modular architecture: Clear separation between API (routing), business logic, data access (CRUD & models), and dependencies.
• Scalability considerations: Though it’s currently monolithic, the README indicates that the design allows the backend to be split into modules later (e.g., separate modules for reviews, queue management, etc.).
• Clear separation of concerns: Each folder represents a distinct responsibility (e.g., lifecycle management, caching, routing).