# informatica92/match-table-system architecture

> Architecture diagram of the GitHub repository informatica92/match-table-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/informatica92/match-table-system
- Repository: https://github.com/informatica92/match-table-system

## Overview

##### Project Type & Purpose
- This is a single-page, full-stack Streamlit web application (“MATCH Table System”) that lets authenticated users create, view, join, edit, and delete board-game table reservations.
- It integrates with a PostgreSQL database for persistence, Auth0 for authentication, the BoardGameGeek (BGG) API for game metadata, the Telegram Bot API for notifications, and optionally Google Maps.

##### File Structure Analysis
- Top-level driver: `board_game_manager.py` (boots the Streamlit app and wires in pages).
- `app_pages/`: each file is a self-contained Streamlit page (View/Join modes, Create, Map, User, Login, etc.).
- `utils/`: service-layer modules:
- `sql_manager.py` (all DB operations)
- `bgg_manager.py` (BGG API calls)
- `telegram_notifications.py` (Telegram Bot integration)
- `altair_manager.py` (chart/timeline generation)
- UI helpers in `streamlit_utils.py`
- Table-specific data wrappers in `table_system_*`.
- `static/`: images, GDPR/legal docs, history CSV.
- Config files: `.streamlit/config.toml`, DevContainer settings, `requirements.txt`.
- README outlines the environment variables (DB, Telegram, Auth0, Google Maps, general settings).

##### Key Components
a. Frontend (Client)
- User’s Web Browser
- Streamlit UI (pages in `app_pages/`)
b. Backend (Server/Container)
- Streamlit Application (Python process)
- Page Router (`board_game_manager.py`)
- Service Layer (`utils/` modules)
c. Data Store
- PostgreSQL Database (schemas for users, propositions, logs, etc.)
d. External Services
- Auth0 (OIDC provider)
- BoardGameGeek API
- Telegram Bot API
- Google Maps (optional embedded map via URL)

##### Relationships & Data Flows
1. User → Browser → Streamlit UI (HTTP/WebSocket)
2. Streamlit UI → Auth0 (redirect + token exchange) → UI (user context)
3. Streamlit UI → `sql_manager` → PostgreSQL (CRUD for users, tables, joins, locations)
4. Streamlit UI → `bgg_manager` → BGG API (fetch game metadata: images, categories, mechanics)
5. Streamlit UI → `telegram_notifications` → Telegram Bot API (post new-table notifications)
6. Streamlit UI → `altair_manager` → Generates timeline/list charts → UI
7. Streamlit UI → Google Maps embed (if `GMAP_MAP_URL` set)

