# chan-stephane/map-data-server architecture

> Architecture diagram of the GitHub repository chan-stephane/map-data-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chan-stephane/map-data-server
- Repository: https://github.com/chan-stephane/map-data-server

## Overview

##### Project type and purpose
- This is a backend-only RESTful API microservice (“Map Data Server”) built with Node.js and Express.
- Its sole responsibility is to serve precomputed map data (bus lines, stops, ways, line types) as JSON over HTTP for use by a map editor or other client.

##### File structure
- Top level:
- Dockerfile, docker-compose.yml, .env.example → containerization and configuration
- package.json / package-lock.json → Node dependencies and scripts
- README.md → usage, endpoints, data specifications
- netlify.toml + functions/app.js → optional Netlify Functions deployment
- Directories:
- routes/ → Express route definitions (map.route.js)
- services/ → business logic / data-loading layer (dataloader.service.js)
- utils/ → shared helper functions (helpers.js)
- data/ → static JSON data sources (antananarivo.json, busLines.json, etc.)
- logs/ → placeholder for runtime logs
- images/ → assets used in README only
- Other files:
- swagger.js → OpenAPI documentation setup
- eslint.config.mjs → linting rules

##### README for additional insights
- Lists all public endpoints under /api (lines, stops/:lineName, ways/:lineName, busLines, lineTypes, busStops).
- Describes data origin and JSON schema.
- Shows usage via npm scripts or Docker Compose.
- Exposes Swagger UI at /api-docs for interactive docs.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Client
    client["Client (Map Editor)"]:::external

    %% Deployment Options
    client -->|"HTTP Request"| API_Docker["Docker Container"]:::compute
    client -->|"HTTP Request"| NetlifyFN["API Gateway / Serverless Wrapper"]:::compute

    %% Docker Deployment
    subgraph "Docker Deployment"
        API_Docker
        subgraph "Container"
            %% Configuration Files
            DockerfileNode["Dockerfile"]:::config
            Compose["docker-compose.yml"]:::config
            EnvExample[".env.example"]:::config

            %% Express Service Components
            subgraph "Express Service"
                Env["Environment Variables (.env)"]:::config
                Router["Routing Layer"]:::compute
                Service["Service Layer"]:::compute
                Utils["Utility Helpers"]:::utility
                DataFS["Data Store (data/*.json)"]:::storage
                Swagger["Swagger UI (/api-docs)"]:::docs
            end

            %% Config & Metadata
            subgraph "Config & Metadata"
                pkg["package.json"]:::config
                lock["package-lock.json"]:::config
                eslint["eslint.config.mjs"]:::config
                netlifyToml["netlify.toml"]:::config
                readme["README.md"]:::config
            end

            %% Other Directories
            images["Assets (images/)"]:::utility
            logs["Logs Directory"]:::storage
        end
    end

    %% Netlify Deployment
    subgraph "Netlify Deployment"
        NetlifyFN
        NetlifyFN -->|Invokes| Router
    end

    %% Internal Data Flow - Docker
    API_Docker -->|2. Express Init| Router
    Router -->|3. Route Handler| Service
    Service -->|4. Reads JSON| DataFS
    DataFS -->|5. Returns Data| Service
    Service -->|6. Responds| Router
    Router -->|7. Sends JSON| API_Docker
    API_Docker -->|8. HTTP Response| client

    %% Swagger Flow
    API_Docker -->|Serves Docs| Swagger

    %% Internal Data Flow - Netlify
    NetlifyFN -->|2. Express Init| Router

    %% Click Events
    click NetlifyFN "https://github.com/chan-stephane/map-data-server/blob/main/functions/app.js"
    click DockerfileNode "https://github.com/chan-stephane/map-data-server/tree/main/Dockerfile"
    click Compose "https://github.com/chan-stephane/map-data-server/blob/main/docker-compose.yml"
    click EnvExample "https://github.com/chan-stephane/map-data-server/blob/main/.env.example"
    click Swagger "https://github.com/chan-stephane/map-data-server/blob/main/swagger.js"
    click Router "https://github.com/chan-stephane/map-data-server/blob/main/routes/map.route.js"
    click Service "https://github.com/chan-stephane/map-data-server/blob/main/services/dataloader.service.js"
    click Utils "https://github.com/chan-stephane/map-data-server/blob/main/utils/helpers.js"
    click DataFS "https://github.com/chan-stephane/map-data-server/blob/main/data/antananarivo.json"
    click pkg "https://github.com/chan-stephane/map-data-server/blob/main/package.json"
    click lock "https://github.com/chan-stephane/map-data-server/blob/main/package-lock.json"
    click eslint "https://github.com/chan-stephane/map-data-server/blob/main/eslint.config.mjs"
    click netlifyToml "https://github.com/chan-stephane/map-data-server/blob/main/netlify.toml"
    click readme "https://github.com/chan-stephane/map-data-server/blob/main/README.md"
    click images "https://github.com/chan-stephane/map-data-server/tree/main/images/"
    click logs "https://github.com/chan-stephane/map-data-server/blob/main/logs/.keep"

    %% Styles
    classDef external fill:#D0E6FF,stroke:#0366d6,stroke-width:2px;
    classDef compute fill:#DFF5D8,stroke:#28a745,stroke-width:2px;
    classDef storage fill:#FFF5CC,stroke:#D2A03C,stroke-width:2px;
    classDef docs fill:#FFE5CC,stroke:#FF7F11,stroke-width:2px;
    classDef config fill:#E8D5F9,stroke:#8A2BE2,stroke-width:2px;
    classDef utility fill:#E0F7FA,stroke:#00ACC1,stroke-width:2px;
```
