# pmareke/lift architecture

> Architecture diagram of the GitHub repository pmareke/lift, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pmareke/lift
- Repository: https://github.com/pmareke/lift

## Overview

##### 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!

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("User/Client"):::external

    subgraph "Delivery Layer"
        B("API Controllers"):::delivery
    end

    subgraph "Use Cases Layer"
        C("Use Case Handlers"):::usecases
    end

    subgraph "Domain Layer"
        D("Domain Logic"):::domain
    end

    subgraph "Infrastructure Layer"
        E("SQL Repository"):::infra
    end

    F("MySQL Database"):::external

    A -->|"sendsRequest"| B
    B -->|"callsHandler"| C
    C -->|"executesLogic"| D
    C -->|"delegatesPersistence"| E
    E -->|"accessesData"| F

    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef delivery fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef usecases fill:#caffbf,stroke:#333,stroke-width:2px;
    classDef domain fill:#9bf6ff,stroke:#333,stroke-width:2px;
    classDef infra fill:#ffadad,stroke:#333,stroke-width:2px;

    click B "https://github.com/pmareke/lift/tree/main/src/delivery/api"
    click C "https://github.com/pmareke/lift/tree/main/src/use_cases"
    click D "https://github.com/pmareke/lift/tree/main/src/domain"
    click E "https://github.com/pmareke/lift/tree/main/src/infrastructure/mysql"
    click F "https://github.com/pmareke/lift/tree/main/database"
```
