# spyroslon/fitoverlays architecture

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

- Interactive diagram: https://gitdiagram.com/spyroslon/fitoverlays
- Repository: https://github.com/spyroslon/fitoverlays

## Overview

##### Main Components
- Client Side (Frontend):
– Browser-based interface that displays pages such as index.html (and index_backup.html for versioning/fallback).
– Static assets (in the static folder, e.g., images) that are used to design overlays and other UI elements.
- Web Server (Backend):
– server.py: This is the main entry point of the Python-based web server. It handles HTTP requests, routes, and business logic.
– validators.py: Contains helper functions or modules that likely validate user input (e.g., checking the pasted Strava URL).
- Activity/Logging/Cache:
– The activities folder stores JSON files (responses from Strava activities) that could be used as logs, caches, or direct inputs for generating overlays.
- External Integration:
– Although not explicitly shown as separate components/files, the README describes “Instant Strava Integration”. This implies that server.py is responsible for making HTTP requests to Strava’s API/endpoint when a user submits an activity link.

##### Architectural Patterns and Principles
- Separation of Concerns – The client (presentation) is separated from business logic (server.py) and validation logic (validators.py).
- Modular Design – Key functionalities (API integration, overlay generation, input validation) are separated into different files or modules.
- Simplicity and Direct Flow – The system design is straightforward, with a clear linear flow: User input → Validation → External API Integration → Data processing → Overlay generation → Response.

- Component is clearly labeled and that every processing or communication flow (user input, validation, API request, data logging, and response output) is depicted.
- Relevant details noted in the README (e.g., “Optimized for Instagram Stories”, “Multiple Overlay Styles”) by possibly annotating the web server’s overlay generation module or by including a side note.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Side"
        A["User / Browser"]:::frontend
        A1["Index Page"]:::clientDetails
        A2["Backup Index Page"]:::clientDetails
        A3["Static Assets"]:::assets
    end

    subgraph "Backend"
        B["Web Server (server.py)"]:::server
        B1["Input Validation (validators.py)"]:::module
    end

    D["Strava API (External Service)"]:::external
    E["Activity Data / Cache (activities directory)"]:::database

    %% Data Flow
    A -->|"HTTPRequest"| B
    B -->|"Validate"| B1
    B -->|"StravaAPICall"| D
    D -->|"APIResponse"| B
    B -->|"LogActivity"| E
    B -->|"ServesAssets"| A3
    B -->|"HTTPResponse"| A

    %% Internal Client Details
    A1 --> A
    A2 --> A

    %% Styles
    classDef frontend fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef clientDetails fill:#ffeeaa,stroke:#333,stroke-width:2px;
    classDef server fill:#aaddff,stroke:#333,stroke-width:2px;
    classDef module fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef external fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef database fill:#ffe4b5,stroke:#333,stroke-width:2px;
    classDef assets fill:#c4f0c5,stroke:#333,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/spyroslon/fitoverlays/blob/main/index.html"
    click A2 "https://github.com/spyroslon/fitoverlays/blob/main/index_backup.html"
    click A3 "https://github.com/spyroslon/fitoverlays/tree/main/static/images"
    click B "https://github.com/spyroslon/fitoverlays/blob/main/server.py"
    click B1 "https://github.com/spyroslon/fitoverlays/blob/main/validators.py"
    click E "https://github.com/spyroslon/fitoverlays/tree/main/activities/"
```
