# erikveenhuis/ideal-octo-computing-machine architecture

> Architecture diagram of the GitHub repository erikveenhuis/ideal-octo-computing-machine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erikveenhuis/ideal-octo-computing-machine
- Repository: https://github.com/erikveenhuis/ideal-octo-computing-machine

## Overview

##### Project type and purpose
- This is a full-stack web application built with Flask (Python) on the backend and standard HTML/CSS/JavaScript (with Tailwind) on the frontend.

##### File structure
- Top-level entrypoint: app.py (Flask app), config.py, error_handlers.py, exceptions.py, utils.py
- services/: business-logic layer that encapsulates all external API calls and processing:
- sporthive_service.py
- uitslagen_service.py
- gpx_processing_service.py
- image_transform_service.py
- deployment_service.py
- templates/: Jinja2 templates for page layouts and components
- static/: CSS (Tailwind), JavaScript components (map manager, export utilities, theme manager, etc.)
- scripts/: CI/tooling (quality checks)
- Config files: requirements.txt, requirements-dev.txt, .pylintrc, GitHub workflows, etc.

##### README for additional insights
- No database: data is retrieved in real time from external APIs.
- Frontend uses CartoDB/OSM tiles for maps.
- The app runs on Flask’s development server (production requires WSGI).
- Code-quality enforced via Pylint and GitHub Actions.

##### Main components & their relationships
a. Browser (Client)
- Loads HTML templates + static assets (CSS/JS).
- Initiates HTTP requests to Flask endpoints (e.g. search, upload GPX, image transform).
b. Flask Web Server
- app.py: route definitions, request parsing, response rendering.
- error_handlers.py & exceptions.py: global error management.
- utils.py & config.py: shared utilities and configuration.
c. Service Layer (services/*.py)
- sporthive_service: calls Sporthive API.
- uitslagen_service: scrapes or calls uitslagen.nl.
- gpx_processing_service: parses GPX, extracts coords, city data (via OSM).
- image_transform_service: applies user requests (e.g. cropping, resizing).
- deployment_service: (optional) Deployment orchestration.
d. External Services
- Sporthive REST API (country=NL).
- Uitslagen.nl endpoints.
- OpenStreetMap/CartoDB tile server (for map background).

##### Architectural patterns & design principles
- MVC-style separation:
- Controller: Flask routes in app.py
- View: Jinja2 templates + JS components
- Model/Service: Python “services” modules for business logic
- Single-page-style JS components handling dynamic map, exports, validation.
- Domain-specific services isolate external‐API specifics.
- Config/exception-handling centralized for reusability.
- No persistent database — stateless API proxies and in-memory GPX processing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Browser UI"
        direction TB
        Templates["HTML Templates"]:::frontend
        CSS["CSS (Tailwind)"]:::frontend
        JS["JavaScript Components"]:::frontend
    end

    %% Backend Layer
    subgraph "Flask App"
        direction TB
        Routes["Route Definitions (app.py)"]:::backend
        Config["Configuration (config.py)"]:::backend
        ErrorHandlers["Error Handlers (error_handlers.py)"]:::backend
        Exceptions["Exceptions (exceptions.py)"]:::backend
        Utils["Utilities (utils.py)"]:::backend
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        Sporthive["Sporthive Service"]:::service
        Uitslagen["Uitslagen Service"]:::service
        GPX["GPX Processing Service"]:::service
        ImageTransform["Image Transform Service"]:::service
        Deployment["Deployment Service"]:::service
    end

    %% External Dependencies
    subgraph "External APIs"
        direction TB
        SporthiveAPI["Sporthive REST API"]:::external
        UitslagenAPI["Uitslagen.nl Endpoints"]:::external
        OSM["OSM/CartoDB Tile Server"]:::external
    end

    %% Connections
    Templates -->|loads assets & templates| Routes
    CSS -->|loads styles| Routes
    JS -->|calls endpoints| Routes

    Routes -->|"calls service functions"| Sporthive
    Routes -->|"calls service functions"| Uitslagen
    Routes -->|"calls service functions"| GPX
    Routes -->|"calls service functions"| ImageTransform
    Routes -->|"calls deployment ops"| Deployment

    Sporthive -->|"HTTP JSON"| SporthiveAPI
    Uitslagen -->|"HTTP Scrape/JSON"| UitslagenAPI
    GPX -->|"fetch map data"| OSM
    ImageTransform -.->|"process image"| Routes

    %% Click Events
    click Templates "https://github.com/erikveenhuis/ideal-octo-computing-machine/tree/main/templates/"
    click CSS "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/static/css/main.css"
    click JS "https://github.com/erikveenhuis/ideal-octo-computing-machine/tree/main/static/js/components/"
    click Routes "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/app.py"
    click Config "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/config.py"
    click ErrorHandlers "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/error_handlers.py"
    click Exceptions "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/exceptions.py"
    click Utils "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/utils.py"
    click Sporthive "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/services/sporthive_service.py"
    click Uitslagen "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/services/uitslagen_service.py"
    click GPX "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/services/gpx_processing_service.py"
    click ImageTransform "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/services/image_transform_service.py"
    click Deployment "https://github.com/erikveenhuis/ideal-octo-computing-machine/blob/main/services/deployment_service.py"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0288D1,stroke-width:1px
    classDef backend fill:#C8E6C9,stroke:#388E3C,stroke-width:1px
    classDef service fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#757575,stroke-width:1px
```
