How pmareke/lift works
Project Type & Purpose
• The project is a Python-based pricing application for ski lift passes. It calculates costs based on lift pass type, user age, and schedule specifics.
• The README and file structure clearly indicate that it is designed using a hexagonal architecture (ports and adapters) to isolate core business logic from delivery (HTTP/REST) and persistence (SQL/MySQL).
• There’s ongoing work to refactor the code to improve testability and reuse, indicating that business rules and infrastructure concerns must be kept separate.
File Structure
• Top-Level Directories and Files:
• The project uses standard configuration files (Dockerfile, Makefile, compose.yaml) and testing configurations (pytest.ini, mypy.ini).
• The app code is in the “src” folder which is further divided into:
▪ delivery – This contains the API controllers (HTTP/rest layer) handling incoming requests (e.g., add_price_controller, get_price_controller).
▪ domain – This encapsulates the core business logic, domain rules, business entities (like lift_pass, lift_pass_cost, exceptions), and possibly factories/repositories interfaces.
▪ infrastructure – This implements the persistence adapter with MySQL connections (including connection management and implementation of SQL-based repositories).
▪ use_cases – This layer holds the command and query handlers which orchestrate operations by taking data from the HTTP layer, applying business rules, and then interacting with infrastructure.
• There is a clear separation into multiple layers, consistent with hexagonal architecture principles.
• Testing Directories:
• The project includes separation of tests: acceptance, integration, and unit tests, which implies that the architecture should isolate external dependencies (like DB, HTTP) for easier testing.
README Insights
• The README emphasizes hexagonal architecture and the separation of concerns:
• It outlines a typical workflow that decouples the HTTP layer, business logic (e.g., PricingLogic), and SQL-specific data access (e.g., PricingDao).
• There is also a clear requirement for extending the functionality (support for pricing several lift passes) – suggesting the need for modular and reusable design components.
Instructing the Principal Software Engineer
– One for Delivery (with API endpoints such as add_price, get_price(s)).
– One for Use Cases (showing command/query handlers).
– One for Domain (containing business objects like lift_pass, cost logic, factories, exceptions).
– One for Infrastructure (MySQL connection management and repository implementations).
– And one for the external Database.
– Illustrate the chain: HTTP request → API Controller → Use Case Handler → Domain Logic → Infrastructure → Database, and then the reverse flow for responses.
– External systems (like the DB) from internal components.
– Adapters (for HTTP and SQL) from core business logic.
• Be thorough in capturing key design principles—emphasize the hexagonal (ports and adapters) approach that decouples the system, making high-level (HTTP and integration) tests easy to separate from unit tests.
Summary:
Happy Diagramming!