# jorgepiconjr/lottery-web-app architecture

> Architecture diagram of the GitHub repository jorgepiconjr/lottery-web-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jorgepiconjr/lottery-web-app
- Repository: https://github.com/jorgepiconjr/lottery-web-app

## Overview

##### Project Type & Purpose
- Full-stack web application built with Spring Boot (Java) and Thymeleaf.
- Purpose: Allow users to play number lotteries, bet on Bundesliga matches, and form private betting pools.

##### File Structure
- src/main/java/lottery – the root package.
- Sub-packages as logical modules (using Spring Modulith):
– bet (domain, controllers, services, data initializers)
– event (football & lotto event domain + forms + controllers)
– lottery (Lottery domain & controller)
– pool (pool domain, controller, service)
– user (user registration/login domain, controllers, services)
– welcome (landing-page controller)
- repositories – Spring Data JPA interfaces for persistence.
- src/main/resources/static – CSS, images for the front-end (Thymeleaf).
- src/main/resources/templates – Thymeleaf HTML templates (views).
- pom.xml & mvnw – Maven build, declares dependencies (Spring Web, Spring Data JPA, Thymeleaf, Salespoint framework, etc.).

##### Extract Key Insights from the README
- Confirms use of Spring Boot + Thymeleaf.
- Team-based Scrum project with MVC architecture.
- No mention of external third-party betting-data services, so the system is self-contained.

##### Defining the Main Components & Their Interactions
a. Components:
1. Web Client (Browser)
2. Static Content Server (delivers CSS/JS/images)
3. Spring Boot Application (REST + MVC)
- Presentation Layer: Controllers (BetController, PoolController, UserController, etc.)
- Service Layer: Business logic (BetService, PoolService, UserService, LotteryService)
- Domain Model: Entities (Bet, Event, Pool, User)
- Data Access Layer: Repositories (Spring Data JPA interfaces)
4. Relational Database (e.g., H2/MySQL)
5. (Optional) External Services – none by default

b. Relationships & Data Flow:
- User → HTTP(S) → Controller → Service → Repository → Database
- Controller returns Thymeleaf view + model → Browser renders UI
- Static assets served directly from /static

c. Architectural Patterns & Principles:
- Layered (Presentation → Business → Data)
- Modular Monolith via Spring Modulith (each sub-package is a module)
- MVC for web interactions
- Dependency Injection & Inversion of Control (Spring)
- Repository Pattern (Spring Data JPA)

d. Key Technologies & Frameworks:
- Spring Boot Web, Spring MVC
- Thymeleaf templating engine
- Spring Data JPA + Hibernate
- Salespoint framework modules (accountancy, catalog, etc.)
- Maven for build
- SQL database (H2/MySQL)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    Browser["Web Client\n(Browser)"]:::client
    Static["Static Content\nServer"]:::static
    Template["Thymeleaf Templates"]:::template

    %% Backend Application
    subgraph "Spring Boot Application" 
        direction TB
        Main["Application.java"]:::backend
        Pom["pom.xml"]:::backend

        subgraph "Modules"
            direction TB
            subgraph "bet module"
                BetModule["bet module"]:::module
            end
            subgraph "event module"
                EventModule["event module"]:::module
            end
            subgraph "lottery module"
                LotteryModule["lottery module"]:::module
            end
            subgraph "pool module"
                PoolModule["pool module"]:::module
            end
            subgraph "user module"
                UserModule["user module"]:::module
            end
            subgraph "welcome module"
                WelcomeModule["welcome module"]:::module
            end
        end

        subgraph "Repositories"
            direction TB
            RepoModule["repositories"]:::repo
        end
    end

    DB["Relational Database"]:::db

    %% Data Flow
    Browser -->|"HTTP GET/POST"| Main
    Browser -->|"GET static assets"| Static
    Main -->|"loads templates"| Template
    Main -->|"calls repositories"| RepoModule
    RepoModule -->|"JPA Queries"| DB
    Template -->|"renders HTML"| Browser
    Static -->|"serves CSS/JS/images"| Browser

    %% Click Events
    click Main "https://github.com/jorgepiconjr/lottery-web-app/blob/main/src/main/java/lottery/Application.java"
    click Pom "https://github.com/jorgepiconjr/lottery-web-app/blob/main/pom.xml"
    click BetModule "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/java/lottery/bet"
    click EventModule "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/java/lottery/event"
    click LotteryModule "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/java/lottery/lottery"
    click PoolModule "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/java/lottery/pool"
    click UserModule "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/java/lottery/user"
    click WelcomeModule "https://github.com/jorgepiconjr/lottery-web-app/blob/main/src/main/java/lottery/welcome/WelcomeController.java"
    click RepoModule "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/java/lottery/repositories"
    click Static "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/resources/static"
    click Template "https://github.com/jorgepiconjr/lottery-web-app/tree/main/src/main/resources/templates"

    %% Styles
    classDef client fill:#CCF,stroke:#333,stroke-width:1px
    classDef static fill:#CFC,stroke:#333,stroke-width:1px
    classDef template fill:#CFF,stroke:#333,stroke-width:1px
    classDef backend fill:#FCF,stroke:#333,stroke-width:1px
    classDef module fill:#EEF,stroke:#333,stroke-width:1px
    classDef repo fill:#FEE,stroke:#333,stroke-width:1px
    classDef db fill:#FCE,stroke:#333,stroke-width:1px
```
