# jflamy/owlcms4 architecture

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

- Interactive diagram: https://gitdiagram.com/jflamy/owlcms4
- Repository: https://github.com/jflamy/owlcms4

## Overview

##### System Type and Purpose
This is a complex, full-stack web application specifically designed for managing weightlifting competitions. The system appears to have both local and cloud deployment capabilities, with real-time features for competition management.

##### Main Architectural Components

a) Core Components:
- Frontend Layer (Vaadin-based web interface)
- Backend Services Layer
- Database Layer (supports both H2 and PostgreSQL)
- MQTT Message Broker (for real-time updates)
- Public Results Display System

b) Key Functional Modules:
- Competition Management
- Athlete Registration
- Weighing System
- Scoring System
- Results Display
- Records Management
- Technical Officials Interface

##### User Interface Layer
- Competition Management UI
- Referee Interface
- Public Display Screens
- Technical Controller Interface
- Announcer Interface
- Use Vaadin components symbol

##### Application Layer
- Core Services:
- Competition Service
- Athlete Management
- Scoring Engine
- Timing System
- Records Management
- Support Services:
- Authentication/Authorization
- Event Broadcasting
- Data Export/Import

##### Integration Layer
- MQTT Broker (for real-time updates)
- Public Results API
- External Systems Integration

##### Data Layer
- Primary Database (H2/PostgreSQL)
- File Storage (for documents/templates)
- Cache Layer

##### Interaction Flows

- User input flow through UI to services
- Real-time event broadcasting
- Database operations
- Public results distribution
- Integration points with external systems

##### Technical Details

- Vaadin framework components
- MQTT message paths
- Database connections
- REST endpoints
- WebSocket connections for real-time updates

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef integration fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef realtime fill:#F44336,stroke:#C62828,color:white

    %% User Interface Layer
    subgraph UI
        CompUI["Competition Management UI"]
        RefUI["Referee Interface"]
        TechUI["Technical Controller UI"]
        AnnUI["Announcer Interface"]
        PubDisp["Public Display Screens"]
    end

    %% Application Layer
    subgraph Core
        CompSvc["Competition Service"]
        AthSvc["Athlete Management"]
        ScoreSvc["Scoring Engine"]
        TimeSvc["Timing System"]
        RecSvc["Records Management"]
    end

    %% Support Services
    subgraph Support
        Auth["Authentication"]
        EventBus["Event Broadcasting"]
        DataExp["Data Export/Import"]
    end

    %% Integration Layer
    subgraph Integration
        MQTT["MQTT Broker"]
        PubAPI["Public Results API"]
        ExtInt["External Systems"]
    end

    %% Data Layer
    subgraph Data
        DB[(Database)]
        FileStore[(File Storage)]
        Cache[(Cache Layer)]
    end

    %% Connections
    CompUI --> CompSvc
    RefUI --> ScoreSvc
    TechUI --> CompSvc
    AnnUI --> TimeSvc
    CompSvc --> EventBus
    AthSvc --> DB
    ScoreSvc --> EventBus
    TimeSvc --> EventBus
    RecSvc --> DB
    EventBus --> MQTT
    MQTT --> PubAPI
    PubAPI --> PubDisp
    DB --> Cache
    CompSvc --> FileStore

    %% Click Events
    click CompUI "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/nui/"
    click RefUI "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/nui/referee/"
    click PubDisp "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/displays/scoreboard/"
    click CompSvc "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/fieldofplay/"
    click AthSvc "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/data/athlete/"
    click ScoreSvc "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/data/scoring/"
    click RecSvc "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/data/records/"
    click MQTT "https://github.com/jflamy/owlcms4/blob/dev54/owlcms/src/main/java/app/owlcms/monitors/MQTTMonitor.java"
    click DB "https://github.com/jflamy/owlcms4/tree/dev54/owlcms/src/main/java/app/owlcms/data/jpa/"
    click PubAPI "https://github.com/jflamy/owlcms4/tree/dev54/publicresults/"

    %% Style Applications
    class CompUI,RefUI,TechUI,AnnUI,PubDisp ui
    class CompSvc,AthSvc,ScoreSvc,TimeSvc,RecSvc core
    class DB,FileStore,Cache data
    class MQTT,PubAPI,ExtInt integration
    class EventBus realtime

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        Core_L["Core Services"]:::core
        Data_L["Data Storage"]:::data
        Int_L["Integration"]:::integration
        RT_L["Real-time"]:::realtime
    end
```
