How arteria-project/arteria-delivery works
Main Components
• API Service (Tornado REST Service):
– Represented by the “delivery/app.py” file which is the entry point for the application.
– This component handles incoming RESTful API calls that clients will use.
• Request Handlers:
– Found under “delivery/handlers”, these modules (such as dds_handlers, delivery_handlers, project_handlers, etc.) implement the logic for different API endpoints.
– They serve as controllers processing user requests.
• Business/Service Layer:
– Under “delivery/services”, business logic such as analysing best practices, handling external programs, file system interactions, and staging work are implemented.
– This layer acts upon data provided or requested by the handlers before passing information further on.
• Data Access/Repository Layer:
– In “delivery/repositories”, access to persistence (e.g., creating, querying, and updating delivery records) is managed.
– This layer abstracts the database operations from the business logic.
• Database & Migration Management:
– The project uses Alembic (directory “alembic” and config files in “config/alembic.ini”) to handle schema migrations and database version control.
– Emphasize that schema changes made in “delivery/models/db_models.py” need migration scripts managed by Alembic.
• Configuration & Environment:
– The “config” directory contains configuration files for the application, logging, and organizational settings.
– There is also a Dockerfile for containerizing the service, indicating a deployment component.
• Testing:
– The “tests” folder (with unit and integration tests) shows how the components are verified separately, ensuring that the architecture’s separation is maintained.
Relationships and Interactions
• External Clients (or API Consumers) interact with the Tornado API (delivery/app.py).
• The API forwards requests to relevant Handlers.
• Handlers call the Service Layer to perform the core business functions.
• The Service Layer in turn uses the Repository Layer for CRUD operations against the database.
• The Repository Layer directly interacts with the database, where Alembic schedules and manages version updates and migrations.
• Configuration information feeds into the API service at startup, dictating log settings, DB connections, and other runtime parameters.
• The Dockerfile implies that containerization encapsulates the entire ecosystem for deployment.
Architectural Patterns and Design Principles
• Layered Architecture/MVC Patterns:
– The project cleanly separates concerns by splitting REST API (handlers), business logic (services), and data persistence (repositories).
– Database models are isolated in “delivery/models”.
• Configuration Management:
– System configuration is externalized in the “config” directory for easier modifications without code changes.
• Automated Database Migrations:
– Alembic is used for keeping the database schema in sync with the models.
• Testing and Continuous Integration:
– Integration and unit tests support each layer, ensuring interactions behave as expected.
Relevant Technologies and Tools
• Python 3.6+
• Tornado (as the underlying web server for handling REST APIs)
• Alembic for database migrations
• Docker for containerized deployment
• The layered structure is reflected in the use of repositories, services, and handlers.