# dat-etsit/top-profe architecture

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

- Interactive diagram: https://gitdiagram.com/dat-etsit/top-profe
- Repository: https://github.com/dat-etsit/top-profe

## Overview

##### Main Components Identification

The system should be represented with these primary components:

a) Client-Side (Frontend):
- React-based frontend (evident from .jsx files)
- Public assets (CSS, fonts)
- Views hierarchy (admin and regular user views)

b) Server-Side (Backend):
- Express.js server (Node.js)
- Controllers layer
- Models layer (Sequelize ORM)
- Authentication system (SSO integration)
- Email service
- External API integration

c) Database:
- MySQL database with multiple related tables
- Session storage

- Public Assets
- Views
- Admin Views
- User Views
- Shared Components
- Client Utilities

- Controllers
- Models
- Middleware
- Router
- Services (Mail, SSO)

- Users
- Professors
- Subjects
- Degrees
- Votes
- Ballots
- Notes
- Sessions

##### Component Relationships

a) Client-Server Communication:
- REST API calls between frontend views and backend controllers
- WebSocket connections (if implemented)
- Authentication flow with SSO

b) Data Flow:
- Controller-Model interactions
- Database operations
- External API communications

##### Architectural Patterns to Highlight

- MVC pattern in the backend
- Component-based architecture in React frontend
- RESTful API design
- Database relationships and constraints

##### Technical Stack Indicators

Technologies:
- Node.js/Express
- React
- MySQL
- Sequelize ORM
- Webpack
- Babel

Remember to include:
- Version information
- Environment configurations
- API endpoints
- Database relationships
- Authentication flow

This will provide a comprehensive view of the system while maintaining clarity and usefulness for both development and documentation purposes.

## 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:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef security fill:#9b59b6,stroke:#8e44ad,color:white

    %% Frontend Layer
    subgraph Frontend
        FE[Frontend Entry]
        Views[Views Layer]
        AdminViews[Admin Interface]
        Assets[Public Assets]
        Utils[Client Utilities]
    end

    %% Backend Layer
    subgraph Backend
        BE[Backend Entry]
        Router[Router]
        Middleware[Middleware]
        Controllers[Controllers Layer]
        EmailSvc[Email Service]
        EmailTemp[Email Template]
    end

    %% Database Layer
    subgraph Database
        DBConfig[Database Config]
        Models[Models Layer]
        Migrations[Migrations]
    end

    %% Authentication Layer
    subgraph Auth
        LoginCtrl[Login Controller]
        SessionModel[Session Model]
    end

    %% Core Controllers
    subgraph CoreControllers
        AdminCtrl[Admin Controller]
        ProfCtrl[Professor Controller]
        SubjCtrl[Subject Controller]
        BallotCtrl[Ballot Controller]
        RankCtrl[Ranking Controller]
    end

    %% Data Models
    subgraph DataModels
        UserModel[User Model]
        ProfModel[Professor Model]
        SubjModel[Subject Model]
        BallotModel[Ballot Model]
        VoteModel[Vote Model]
        NoteModel[Note Model]
    end

    %% Model-Controller Relationships
    AdminCtrl --> UserModel
    AdminCtrl --> ProfModel
    AdminCtrl --> SubjModel
    AdminCtrl --> BallotModel
    AdminCtrl --> VoteModel
    AdminCtrl --> NoteModel
    ProfCtrl --> ProfModel
    SubjCtrl --> SubjModel
    BallotCtrl --> BallotModel
    BallotCtrl --> VoteModel
    BallotCtrl --> ProfModel
    BallotCtrl --> SubjModel
    RankCtrl --> VoteModel
    RankCtrl --> ProfModel
    RankCtrl --> SubjModel
    LoginCtrl --> UserModel
    LoginCtrl --> SessionModel

    %% Middleware Relationships
    Middleware --> LoginCtrl
    Middleware --> AdminCtrl
    Middleware --> BallotCtrl

    %% Base Relationships
    FE --> Router
    Router --> Controllers
    Controllers --> Models
    Models --> DBConfig
    EmailSvc --> EmailTemp

    %% Component Classes
    class FE,Views,AdminViews,Assets,Utils frontend
    class BE,Router,Middleware,Controllers,EmailSvc,EmailTemp backend
    class DBConfig,Models,Migrations database
    class LoginCtrl,SessionModel security

    %% Click Events
    click FE "https://github.com/DAT-ETSIT/top-profe/blob/main/src/client/App.jsx"
    click BE "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/server.js"
    click Views "https://github.com/DAT-ETSIT/top-profe/tree/main/src/client/views/"
    click AdminViews "https://github.com/DAT-ETSIT/top-profe/tree/main/src/client/views/admin/"
    click Assets "https://github.com/DAT-ETSIT/top-profe/tree/main/src/client/public/"
    click Utils "https://github.com/DAT-ETSIT/top-profe/blob/main/src/client/util.js"
    click Controllers "https://github.com/DAT-ETSIT/top-profe/tree/main/src/server/controllers/"
    click Router "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/router.js"
    click Middleware "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/middlewares.js"
    click EmailSvc "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/mail.js"
    click EmailTemp "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/mailTemplate.html"
    click DBConfig "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/databaseConfig.js"
    click Models "https://github.com/DAT-ETSIT/top-profe/tree/main/src/server/models/"
    click Migrations "https://github.com/DAT-ETSIT/top-profe/tree/main/src/server/migrations/"
    click LoginCtrl "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/controllers/loginController.js"
    click SessionModel "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/models/Session.js"
    click AdminCtrl "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/controllers/adminController.js"
    click ProfCtrl "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/controllers/professorController.js"
    click SubjCtrl "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/controllers/subjectController.js"
    click BallotCtrl "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/controllers/ballotController.js"
    click RankCtrl "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/controllers/rankingController.js"
    click UserModel "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/models/User.js"
    click ProfModel "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/models/Professor.js"
    click SubjModel "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/models/Subject.js"
    click BallotModel "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/models/Ballot.js"
    click VoteModel "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/models/Vote.js"
    click NoteModel "https://github.com/DAT-ETSIT/top-profe/blob/main/src/server/models/Note.js"
```
