# willvillegas/proyecto-ds-equipo5 architecture

> Architecture diagram of the GitHub repository willvillegas/proyecto-ds-equipo5, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/willvillegas/proyecto-ds-equipo5
- Repository: https://github.com/willvillegas/proyecto-ds-equipo5

## Overview

##### Main Components
- Frontend (Client):
- Contains the React application (pages, components, context providers, and API routing).
- Handles user interfaces, authentication views (login, password recovery, etc.), and different pages for managing content (activities, comments, plan work, etc.).
- Backend (Server):
- Implements REST APIs with Express.
- Organized into DAOs (data access objects) for database interaction, controllers for request handling, models including visitors and interfaces, and middleware.
- Utilizes helper utilities for tasks like generating tokens (jsonwebtoken), sending emails (nodemailer), and server time management.
- Database:
- MS-SQL is the central data store for user records, activity details, plan information, and notifications.
- External Services and Libraries:
- Express (for routing and server logic)
- nodemailer (for sending emails)
- Tailwind CSS (on the frontend for styling)
- Vite (for fast frontend builds)
- Netlify (cloud service for deployment of the client)
- MS-SQL (database engine to store and manage data)

##### Relationships and Interactions
- Frontend to Backend Communication:
- Use API calls (likely via REST routes defined in Client/apiRoutes.js) where user actions (login, registration, activity submissions, etc.) trigger HTTP requests to the backend.
- Server Internal Flow:
- Requests hit the appropriate routes (organized in the Server/routes folder).
- Routes call corresponding controllers (located in Server/controllers) which then delegate to DAOs (in Server/DAOs) for data interaction.
- Controllers incorporate middleware (from Server/middleware) for authentication and role-based access control.
- Database Layer:
- DAOs interact directly with the MS-SQL database (as evidenced by scripts.sql and the connection requirements).
- External Utilities:
- Usage of nodemailer for email notifications and utilities handling JSON web tokens for security.

##### Architectural Patterns and Design Principles
- MVC-like Structure:
- Clearly separated concerns (models, views on the client, controllers, and DAOs on the server).
- RESTful API design:
- Each resource (activities, professors, students, etc.) has its own route and controller.
- Modular Code Organization:
- Granularity in the code (multiple small components, context providers, and helper modules) promotes maintainability.
- Security Practices:
- User authentication (login, password recovery) as well as data encryption for passwords.
- Scalability:
- The separation between frontend and backend along with API-based communication makes it easier to extend functionalities without affecting system stability.

- At the top, include a “User Interface” block representing the end user interacting with the Client.
- A block for the React application, which includes sub-blocks such as “Pages”, “Components”, “Routes”, and “Context Providers”.
- Server:
▪ Top layer: “Routes” which then link to “Controllers”.
▪ Middle layer: “Controllers” calling logic for respective modules (e.g., Activity, Usuario, Profesor, etc.).
▪ Lower Layer: “DAOs” communicating with the “MS-SQL Database”.
- An additional middleware block intercepting incoming requests for authentication or role validation.
- From Client to Server: Show API calls.
- Inside Server: Show the flow from routes → controllers → models/DAOs → database.
- From Server back to Client: Response flows.
- External Tools:
- A note or separate block for “Deployment on Netlify” associated with the Client, and mention “Node.js (Express)” on the server side.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User("User"):::external

    %% Client Subgraph
    subgraph "Client"
        ReactFrontend("React Frontend"):::frontend
        subgraph "Client Components"
            ApiRoutes("API Routing: apiRoutes.js"):::frontend
            PageRoutes("API Routing: PageRoutes.jsx"):::frontend
            UIComponents("UI Components: components"):::frontend
            UIComponentsUI("UI Components: ui"):::frontend
            ContextProviders("Context Providers"):::frontend
        end
        NetlifyDeployment("Netlify Deployment"):::external
    end

    %% Server Subgraph
    subgraph "Server"
        ExpressServerEntry("Express Server Entry Point"):::backend
        subgraph "Server Layers"
            MiddlewareLayer("Middleware (Auth&Role)"):::backend
            RoutesLayer("Server Routes"):::backend
            ControllersLayer("Server Controllers"):::backend
            DAOsLayer("Data Access Objects (DAOs)"):::backend
            ModelsLayer("Domain Models & Interfaces"):::backend
        end
        subgraph "Utilities"
            JWTUtils("JSON Web Token Utility"):::utility
            NodemailerUtils("Nodemailer Utility"):::utility
            HelperUtils("Helper Utilities"):::utility
            ServerTime("Server Time Utility"):::utility
        end
    end

    %% Database Node and Connection DAO
    Database("MS-SQL Database"):::db
    ConnectionDAO("ConnectionDAO"):::backend

    %% Connections between Client and User
    User --> ReactFrontend

    %% Client internal connections
    ReactFrontend --> ApiRoutes
    ReactFrontend --> PageRoutes
    ReactFrontend --> UIComponents
    ReactFrontend --> UIComponentsUI
    ReactFrontend --> ContextProviders
    ReactFrontend --> NetlifyDeployment

    %% Client to Server API calls
    ApiRoutes --> ExpressServerEntry
    PageRoutes --> ExpressServerEntry

    %% Server internal flow
    ExpressServerEntry --> MiddlewareLayer
    MiddlewareLayer --> RoutesLayer
    RoutesLayer --> ControllersLayer
    ControllersLayer --> DAOsLayer
    ControllersLayer --> ModelsLayer
    DAOsLayer --> ConnectionDAO
    ConnectionDAO --> Database

    %% Controllers using utilities
    ControllersLayer -->|"uses"| JWTUtils
    ControllersLayer -->|"uses"| NodemailerUtils
    ControllersLayer -->|"uses"| HelperUtils
    ControllersLayer -->|"uses"| ServerTime

    %% Response flow back to Client
    ExpressServerEntry -->|"response"| ReactFrontend

    %% Click events for Client components
    click ReactFrontend "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Client"
    click ApiRoutes "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Client/apiRoutes.js"
    click PageRoutes "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Client/src/PageRoutes.jsx"
    click UIComponents "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Client/src/components"
    click UIComponentsUI "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Client/src/components/ui"
    click ContextProviders "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Client/src/context"

    %% Click events for Server components
    click ExpressServerEntry "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Server/index.js"
    click RoutesLayer "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Server/routes"
    click ControllersLayer "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Server/controllers"
    click DAOsLayer "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Server/DAOs"
    click MiddlewareLayer "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Server/middleware"
    click ModelsLayer "https://github.com/willvillegas/proyecto-ds-equipo5/tree/main/Server/models"

    %% Click events for Utilities
    click JWTUtils "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Server/utils/jsonwebtoken.js"
    click NodemailerUtils "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Server/utils/nodemailer.js"
    click HelperUtils "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Server/utils/helpers.js"
    click ServerTime "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Server/utils/serverTime.js"

    %% Click event for Connection DAO and Database
    click ConnectionDAO "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/Server/DAOs/ConnectionDAO.js"
    click Database "https://github.com/willvillegas/proyecto-ds-equipo5/blob/main/scripts.sql"

    %% Styles
    classDef frontend fill:#A3D5FF,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFC993,stroke:#000,stroke-width:2px;
    classDef db fill:#C3F7C3,stroke:#000,stroke-width:2px;
    classDef utility fill:#FFF79A,stroke:#000,stroke-width:2px;
    classDef external fill:#FDD0D0,stroke:#000,stroke-width:2px;
```
