# jjaracanales/desarrollo_software_web_i_ev2 architecture

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

- Interactive diagram: https://gitdiagram.com/jjaracanales/desarrollo_software_web_i_ev2
- Repository: https://github.com/jjaracanales/desarrollo_software_web_i_ev2

## Overview

##### Project Type and Purpose
– This is a monolithic full-stack web application (Laravel 12 with PHP 8.2) providing a JWT-protected CRUD for “Proyectos” (projects) plus public home and authentication pages. Data is stored in MySQL. It also exposes the same functionality via an API.

##### File Structure Analysis
– Top-level folders:
- app/
– Http/Controllers (AuthController, HomeController, ProyectoController)
– Http/Middleware (JWTAuthMiddleware)
– Models (User, Proyecto)
– Services (UFService – external UF data fetch)
- bootstrap/ (Laravel bootstrap, middleware aliases)
- config/ (app, auth, database, etc.)
- database/ (migrations, factories, seeders)
- public/ (index.php front controller, static assets)
- resources/ (Blade views, JS bootstrap)
- routes/ (web.php for UI, api.php for REST)
- storage/ (logs, cache, sessions, file storage)
– Build/deploy scripts: build.sh, vercel-*.json, init-db.php, phpunit.xml.
– Composer files define PHP dependencies.

##### README Insights
– Describes features (JWT auth, protected CRUD).
– Tech stack: Laravel 12, PHP 8.2.29, MySQL.
– Authentication via JWT in cookie or Bearer header.
– No seeders used in EV2.

##### Main Components
1) Client (Browser)
- Displays Blade views (login, register, proyectos pages)
- Stores JWT cookie or includes Bearer token for API calls
2) Web Server / Front Controller
- Apache/Nginx → public/index.php → bootstrap/app.php
3) Laravel Application
– Routing Layer
- routes/web.php (UI)
- routes/api.php (JSON API)
– Middleware Layer
- JWTAuthMiddleware (protects routes)
– Controller Layer
- AuthController (register/login, JWT issuance)
- HomeController (public home)
- ProyectoController (CRUD)
– Service Layer
- UFService (fetch Unidad de Fomento from external API for display component)
– Model Layer (Eloquent ORM)
- User (users table)
- Proyecto (proyectos table)
– View Layer
- Blade templates (resources/views) and JS bootstrap
4) Database
- MySQL (tables: users, proyectos, cache, jobs)
5) Storage & Cache
- File‐based cache, sessions, logs in storage/
6) External Services
- UF external API (via UFService)

##### Relationships & Data Flows
– Browser → HTTP request → public/index.php → Laravel Router
– Router → Middleware (JWTAuthMiddleware on protected routes)
– Middleware → Controllers →
- on CRUD/actions: Controllers use Models → MySQL
- on UF display: Controller (or view component) invokes UFService → external UF API
– Controllers return Views (HTML) or JSON (API routes) → Browser
– Views embed JS bootstrap and Blade components; respond to user actions
– Laravel uses storage/ for session state and caching

##### Architectural Patterns & Principles
– MVC (Model-View-Controller)
– Layered architecture (Routing → Middleware → Controllers → Services → Models → DB)
– Separation of concerns:
- Auth logic in AuthController + JWTAuthMiddleware
- Business logic in Services (UFService)
- Data access via Eloquent Models
– RESTful API layering on top of same controllers

## Diagram (Mermaid)

```mermaid
flowchart TB
    Browser["Browser<br/>(Blade Views & JS)"]:::frontend
    subgraph "Web Server / Front Controller"
        Public["public/index.php → bootstrap/app.php"]:::backend
    end
    subgraph "Routing Layer"
        Router1["routes/web.php"]:::routing
        Router2["routes/api.php"]:::routing
    end
    Middleware["JWTAuthMiddleware"]:::middleware
    subgraph "Controllers"
        AuthC["AuthController"]:::controller
        HomeC["HomeController"]:::controller
        ProyC["ProyectoController"]:::controller
    end
    Service["UFService"]:::service
    subgraph "Models"
        UserM["User Model"]:::model
        ProyM["Proyecto Model"]:::model
    end
    DB["MySQL Database"]:::database
    Storage["Storage/Cache/Logs"]:::storage
    ExtAPI["External UF API"]:::external

    Browser --> Public
    Public --> Router1
    Public --> Router2
    Router1 --> Middleware
    Router2 --> Middleware
    Middleware --> AuthC
    Middleware --> HomeC
    Middleware --> ProyC
    AuthC --> UserM
    HomeC --> UserM
    ProyC --> ProyM
    ProyC --> Service
    UserM -.-> DB
    ProyM -.-> DB
    Service -.-> ExtAPI
    AuthC -->|HTML/JSON Response| Browser
    HomeC -->|HTML Response| Browser
    ProyC -->|HTML/JSON Response| Browser
    AuthC --> Storage
    ProyC --> Storage

    click Browser "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/tree/main/resources/views/"
    click Browser "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/resources/js/bootstrap.js"
    click Public "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/public/index.php"
    click Router1 "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/routes/web.php"
    click Router2 "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/routes/api.php"
    click Middleware "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/app/Http/Middleware/JWTAuthMiddleware.php"
    click AuthC "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/app/Http/Controllers/AuthController.php"
    click HomeC "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/app/Http/Controllers/HomeController.php"
    click ProyC "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/app/Http/Controllers/ProyectoController.php"
    click Service "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/app/Services/UFService.php"
    click UserM "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/app/Models/User.php"
    click ProyM "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/blob/main/app/Models/Proyecto.php"
    click Storage "https://github.com/jjaracanales/desarrollo_software_web_i_ev2/tree/main/storage/framework/"

    classDef frontend fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef backend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef routing fill:#add8e6,stroke:#333,stroke-width:1px
    classDef middleware fill:#87cefa,stroke:#333,stroke-width:1px
    classDef controller fill:#6495ed,stroke:#333,stroke-width:1px
    classDef service fill:#1e90ff,stroke:#333,stroke-width:1px,color:#fff
    classDef model fill:#4169e1,stroke:#000,stroke-width:1px
    classDef database fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef storage fill:#ffb266,stroke:#333,stroke-width:1px
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
```
