# astridv23/tpi_asociacion_futbol architecture

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

- Interactive diagram: https://gitdiagram.com/astridv23/tpi_asociacion_futbol
- Repository: https://github.com/astridv23/tpi_asociacion_futbol

## Overview

##### Project Type and Purpose
- This is a full-stack application managing football (soccer) data—for instance, teams, players, tournaments, etc.
- The backend is built with Node.js (using Express-like patterns) and makes use of Prisma for database management. It includes multiple routes for operations such as login, registration, team management, player handling, and tournament details.
- The frontend uses a React setup (with Vite) that interacts with the backend via API calls.

##### Analyzing the File Structure
a. Backend:
- Contains directories for configurations, route files (e.g., login.routes.js, register.routes.js, equipos.routes.js, etc.), middleware, and libraries (like JWT helpers).
- The "DB" folder holds connection setup details.
- The "prisma" folder includes the Prisma schema file, migrations, and a SQLite database. This clearly defines the data modeling and migration lifecycle for managing the database schema.
- Files like app.js and index.js indicate the entry point and application setup.
b. Frontend:
- Contains the React application with components (e.g., CardJugador.jsx, forms for team and player details), hooks (authentication context, Axios hook), and views structured in "vistas."
- The use of Vite (vite.config.js) implies an optimized development and build environment.
- The login directory highlights separate routes/components for login and registration.
c. SQLite Directory:
d. Root Files:
- Contains a README and package files that may have shared configurations for the whole project.

a. Main Components to Include:
- Frontend Client: Represented by the React application.
- Backend API Server: The Node.js application handling routes, middleware, and business logic.
- Database: The SQLite database managed via Prisma, with a clear representation of how migrations evolve the schema.
- Auxiliary components: Authentication services (JWT-based), connection utilities, and any additional libraries or middleware.

b. Relationships and Interactions:
- Internal flows in the backend, such as request routing (from Express route handlers) to middleware (validation with JWT) and finally to the database.

c. Architectural Patterns and Principles:
- Clearly separate the full-stack architecture into discrete layers (presentation, application, and data persistence).
- Use of RESTful API conventions in the backend routes.
- Middleware usage (for authentication and token validation) and how responsibilities are distributed (e.g., controllers, routers, helper libraries).
- Migration mechanism provided by Prisma for database version control.

d. Technologies, Frameworks, and Tools:
- Frontend: React (with Vite as the bundler/development tool), JSX components, custom hooks, and form handling.
- Backend: Node.js with an Express-like structure; routing for login, registration, categories, divisions, and tournaments; JWT for authentication.
- Database: SQLite used in conjunction with Prisma ORM, visible through schema and migration files.
- Additional tools: ESLint in the frontend, and standard .gitignore files managing source control.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend (React Application)"
        FEApp["React App (App.jsx, main.jsx)"]:::frontendClass
        FELogin["Login/Registration Components"]:::frontendClass
        FEUI["UI Component: CardJugador.jsx"]:::frontendClass
        FEForms["Form Components (Team, Player Forms)"]:::frontendClass
        FEHooks["React Hooks (Auth, Axios)"]:::frontendClass
    end

    %% Backend Subgraph
    subgraph "Backend API Server (Node/Express)"
        BEApp["app.js"]:::backendClass
        BEIndex["index.js"]:::backendClass
        
        subgraph "API Routes"
            BELogin["login.routes.js"]:::backendClass
            BERegister["register.routes.js"]:::backendClass
            BEEquipos["equipos.routes.js"]:::backendClass
            BETorneo["torneo.routes.js"]:::backendClass
            BECategoria["categoria.routes.js"]:::backendClass
            BEDivision["division.routes.js"]:::backendClass
        end
        
        BEMiddleware["validateToken.js"]:::backendClass
        BEJWT["JWT Utilities"]:::backendClass
        BEDBConn["DB Connection Utility"]:::backendClass
        BEPrisma["Prisma ORM & Schema"]:::backendClass
    end

    %% Database Subgraph
    subgraph "Database (SQLite + Prisma)"
        DBPrismMigs["Prisma Migrations"]:::dbClass
        DB_SQLite["SQLite Database (futbol.db)"]:::dbClass
    end

    %% Connections between Frontend and Backend
    FEApp -- "API_Calls" --> BEApp

    %% Backend internal flows: Entry points calling API Routes
    BEApp -- "routes" --> BELogin
    BEApp -- "routes" --> BERegister
    BEApp -- "routes" --> BEEquipos
    BEApp -- "routes" --> BETorneo
    BEApp -- "routes" --> BECategoria
    BEApp -- "routes" --> BEDivision

    %% API Routes utilizing Middleware and JWT
    BELogin -- "auth" --> BEMiddleware
    BERegister -- "auth" --> BEMiddleware
    BEEquipos -- "auth" --> BEMiddleware
    BETorneo -- "auth" --> BEMiddleware
    BECategoria -- "auth" --> BEMiddleware
    BEDivision -- "auth" --> BEMiddleware

    BELogin -- "JWT" --> BEJWT
    BERegister -- "JWT" --> BEJWT

    %% Middleware directs to DB Connection then to Prisma
    BEMiddleware -- "db_call" --> BEDBConn
    BEDBConn -- "ORM" --> BEPrisma

    %% Prisma handles migrations to the database
    BEPrisma -- "migrate" --> DBPrismMigs
    DBPrismMigs -- "schema" --> DB_SQLite

    %% Click Events for Frontend Components
    click FEApp "https://github.com/astridv23/tpi_asociacion_futbol/tree/main/Frontend/src"
    click FELogin "https://github.com/astridv23/tpi_asociacion_futbol/tree/main/Frontend/src/login"
    click FEUI "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Frontend/src/componentes/CardJugador.jsx"
    click FEForms "https://github.com/astridv23/tpi_asociacion_futbol/tree/main/Frontend/src/forms"
    click FEHooks "https://github.com/astridv23/tpi_asociacion_futbol/tree/main/Frontend/src/hooks"

    %% Click Events for Backend Entry Points
    click BEApp "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/app.js"
    click BEIndex "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/index.js"

    %% Click Events for API Routes
    click BELogin "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/routes/login.routes.js"
    click BERegister "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/routes/register.routes.js"
    click BEEquipos "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/routes/equipos.routes.js"
    click BETorneo "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/routes/torneo.routes.js"
    click BECategoria "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/routes/categoria.routes.js"
    click BEDivision "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/routes/division.routes.js"

    %% Click Events for Middleware and JWT
    click BEMiddleware "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/middlewares/validateToken.js"
    click BEJWT "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/libs/jwt.js"

    %% Click Event for DB Connection
    click BEDBConn "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/DB/connection.js"

    %% Click Events for Prisma ORM
    click BEPrisma "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/prisma/schema.prisma"

    %% Click Events for Database Components
    click DB_SQLite "https://github.com/astridv23/tpi_asociacion_futbol/blob/main/Backend/src/DB/futbol.db"
    click DBPrismMigs "https://github.com/astridv23/tpi_asociacion_futbol/tree/main/Backend/prisma/migrations/"

    %% Styling Classes
    classDef frontendClass fill:#e0f7fa,stroke:#006064,stroke-width:2px,color:#006064;
    classDef backendClass fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px,color:#ef6c00;
    classDef dbClass fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px,color:#2e7d32;
```
