# zyla/ceburilo architecture

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

- Interactive diagram: https://gitdiagram.com/zyla/ceburilo
- Repository: https://github.com/zyla/ceburilo

## Overview

- API Server: Represent the “app/server” as the primary service handling incoming /route queries. This is where client requests are processed.
- Precomputation Service: Represent “app/precompute” which likely computes and caches graph data, precomputed routes, or station arrangements for performance.
- Configuration & Assets: Show the “config” folder (and its routes file), “graphhopper” folder (with its configuration file and nextbike data), and scripts (deployment scripts, service configuration) as components that supply parameters, external data, and deployment configuration.
- External Data/Services: Since the README example response includes station data along with routing information, incorporate external data sources (like NextBike data provided via the XML file) as inputs to the precomputation and/or API logic.

##### Relationships and data-flow
- “Precomputation Service” to the “Core Modules” to show that it pre-calculates routes and possibly stores/caches the computed data (this might feed directly or indirectly into the API response).
- Optionally, add a component for “Deployment & Scripts” (taking cues from the scripts directory and get_paths.sh, get_stations.sh, etc.) to reflect how different parts are deployed and managed in production.

##### Important architectural patterns
- Separation between the API layer (handling HTTP requests) and the precomputation layer (offline computation and data preparation). This separation improves performance and scalability.
- Module-based design within “src”, which points to encapsulation of the domain logic (graph and geographic computations) within distinct Haskell modules.
- The use of configuration files and external data (graphhopper configs, NextBike XML) suggests a design that externalizes environment-specific parameters to simplify maintenance and deployment.

##### Details on technologies and design principles
- Haskell/Cabal/Stack: Since the cabal file and stack.yaml exist, note that the project is built and managed using the Haskell toolchain.
- RESTful API: The API server is designed to handle RESTful GET requests (illustrated in the README). Indicate that the design focuses on stateless, parameterized requests.
- Batch/Background Processing: The precomputation subsystem is likely designed to run as a separate service (or via cron/deployment scripts), feeding optimized data into the API.

##### What
- Each component should be clearly labeled (e.g., “API Server (app/server)”, “Precomputation Service (app/precompute)”, “Core Route & Geo Logic (src/Ceburilo)”).
- Inbound client requests coming into the API server.
- Data flow from the API server to the core modules.
- Data precomputed by the Precomputation Service feeding into the server logic.
- External configurations and data influencing both layers.
- Interactions among components with brief notes (e.g., “uses configuration”, “generates precomputed data”, “serves JSON response”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Sources Subgraph
    subgraph "External Configuration & Deployment"
        cfg["Config (config/routes)"]:::external
        gph["Graphhopper (graphhopper-config.properties, nextbike-live.xml)"]:::external
        depl["Deployment & Scripts (get_paths.sh, get_stations.sh, precompute.sh, scripts)"]:::deployment
    end

    %% Client Request
    client["Client Request"]:::client

    %% Services Subgraph
    subgraph "Services"
        api["API Server (app/server)"]:::service
        pre["Precomputation Service (app/precompute)"]:::service
    end

    %% Core Business Logic Modules
    core["Core Route & Geo Logic (src/Ceburilo)"]:::module

    %% Data Flow Connections
    client -->|"GET_/route"| api
    api -->|"calls"| core
    pre -->|"feeds_precomputed_data"| core
    cfg -->|"configures"| api
    cfg -->|"configures"| pre
    gph -->|"external_data"| api
    gph -->|"external_data"| pre
    depl -->|"deploys"| api
    depl -->|"deploys"| pre

    %% Click Events
    click api "https://github.com/zyla/ceburilo/blob/master/app/server/Main.hs"
    click pre "https://github.com/zyla/ceburilo/blob/master/app/precompute/Main.hs"
    click core "https://github.com/zyla/ceburilo/tree/master/src/Ceburilo"
    click cfg "https://github.com/zyla/ceburilo/tree/master/config"
    click gph "https://github.com/zyla/ceburilo/tree/master/graphhopper"
    click depl "https://github.com/zyla/ceburilo/tree/master/scripts"

    %% Styles
    classDef client fill:#ffcccb,stroke:#d62728,stroke-width:2px;
    classDef service fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef module fill:#aed6f1,stroke:#2e86c1,stroke-width:2px;
    classDef external fill:#a9dfbf,stroke:#27ae60,stroke-width:2px;
    classDef deployment fill:#f5cba7,stroke:#ca6f1e,stroke-width:2px;
```