##### Architectural Patterns & Principles
- Container/Modular monolith: UI pages (presentation layer) orchestrate calls to a clean service layer.
- Separation of concerns:
- Presentation → `app_pages/`
- Business logic → `utils/`
- Persistence → `sql_manager.py`
- External integration → dedicated modules (`bgg_manager.py`, `telegram_notifications.py`)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    subgraph "Frontend (Client)"
        direction TB
        Browser["User’s Web Browser"]:::ui
        subgraph "Streamlit UI Pages"
            direction TB
            P1["1_View_&_Join_Base"]:::ui
            P2["1_View_&_Join_Default"]:::ui
            P3["1_View_&_Join_Demos"]:::ui
            P4["1_View_&_Join_RoW"]:::ui
            P5["1_View_&_Join_Tournaments"]:::ui
            P6["2_Create"]:::ui
            P7["3_Map"]:::ui
            P8["4_User"]:::ui
            P9["98_Banned_User"]:::ui
            P10["99_Login"]:::ui
        end
    end

    %% Backend
    subgraph "Backend (Streamlit App)" 
        direction TB
        Router["Page Router"]:::server
        subgraph "Service Layer"
            direction TB
            SQL["sql_manager.py"]:::server
            BGG["bgg_manager.py"]:::server
            TN["telegram_notifications.py"]:::server
            ALT["altair_manager.py"]:::server
            UIH["streamlit_utils.py"]:::server
            LOG["table_system_logging.py"]:::server
            PROP["table_system_proposition.py"]:::server
            USR["table_system_user.py"]:::server
        end
    end

    %% Data Store
    subgraph "Data Store"
        direction TB
        DB["PostgreSQL Database"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Auth0["Auth0 (OIDC)"]:::external
        BGGAPI["BoardGameGeek API"]:::external
        TelegramAPI["Telegram Bot API"]:::external
        GoogleMaps["Google Maps Embed"]:::external
    end

    %% Assets & Config
    static["static/"]:::server
    config[".streamlit/config.toml"]:::server
    reqs["requirements.txt"]:::server

    %% Relationships
    Browser -->|"HTTP/WebSocket"| P1
    Browser --> P2
    Browser --> P3
    Browser --> P4
    Browser --> P5
    Browser --> P6
    Browser --> P7
    Browser --> P8
    Browser --> P9
    Browser --> P10

    P* -->|"Route Request"| Router
    Router -->|"Invoke Services"| SQL
    Router -->|"Invoke Services"| BGG
    Router -->|"Invoke Services"| TN
    Router -->|"Invoke Services"| ALT
    Router -->|"Invoke Helpers"| UIH
    Router -->|"Wrap Data"| LOG
    Router -->|"Wrap Data"| PROP
    Router -->|"Wrap Data"| USR

    SQL -->|"SQL Queries"| DB
    BGG -->|"HTTP Request"| BGGAPI
    TN -->|"Send Message"| TelegramAPI
    ALT -->|"Generate Charts"| Router
    P7 -->|"Embed URL"| GoogleMaps
    P* -->|"Authenticate via OIDC"| Auth0

    %% Click Events
    click Router "https://github.com/informatica92/match-table-system/blob/main/board_game_manager.py"
    click P1 "https://github.com/informatica92/match-table-system/blob/main/app_pages/1_View_&_Join_Base.py"
    click P2 "https://github.com/informatica92/match-table-system/blob/main/app_pages/1_View_&_Join_Default.py"
    click P3 "https://github.com/informatica92/match-table-system/blob/main/app_pages/1_View_&_Join_Demos.py"
    click P4 "https://github.com/informatica92/match-table-system/blob/main/app_pages/1_View_&_Join_RoW.py"
    click P5 "https://github.com/informatica92/match-table-system/blob/main/app_pages/1_View_&_Join_Tournaments.py"
    click P6 "https://github.com/informatica92/match-table-system/blob/main/app_pages/2_Create.py"
    click P7 "https://github.com/informatica92/match-table-system/blob/main/app_pages/3_Map.py"
    click P8 "https://github.com/informatica92/match-table-system/blob/main/app_pages/4_User.py"
    click P9 "https://github.com/informatica92/match-table-system/blob/main/app_pages/98_Banned_User.py"
    click P10 "https://github.com/informatica92/match-table-system/blob/main/app_pages/99_Login.py"
    click SQL "https://github.com/informatica92/match-table-system/blob/main/utils/sql_manager.py"
    click BGG "https://github.com/informatica92/match-table-system/blob/main/utils/bgg_manager.py"
    click TN "https://github.com/informatica92/match-table-system/blob/main/utils/telegram_notifications.py"
    click ALT "https://github.com/informatica92/match-table-system/blob/main/utils/altair_manager.py"
    click UIH "https://github.com/informatica92/match-table-system/blob/main/utils/streamlit_utils.py"
    click LOG "https://github.com/informatica92/match-table-system/blob/main/utils/table_system_logging.py"
    click PROP "https://github.com/informatica92/match-table-system/blob/main/utils/table_system_proposition.py"
    click USR "https://github.com/informatica92/match-table-system/blob/main/utils/table_system_user.py"
    click static "https://github.com/informatica92/match-table-system/tree/main/static/"
    click config "https://github.com/informatica92/match-table-system/blob/main/.streamlit/config.toml"
    click reqs "https://github.com/informatica92/match-table-system/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef server fill:#D0FFD0,stroke:#333,stroke-width:1px
    classDef db fill:#FFDDA0,stroke:#333,stroke-width:1px
    classDef external fill:#E0D0FF,stroke:#333,stroke-width:1px
```
