# skorentis/softeng19-20 architecture

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

- Interactive diagram: https://gitdiagram.com/skorentis/softeng19-20
- Repository: https://github.com/skorentis/softeng19-20

## Overview

##### Main Components

A. Frontend Layer (Angular):
- Core Module Components:
- Authentication Module
- Users Module
- Home Module
- Payments Module
- Insert Data Module
- Shared Components:
- Header
- Error Handling
- Guards
- Interceptors

B. Backend Layer (Node.js):
- API Routes
- Middleware Layer
- Models Layer
- Database Connection
- Authentication System
- SSL Certificate Handler

C. Database Layer:
- MongoDB (indicated by mongoose.js)
- Data Models for:
- Users
- ActualTotalLoad
- AggregatedGeneration
- DayAheadForecast
- Various Reference Data

D. CLI Client:
- Command Line Interface Tool

- ┌─────────────────┐
- Frontend Zone  │
- ┬────────┘
- ↕ HTTPS
- ┌────────┴────────┐
- Backend Zone   │
- ┬────────┘
- ↕
- ┌────────┴────────┐
- Database Zone  │
- ┘

##### Detailed Component Representation

Frontend (Angular):
**┌─ Angular Application ─────────────────┐**
- ┌─────────┐ ┌─────────┐ ┌─────────┐  │
- Auth   │ │  Home   │ │ Payment │  │
- ┘ └─────────┘ └─────────┘  │
- ┌─────────┐ ┌─────────┐ ┌─────────┐  │
- Users  │ │ Insert  │ │ Shared  │  │
- ┘ └─────────┘ └─────────┘  │
- ┬──────────────────┘
- ↓

Backend (Node.js):
**┌─ Node.js API ──────────────────────┐**
- ┌─────────┐ ┌─────────┐            │
- Routes  │ │ Models  │            │
- ┘ └─────────┘            │
- ┌─────────┐ ┌─────────┐            │
- Middleware│ │ Config  │            │
- ┘ └─────────┘            │
- ┬─────────────────┘
- ↓

##### Important Elements to Highlight

- Security Layer:
- SSL/TLS encryption (shown by sslcert folder)
- Authentication middleware
- Authorization guards
- Request interceptors

- Data Flow:
- User authentication flow
- API request/response cycle
- Data import/export processes
- Payment processing flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef cli fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        Angular["Angular Application"]
        AuthMod["Authentication Module"]
        UsersMod["Users Module"]
        HomeMod["Home Module"]
        PayMod["Payments Module"]
        InsertMod["Insert Data Module"]
        Header["Header Component"]
        ErrorHandler["Error Handler"]
        
        Angular --> AuthMod
        Angular --> UsersMod
        Angular --> HomeMod
        Angular --> PayMod
        Angular --> InsertMod
        Angular --> Header
        Angular --> ErrorHandler
    end

    %% Backend Layer
    subgraph Backend
        NodeAPI["Node.js API"]
        Routes["API Routes"]
        Middleware["Middleware Layer"]
        Models["Models Layer"]
        DBConn["Database Connection"]
        AuthSystem["Authentication System"]
        SSL["SSL Certificate Handler"]
        
        NodeAPI --> Routes
        NodeAPI --> Middleware
        NodeAPI --> Models
        NodeAPI --> DBConn
        NodeAPI --> AuthSystem
        NodeAPI --> SSL
    end

    %% Database Layer
    subgraph Database
        MongoDB[(MongoDB)]
        UserModel["User Model"]
        ATLModel["ActualTotalLoad Model"]
        AGModel["AggregatedGeneration Model"]
        DAFModel["DayAheadForecast Model"]
        
        MongoDB --> UserModel
        MongoDB --> ATLModel
        MongoDB --> AGModel
        MongoDB --> DAFModel
    end

    %% CLI Client
    CLI["CLI Client"]

    %% Connections between layers
    Frontend <--> Backend
    Backend <--> Database
    CLI --> Backend

    %% Click events for component mapping
    click AuthMod "https://github.com/skorentis/softeng19-20/tree/master/front-end/src/app/auth"
    click UsersMod "https://github.com/skorentis/softeng19-20/tree/master/front-end/src/app/users"
    click HomeMod "https://github.com/skorentis/softeng19-20/tree/master/front-end/src/app/home"
    click PayMod "https://github.com/skorentis/softeng19-20/tree/master/front-end/src/app/payments"
    click InsertMod "https://github.com/skorentis/softeng19-20/tree/master/front-end/src/app/insert-data"
    click Header "https://github.com/skorentis/softeng19-20/tree/master/front-end/src/app/header"
    click ErrorHandler "https://github.com/skorentis/softeng19-20/tree/master/front-end/src/app/http-error"
    click Routes "https://github.com/skorentis/softeng19-20/tree/master/back-end/routes"
    click Middleware "https://github.com/skorentis/softeng19-20/tree/master/back-end/middleware"
    click Models "https://github.com/skorentis/softeng19-20/tree/master/back-end/models"
    click DBConn "https://github.com/skorentis/softeng19-20/blob/master/back-end/db/mongoose.js"
    click AuthSystem "https://github.com/skorentis/softeng19-20/blob/master/back-end/middleware/authenticate.js"
    click SSL "https://github.com/skorentis/softeng19-20/tree/master/back-end/sslcert"
    click UserModel "https://github.com/skorentis/softeng19-20/blob/master/back-end/models/User.js"
    click ATLModel "https://github.com/skorentis/softeng19-20/blob/master/back-end/models/ActualTotalLoad.js"
    click AGModel "https://github.com/skorentis/softeng19-20/blob/master/back-end/models/AggregatedGenerationPerType.js"
    click DAFModel "https://github.com/skorentis/softeng19-20/blob/master/back-end/models/DayAheadTotalLoadForecast.js"
    click CLI "https://github.com/skorentis/softeng19-20/tree/master/cli-client/energy_group68"

    %% Apply styles
    class AuthMod,UsersMod,HomeMod,PayMod,InsertMod,Header,ErrorHandler frontend
    class Routes,Middleware,Models,DBConn,NodeAPI backend
    class MongoDB,UserModel,ATLModel,AGModel,DAFModel database
    class AuthSystem,SSL security
    class CLI cli
```
