# drehelis/sammy_ofer architecture

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

- Interactive diagram: https://gitdiagram.com/drehelis/sammy_ofer
- Repository: https://github.com/drehelis/sammy_ofer

## Overview

##### Main Components

a) Web Scraping Layer
- Web scraper component (web_scrape.py)
- Connection to the external Sammy Ofer Stadium website

b) Scheduling System
- Cron scheduler (cron.py)
- How it triggers the web scraping process

c) Data Storage
- Currently using dictionary storage (as mentioned in TODO about future SQLite implementation)
- As a temporary data store

d) Notification System
- Telegram Bot integration
- Connection to Telegram API

e) Web Interface
- Flask web server (web.py)
- Static page generator (static_html_page.py)
- Template rendering system (using Jinja2)

**[External Sources]**
- ↓
**[Web Scraper]**
- ↓
**[Scheduler] ←→ [Data Store]**
- ↓
**[Core Logic]**
- ↓
**[Output Layer]**
- ↙     ↘
**[Telegram]  [Web UI]**

##### Important Relationships

- Scheduler triggering the web scraper
- Web scraper updating the data store
- Core logic reading from data store
- Template system feeding into both web UI and static page generation
- Notification system pushing to Telegram

##### Technical Details

- Flask web server on port 5000
- Jinja2 templating system
- Cron-based scheduling
- Docker containerization
- GitHub Actions CI/CD pipeline

**[Configuration]**
- Environment Variables
- Docker Settings
- Development Container

**[Core Application]**
- Web Scraper
- Scheduler
- Data Management

**[Output Interfaces]**
- Web UI (Flask)
- Static Page
- Telegram Bot

**[Infrastructure]**
- Docker Container
- GitHub Actions
- GitHub Pages

This architecture should be represented in a way that highlights both the simplicity of the core functionality (web scraping and notifications) and the professional implementation details (containerization, CI/CD, multiple output formats).

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External["External Services"]
        Stadium["Sammy Ofer Stadium Website"]:::external
        TelegramAPI["Telegram API"]:::external
    end

    subgraph Core["Core Application"]
        WebScraper["Web Scraper"]:::core
        click WebScraper "https://github.com/drehelis/sammy_ofer/blob/master/web_scrape.py"
        
        Scheduler["Scheduler"]:::core
        click Scheduler "https://github.com/drehelis/sammy_ofer/blob/master/cron.py"
        
        DataStore[("Data Store")]:::storage
        
        LogSystem["Logging System"]:::support
        click LogSystem "https://github.com/drehelis/sammy_ofer/blob/master/logger.py"
        
        MetaHandler["Metadata Handler"]:::support
        click MetaHandler "https://github.com/drehelis/sammy_ofer/blob/master/metadata.py"
        
        StadiumData["Stadium Data Handler"]:::support
        click StadiumData "https://github.com/drehelis/sammy_ofer/blob/master/spectators.py"
    end

    subgraph Output["Output Layer"]
        subgraph WebInterface["Web Interface"]
            FlaskServer["Flask Server"]:::web
            click FlaskServer "https://github.com/drehelis/sammy_ofer/blob/master/web.py"
            
            StaticGen["Static Page Generator"]:::web
            click StaticGen "https://github.com/drehelis/sammy_ofer/blob/master/static_html_page.py"
            
            Templates["Template System"]:::web
            click Templates "https://github.com/drehelis/sammy_ofer/tree/master/assets/templates"
            
            JinjaFilters["Template Filters"]:::web
            click JinjaFilters "https://github.com/drehelis/sammy_ofer/blob/master/jinja_filters.py"
        end

        TelegramBot["Telegram Bot"]:::output
    end

    subgraph Infrastructure["Infrastructure"]
        Docker["Docker Container"]:::infra
        click Docker "https://github.com/drehelis/sammy_ofer/tree/master/Dockerfile"
        
        DevEnv["Development Environment"]:::infra
        click DevEnv "https://github.com/drehelis/sammy_ofer/blob/master/.devcontainer"
        
        CICD["GitHub Actions"]:::infra
        click CICD "https://github.com/drehelis/sammy_ofer/blob/master/.github/workflows/python-app.yml"
        
        Assets["Static Assets"]:::infra
        click Assets "https://github.com/drehelis/sammy_ofer/tree/master/assets"
    end

    %% Relationships
    Stadium --> WebScraper
    WebScraper --> DataStore
    Scheduler --> WebScraper
    DataStore --> FlaskServer
    DataStore --> StaticGen
    DataStore --> TelegramBot
    Templates --> StaticGen
    Templates --> FlaskServer
    TelegramBot --> TelegramAPI
    JinjaFilters --> Templates
    LogSystem --> WebScraper
    MetaHandler --> WebScraper
    StadiumData --> WebScraper

    %% Styles
    classDef external fill:#1E88E5,color:white
    classDef core fill:#4CAF50,color:white
    classDef storage fill:#FFC107,color:black
    classDef web fill:#9C27B0,color:white
    classDef output fill:#673AB7,color:white
    classDef support fill:#90A4AE,color:white
    classDef infra fill:#607D8B,color:white

    %% Legend
    subgraph Legend
        ExtLegend["External Services"]:::external
        CoreLegend["Core Components"]:::core
        StorageLegend["Data Storage"]:::storage
        WebLegend["Web Components"]:::web
        OutputLegend["Output Systems"]:::output
        SupportLegend["Support Systems"]:::support
        InfraLegend["Infrastructure"]:::infra
    end
```
