# tasera-ry/tss architecture

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

- Interactive diagram: https://gitdiagram.com/tasera-ry/tss
- Repository: https://github.com/tasera-ry/tss

## Overview

##### Project Type Analysis
This is a full-stack web application for managing shooting range schedules and supervision, with distinct frontend and backend components, using Node.js and PostgreSQL.

##### Main Components

A. Client Layer:
- React Frontend (port 3000)
- Key modules:
- User Management
- Scheduling Interface
- Track Management
- Statistics Views
- Tablet View for Range Officers

B. Server Layer:
- Node.js Backend (port 8000)
- Express.js API
- JWT Authentication
- Email Service

C. Database Layer:
- PostgreSQL Database
- Key entities:
- Users/Supervisors
- Ranges/Tracks
- Reservations
- Supervisions
- Devices

**[Client Layer]**

- Web Browser
- React Frontend Components
- Authentication Views
- Scheduling Views
- Management Interfaces
- Statistics/Reporting
- API Services

**[Server Layer]**

- Express.js Backend
- Routes
- Controllers
- Services
- Models
- Validators

- Middleware
- JWT Authentication
- Request Validation
- Error Handling

- External Services
- Email Service

**[Data Layer]**

- PostgreSQL Database
- User Management Tables
- Range/Track Tables
- Supervision Tables
- Device Management Tables

##### Key Relationships to Highlight

- Client-Server Communication:
- REST API calls
- WebSocket connections (if implemented)
- Authentication flow

- Server-Database Interaction:
- Knex.js query builder
- Migration paths
- Data relationships

- External Service Integration:
- Email service connection
- Any third-party APIs

##### Documentation Elements

- Version information
- Environment variables and configuration points
- Document main data flows
- API endpoints grouping

Remember to use standardized UML or C4 model notation where appropriate, and consider creating separate detailed views for complex subsystems like the scheduling engine or supervision management.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        
        subgraph Frontend
            AuthViews["Authentication Views"]:::frontend
            SchedViews["Scheduling Views"]:::frontend
            ManageViews["Management Interfaces"]:::frontend
            StatsViews["Statistics/Reporting"]:::frontend
            TabletView["Tablet View"]:::frontend
            DeviceView["Device Management"]:::frontend
            PassReset["Password Reset"]:::frontend
        end
        
        subgraph APIServices
            APIClient["API Services"]:::service
        end
    end

    subgraph Server
        Express["Express.js Backend"]:::backend
        
        subgraph Middleware
            JWT["JWT Authentication"]:::security
            ReqValid["Request Validation"]:::security
            ErrorHandle["Error Handling"]:::security
        end
        
        subgraph CoreServices
            Controllers["API Controllers"]:::service
            Services["Backend Services"]:::service
            Models["Data Models"]:::service
            Routes["API Routes"]:::service
            Validators["Request Validators"]:::service
            EmailSvc["Email Service"]:::service
            TrackSup["Track Supervision"]:::service
            RangeSup["Range Supervision"]:::service
        end
    end

    subgraph Database
        PostgreSQL[(PostgreSQL DB)]:::database
        
        subgraph Tables
            UserTables[("User Tables")]:::database
            RangeTables[("Range Tables")]:::database
            SupervisionTables[("Supervision Tables")]:::database
            DeviceTables[("Device Tables")]:::database
        end
        
        Migrations["Database Migrations"]:::database
    end

    Browser --> Frontend
    Frontend --> APIServices
    APIServices --> Express
    Express --> Middleware
    Middleware --> CoreServices
    CoreServices --> PostgreSQL
    
    %% Click Events
    click AuthViews "https://github.com/tasera-ry/tss/blob/master/front/src/signin/SignIn.js"
    click SchedViews "https://github.com/tasera-ry/tss/blob/master/front/src/scheduling/Scheduling.js"
    click ManageViews "https://github.com/tasera-ry/tss/blob/master/front/src/edittracks/tracks.js"
    click StatsViews "https://github.com/tasera-ry/tss/blob/master/front/src/statistics/Statistics.js"
    click TabletView "https://github.com/tasera-ry/tss/blob/master/front/src/tabletview/rangeofficer.js"
    click DeviceView "https://github.com/tasera-ry/tss/blob/master/front/src/Devices/devices.js"
    click PassReset "https://github.com/tasera-ry/tss/blob/master/front/src/resetPW/ResetPassword.js"
    click Express "https://github.com/tasera-ry/tss/blob/master/back/app.js"
    click JWT "https://github.com/tasera-ry/tss/blob/master/back/middlewares/jwt.js"
    click Controllers "https://github.com/tasera-ry/tss/tree/master/back/controllers/"
    click Services "https://github.com/tasera-ry/tss/tree/master/back/services/"
    click Models "https://github.com/tasera-ry/tss/tree/master/back/models/"
    click Validators "https://github.com/tasera-ry/tss/tree/master/back/validators/"
    click EmailSvc "https://github.com/tasera-ry/tss/blob/master/back/mailer.js"
    click Migrations "https://github.com/tasera-ry/tss/tree/master/back/knex/development/migrations/"
    click Routes "https://github.com/tasera-ry/tss/blob/master/back/routes.js"
    click TrackSup "https://github.com/tasera-ry/tss/blob/master/back/controllers/trackSupervision.js"
    click RangeSup "https://github.com/tasera-ry/tss/blob/master/back/controllers/rangeSupervision.js"

    %% Styling
    classDef frontend fill:#2374ab
    classDef backend fill:#48a9a6
    classDef service fill:#4ea5d9
    classDef security fill:#b4436c
    classDef database fill:#f58549
```
