# mti-2023-tala/studasso architecture

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

- Interactive diagram: https://gitdiagram.com/mti-2023-tala/studasso
- Repository: https://github.com/mti-2023-tala/studasso

## Overview

##### Main Components

a. Frontend Applications (3 separate apps):
- Student Portal (Angular)
- Association Portal (Angular)
- School Portal (Angular)

b. Backend Components:
- NestJS Backend API
- PostgreSQL Database
- Redis Cache
- Authentication System

##### Architecture Layers

Frontend Layer:
**┌─────────────────────────────────────────────────────┐**
- Frontend Apps                       │
- ┬────────────────┬───────────────────┤
- Student Portal│Association Portal│  School Portal    │
- ┬───────┴────────┬───────┴─────────┬─────────┘

- ┼──────────────────┘

Shared Frontend Components:
**┌─────────────────────────────────────────────────────┐**
- Shared Frontend Libraries               │
- ┬──────────────┬────────────┬──────────┤
- Formly    │    Modal     │  Navbar    │  Toast   │
- Generic   │    Table     │  Tag       │  Tooltip │
- ┴──────────────┴────────────┴──────────┘

Backend Layer:
**┌─────────────────────────────────────────────────────┐**
- NestJS Backend                    │
- ┬──────────────┬────────────┬──────────┤
- Core       │  Features    │   Auth     │  API     │
- Modules    │  Modules     │   Module   │ Gateway  │
- ┬──────┴──────┬───────┴─────┬─────┴────┬─────┘

**┌──────┴──────┐┌────┴─────┐ ┌──────┴───┐┌────┴─────┐**
- Database   ││   Redis   │ │  JWT Auth ││  Swagger │
- (PostgreSQL) ││   Cache   │ │          ││   Docs   │
- ┘└──────────┘ └──────────┘└──────────┘

##### Key Design Elements

- Blue for frontend applications
- Green for backend services
- Yellow for databases/storage
- Red for authentication/security components

- Frontend → Backend (REST API calls)
- Backend → Database (Prisma ORM)
- Backend → Redis (Caching)

##### Important Details

- Authentication flow
- Feature modules organization
- Shared libraries and components
- Database schema representation
- API endpoints structure

##### Implementation Notes

- Modular architecture using NX workspace
- Separation of concerns between different portals
- Shared component libraries
- Core backend services
- Database relationships
- Caching strategy
- Authentication flow

##### Deployment Architecture

**┌─────────────────┐    ┌─────────────────┐**
- CI/CD (.yml)  │───>│  Docker Images  │
- ┬────────┘    └────────┬────────┘

- v                      v
**┌─────────────────┐    ┌─────────────────┐**
- Load Balancer  │<───│  Container Orch │
- ┬────────┘    └────────┬────────┘

- ┌────┴─────────────────────┘

- v
**┌─────────────────┐**
- Production Env │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#e67e22,stroke:#d35400,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef shared fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        SP["Student Portal"]:::frontend
        AP["Association Portal"]:::frontend
        SCP["School Portal"]:::frontend

        subgraph SharedComponents
            Forms["Forms"]:::shared
            Tables["Tables"]:::shared
            Modals["Modals"]:::shared
            Nav["Navigation"]:::shared
        end

        subgraph CoreServices
            Auth["Authentication"]:::frontend
            ApiComm["API Communication"]:::frontend
            State["State Management"]:::frontend
        end
    end

    %% Backend Layer
    subgraph Backend
        API["NestJS API Server"]:::backend

        subgraph CoreModules
            AuthMod["Authentication Module"]:::security
            ErrorMod["Error Handling"]:::backend
            CacheMod["Redis Cache"]:::backend
            RepoMod["Repository Layer"]:::backend
        end

        subgraph FeatureModules
            AssoMod["Association Module"]:::backend
            EventMod["Event Module"]:::backend
            NewsMod["News Module"]:::backend
            UserMod["User Module"]:::backend
            RoleMod["Role Module"]:::backend
        end
    end

    %% Database Layer
    subgraph DataLayer
        DB[(PostgreSQL)]:::database
        Redis[(Redis Cache)]:::database
        PrismaORM["Prisma ORM"]:::backend
    end

    %% Relationships
    SP & AP & SCP --> SharedComponents
    SharedComponents --> CoreServices
    CoreServices --> API
    API --> CoreModules
    API --> FeatureModules
    CoreModules & FeatureModules --> RepoMod
    RepoMod --> PrismaORM
    PrismaORM --> DB
    CacheMod --> Redis

    %% Click Events
    click SP "https://github.com/MTI-2023-TALA/StudAsso/tree/main/apps/frontend/student"
    click AP "https://github.com/MTI-2023-TALA/StudAsso/tree/main/apps/frontend/association"
    click SCP "https://github.com/MTI-2023-TALA/StudAsso/tree/main/apps/frontend/school"
    click Forms "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/frontend/shared/formly"
    click Tables "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/frontend/shared/table"
    click Modals "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/frontend/shared/modal"
    click Nav "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/frontend/shared/navbar"
    click API "https://github.com/MTI-2023-TALA/StudAsso/tree/main/apps/backend"
    click AuthMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/core/auth"
    click ErrorMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/core/error"
    click CacheMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/core/redis"
    click RepoMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/core/repository"
    click AssoMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/feature/association"
    click EventMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/feature/event"
    click NewsMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/feature/news"
    click UserMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/feature/user"
    click RoleMod "https://github.com/MTI-2023-TALA/StudAsso/tree/main/libs/backend/feature/role"
    click PrismaORM "https://github.com/MTI-2023-TALA/StudAsso/blob/main/libs/backend/core/orm/src/lib/prisma/schema.prisma"
```
