# fernandoasto04/ingsoft2 architecture

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

- Interactive diagram: https://gitdiagram.com/fernandoasto04/ingsoft2
- Repository: https://github.com/fernandoasto04/ingsoft2

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with a Node.js/Express backend and a React/Vite frontend, backed by a relational database (models indicate Sequelize or a similar ORM).
- It implements an MVC‐style backend with a DAO pattern for data access and provides RESTful API endpoints for managing users, professors, areas, assignments, etc.

##### File Structure Analysis
- Top-level “backend” and “frontend” directories separate server and client.
- backend/ contains:
- server.js – entry point that wires routes, controllers, database.
- controllers/ – request handlers for each entity (Usuario, Profesor, etc.).
- models/ & database/ – ORM model definitions and DB connection.
- patrones/patronDAO/ – DAO factory, DAO implementations, and transfer objects (TO) for data layer abstraction.
- routes/ – Express route definitions mapped to controllers.
- frontend/ contains:
- src/ – React components and contexts.
- Service/ – client-side API wrappers.
- Vite config, public assets, styling.
- pruebasJest/ shows unit tests for DAO and model logic.

##### Key Architectural Patterns
- Layered architecture: Presentation (React), Application/API layer (Express controllers + routes), Domain layer (models + DAO), Persistence layer (database).
- DAO pattern abstracts CRUD operations behind factory/injectable interfaces.
- Context usage in React for state management (Trabajoscontext.jsx).

##### Main Components
- Frontend (React/Vite): UI components, Service layer.
- Backend API (Node.js/Express):
- Routes → Controllers → Service/DAO → Models → Database.
- Database: Relational DB (e.g. PostgreSQL/MySQL).
- External or Auxiliary: Unit Test Suite (Jest) – can be shown as a side component.

##### Relationships and Data Flow
- DAO Factory providing concrete DAO implementations to controllers.
- React Context distributing state to components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        UIComp["UI Components"]:::frontend
        TrabCon["Trabajoscontext.jsx"]:::frontend
        Service["Service Layer (API Adapters)"]:::frontend
        Main["main.jsx"]:::frontend
        App["App.jsx"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API Layer"
        Server["server.js"]:::backend
        subgraph "Routes"
            Routes["Express Routes"]:::backend
        end
        subgraph "Controllers"
            Controllers["Controllers"]:::backend
        end
        DAOFactory["DAOFactory.js"]:::backend
        subgraph "DAO Implementations"
            DAOs["DAO Impl (CRUD)"]:::backend
        end
        subgraph "Transfer Objects"
            TOs["TOs (Data Transfer)"]:::backend
        end
        subgraph "ORM Models"
            Models["Model Definitions & Associations"]:::backend
        end
        DBConn["database.js"]:::backend
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        Database[(Database)]:::persistence
    end

    %% Test Suite
    Tests["Jest Unit Tests"]:::test

    %% Data Flow (all dotted)
    UIComp -.->|"user actions"| Service
    Main -.->|"boots App"| App
    App -.->|"uses UI Components & Context"| UIComp
    TrabCon -.->|"provides state"| UIComp
    Service -.->|"HTTP GET/POST/etc"| Routes

    Routes -.->|"route handling"| Controllers
    Controllers -.->|"use DAOFactory.getDAO()"| DAOFactory
    DAOFactory -.->|"provides DAO instances"| DAOs
    DAOs -.->|"CRUD operations"| TOs
    TOs -.->|"map to models"| Models
    Models -.->|"SQL queries"| DBConn
    DBConn -.->|"connect/query"| Database

    %% Response flows back
    Database -.->|"results"| DBConn
    DBConn -.->|"ORM returns"| Models
    Models -.->|"mapped TO"| TOs
    TOs -.->|"DAO returns"| DAOs
    DAOs -.->|"data to controller"| Controllers
    Controllers -.->|"res.send()"| Routes
    Routes -.->|"HTTP response"| Service
    Service -.->|"update UI"| UIComp

    %% Tests interacting with DAO layer
    Tests -.->|"test CRUD"| DAOs
    Tests -.->|"use models"| Models
    Tests -.->|"use DB connection"| DBConn

    %% Click Events
    click UIComp "https://github.com/fernandoasto04/ingsoft2/tree/main/frontend/src/components"
    click TrabCon "https://github.com/fernandoasto04/ingsoft2/blob/main/frontend/src/components/Trabajoscontext.jsx"
    click Service "https://github.com/fernandoasto04/ingsoft2/tree/main/frontend/Service"
    click Main "https://github.com/fernandoasto04/ingsoft2/blob/main/frontend/src/main.jsx"
    click App "https://github.com/fernandoasto04/ingsoft2/blob/main/frontend/src/App.jsx"
    click Server "https://github.com/fernandoasto04/ingsoft2/blob/main/backend/server.js"
    click Routes "https://github.com/fernandoasto04/ingsoft2/tree/main/backend/routes"
    click Controllers "https://github.com/fernandoasto04/ingsoft2/tree/main/backend/controllers"
    click DAOFactory "https://github.com/fernandoasto04/ingsoft2/blob/main/backend/patrones/patronDAO/dao/DAOFactory.js"
    click DAOs "https://github.com/fernandoasto04/ingsoft2/tree/main/backend/patrones/patronDAO/daocomponent"
    click TOs "https://github.com/fernandoasto04/ingsoft2/tree/main/backend/patrones/patronDAO/daoto"
    click Models "https://github.com/fernandoasto04/ingsoft2/tree/main/backend/models"
    click DBConn "https://github.com/fernandoasto04/ingsoft2/blob/main/backend/database/database.js"
    click Tests "https://github.com/fernandoasto04/ingsoft2/tree/main/pruebasJest/src/PruebasUnitarias"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000
    classDef backend fill:#90EE90,stroke:#000
    classDef persistence fill:#FFA500,stroke:#000
    classDef test fill:#D3D3D3,stroke:#000
```
