# city-of-vantaa-smartlab/mobiilinutakortti architecture

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

- Interactive diagram: https://gitdiagram.com/city-of-vantaa-smartlab/mobiilinutakortti
- Repository: https://github.com/city-of-vantaa-smartlab/mobiilinutakortti

## Overview

##### Main Components

a. Client Layer:
- Frontend (React, Port 3001) - Youth user interface
- Admin Frontend (React Admin, Port 3002) - Youth worker interface

b. API Layer:
- Backend (NestJS, Port 3000)
- API endpoints categorization:
- Authentication endpoints
- Youth management endpoints
- Club management endpoints
- QR code handling endpoints
- Extra entries endpoints

c. External Services:
- Telia SMS Service
- Amazon Email Service
- Microsoft Entra ID (optional authentication)
- Suomi.fi identification

d. Database Layer:
- PostgreSQL (Port 5432)
- Key entities to highlight:
- Juniors (youth)
- Youth Workers
- Clubs
- Check-ins
- Extra Entries
- Announcements

##### Component Relationships

- Frontend → Backend (REST API calls)
- Admin Frontend → Backend (REST API calls)
- Backend → External Services (SMS, Email, Authentication)
- Backend → Database (Data persistence)

##### Additional Elements

A section showing:
- Environment configurations
- Port mappings
- Docker container boundaries
- Key security boundaries

##### Notes Section

Notes about:
- Scalability considerations
- Security implementations
- External service dependencies
- Environment-specific configurations

Remember to emphasize the security aspects, especially around the QR code system and youth worker authentication, as these are critical features of the application.

This system design should help developers understand both the overall architecture and the specific implementation details needed for maintenance and further development.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        YF["Youth Frontend\n(React :3001)"]
        QR["QR Code System"]
        Login["Login System"]
        ParentReg["Parent Registration"]
        
        AF["Admin Frontend\n(React Admin :3002)"]
        CheckIn["Check-in Management"]
        YWInterface["Youth Worker Interface"]
        ClubMgmt["Club Management"]
    end

    %% Backend Layer
    subgraph Backend
        API["NestJS Backend\n(:3000)"]
        Auth["Authentication"]
        YouthMgmt["Youth Management"]
        ClubAPI["Club Management"]
        ExtraEnt["Extra Entries"]
        Announce["Announcements"]
        SMS["SMS Service"]
        Email["Email Service"]
        SSO["Microsoft Entra ID"]
        SuomiAuth["Suomi.fi Auth"]
    end

    %% External Services
    subgraph External
        TeliaS["Telia SMS"]
        AmazonS["Amazon Email"]
        MSEntra["Microsoft Entra ID"]
        SuomiFi["Suomi.fi"]
    end

    %% Database Layer
    subgraph Database
        DB[(PostgreSQL :5432)]
        JuniorE[("Junior Entity")]
        YWE[("Youth Worker Entity")]
        ClubE[("Club Entity")]
        CheckInE[("Check-in Entity")]
        ExtraE[("Extra Entry Entity")]
    end

    %% Relationships
    YF --> API
    AF --> API
    API --> DB
    SMS --> TeliaS
    Email --> AmazonS
    SSO --> MSEntra
    SuomiAuth --> SuomiFi

    %% Database Relationships
    DB --> JuniorE
    DB --> YWE
    DB --> ClubE
    DB --> CheckInE
    DB --> ExtraE

    %% Click Events
    click YF "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/frontend/src/"
    click QR "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/frontend/src/components/QR/"
    click Login "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/frontend/src/components/loginPage/"
    click ParentReg "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/frontend/src/components/ParentRegistration/"
    click AF "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/admin-frontend/src/"
    click CheckIn "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/admin-frontend/src/components/checkIn/"
    click YWInterface "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/blob/master/admin-frontend/src/components/youthWorker.js"
    click ClubMgmt "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/blob/master/admin-frontend/src/components/youthClub.js"
    click Auth "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/authentication/"
    click YouthMgmt "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/junior/"
    click ClubAPI "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/club/"
    click ExtraEnt "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/extraEntry/"
    click Announce "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/announcement/"
    click SMS "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/sms/"
    click Email "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/email/"
    click SSO "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/sso/"
    click SuomiAuth "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/tree/master/backend/src/authentication/"
    click JuniorE "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/blob/master/backend/src/junior/entities/junior.entity.ts"
    click YWE "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/blob/master/backend/src/youthWorker/entities/youthWorker.entity.ts"
    click ClubE "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/blob/master/backend/src/club/entities/club.entity.ts"
    click CheckInE "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/blob/master/backend/src/club/entities/checkin.entity.ts"
    click ExtraE "https://github.com/City-of-Vantaa-SmartLab/Mobiilinutakortti/blob/master/backend/src/extraEntry/entities/extraEntry.entity.ts"

    %% Style Applications
    class YF,AF,QR,Login,ParentReg,CheckIn,YWInterface,ClubMgmt frontend
    class API,Auth,YouthMgmt,ClubAPI,ExtraEnt,Announce,SMS,Email,SSO,SuomiAuth backend
    class DB,JuniorE,YWE,ClubE,CheckInE,ExtraE database
    class TeliaS,AmazonS,MSEntra,SuomiFi external
    class Auth,SSO,SuomiAuth security
```
