# franndeli/blooming architecture

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

- Interactive diagram: https://gitdiagram.com/franndeli/blooming
- Repository: https://github.com/franndeli/blooming

## Overview

##### Project Type and Purpose
- Full‐stack web application (“Blooming”) for real‐time monitoring of elementary and early middle school students’ emotional well‐being.
- Backend: Node.js + Express REST API with Sequelize ORM over an SQL database.
- Frontend: Angular SPA with custom WebGL graphics engine for interactive emotional state visualization.
- Target users: administrators, teachers, center managers, students (viewing simple experiences).

##### File Structure Analysis
- Top-level:
- backend/: controllers/, models/, routes/, middleware/, helpers/, database/ → standard MVC pattern.
- frontend/: Angular workspace with modules (auth, commons, components, graphics, pages, services), assets (styles, images, shaders, libs).
- Backend:
- controllers/*.js handle HTTP requests.
- routes/*.js map paths → controllers.
- models/*.js define DB entities and associations.js wires them.
- middleware/* handle JWT validation, role checks, hashing, input validation.
- helpers/jwt.js and middleware/validar-jwt.js implement authentication.
- Frontend:
- app-routing.module.ts and feature routing modules separate auth, admin, teacher, student, center areas.
- services/*.service.ts wrap HTTP calls to REST endpoints.
- graphics/ implements a scene graph and WebGL engine (arbol_escena, gestor_recursos, motor).
- assets/libs include third-party JS/CSS (Bootstrap, jQuery, ApexCharts, SimpleBar).
- components and pages folders organize UI by feature (admin, profesores, alumnos, centros, etc.).

##### Key Architectural Patterns
- Backend: MVC + layered middleware for cross-cutting concerns (auth, validation).
- Frontend: Modular Angular architecture with feature modules, component-based UI, service-based data layer.
- WebGL subsystem: custom graphics engine internal to the front end, decoupled via services.

a. Main Components
- Client Browser (Angular SPA)
- REST API Server (Node.js + Express)
- SQL Database (MySQL/PostgreSQL via Sequelize)
- Authentication Service (JWT issuance/validation)
- WebGL Engine (inside SPA)
- Static Assets CDN or Server (served by Express or external)
b. Interactions
1. User interacts with Angular UI → Angular services invoke HTTP(S) requests to REST API endpoints.
2. REST API middleware validates JWT, checks roles.
3. Controllers perform business logic and use Sequelize models to query/update the SQL database.
4. Responses (JSON) flow back to Angular services → components update UI, graphics engine renders scenes.
5. Static assets (images, shaders, JS libs) served to client at build time or via CDN.
c. Important Patterns
- Stateless REST API with JWT-based auth.
- ORM layer abstracts SQL schemas.
- Angular lazy-loaded feature modules for admin/teacher/student flows.
- MVC separation in backend, component/service separation in frontend.
d. Key Technologies
- Node.js, Express, Sequelize on the server.
- Angular CLI, TypeScript, WebGL (custom engine) on the client.
- Third-party libs: Bootstrap, ApexCharts for data visualization, SimpleBar for scrollbars.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Angular SPA)" 
        direction TB
        SPA["Browser / Angular SPA"]:::frontend

        subgraph "Core Modules"
            direction TB
            AppModule["AppModule"]:::frontend
            AppRouting["AppRoutingModule"]:::frontend
        end

        subgraph "Feature Modules"
            direction TB
            AuthModule["AuthModule"]:::frontend
            AdminModule["AdminModule"]:::frontend
            TeacherModule["TeacherModule"]:::frontend
            StudentModule["StudentModule"]:::frontend
            CenterModule["CenterModule"]:::frontend
        end

        subgraph "Shared Layer"
            direction TB
            Commons["Common Components"]:::frontend
            ComponentsModule["ComponentsModule"]:::frontend
        end

        subgraph "Services"
            direction TB
            DataService["HTTP Services"]:::frontend
            GraphicsService["Graphics Services"]:::frontend
        end

        subgraph "WebGL Engine"
            direction TB
            SceneGraph["arbol_escena"]:::frontend
            ResourceManager["gestorRecursos"]:::frontend
            GraphicsMotor["motorGrafico"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Express API)" 
        direction TB
        API["index.js / Express API"]:::backend

        subgraph "Middleware"
            direction TB
            JWTValidate["validar-jwt.js"]:::backend
            RoleCheck["validar-rol.js"]:::backend
            HashHelper["hashHelper.js"]:::backend
            Validations["validaciones.js"]:::backend
        end

        subgraph "Controllers"
            direction TB
            Controllers["controllers/*.js"]:::backend
        end

        subgraph "Routes"
            direction TB
            Routes["routes/*.js"]:::backend
        end

        subgraph "Models"
            direction TB
            Models["models/*.js"]:::backend
            Associations["associations.js"]:::backend
        end

        ConfigDB["configdb.js"]:::backend
        JWTHelper["jwt.js"]:::auth
    end

    %% Database
    Database[(SQL Database)]:::database

    %% Static Assets / CDN
    CDN["Static Assets / CDN"]:::cdn

    %% Authentication Service
    AuthService["JWT Service"]:::auth

    %% Interactions
    SPA -->|"HTTP Request"| API
    API -->|"SQL queries via Sequelize"| Database
    API -->|"+ token validation"| JWTValidate
    JWTValidate -->|"+ role check"| RoleCheck
    API --> Controllers
    Routes --> Controllers
    Controllers --> Models
    Models --> Database
    API --> ConfigDB
    API --> JWTHelper
    SPA --> DataService
    DataService --> API
    SPA --> GraphicsService
    GraphicsService --> SceneGraph
    GraphicsService --> ResourceManager
    GraphicsService --> GraphicsMotor
    SPA -->|load assets| CDN

    %% Click Events
    click AppModule "https://github.com/franndeli/blooming/blob/main/frontend/src/app/app.module.ts"
    click AppRouting "https://github.com/franndeli/blooming/blob/main/frontend/src/app/app-routing.module.ts"
    click AuthModule "https://github.com/franndeli/blooming/blob/main/frontend/src/app/auth/auth.module.ts"
    click AuthModule "https://github.com/franndeli/blooming/blob/main/frontend/src/app/auth/auth.routing.ts"
    click AdminModule "https://github.com/franndeli/blooming/tree/main/frontend/src/app/pages/admin"
    click AdminModule "https://github.com/franndeli/blooming/blob/main/frontend/src/app/layouts/admin-layout/admin-layout.component.ts"
    click TeacherModule "https://github.com/franndeli/blooming/tree/main/frontend/src/app/pages/profesores"
    click TeacherModule "https://github.com/franndeli/blooming/blob/main/frontend/src/app/layouts/auth-layout/auth-layout.component.ts"
    click StudentModule "https://github.com/franndeli/blooming/tree/main/frontend/src/app/pages/alumnos"
    click StudentModule "https://github.com/franndeli/blooming/blob/main/frontend/src/app/layouts/alumno-layout/alumno-layout.component.ts"
    click CenterModule "https://github.com/franndeli/blooming/tree/main/frontend/src/app/pages/centros"
    click Commons "https://github.com/franndeli/blooming/tree/main/frontend/src/app/commons"
    click ComponentsModule "https://github.com/franndeli/blooming/blob/main/frontend/src/app/components/components.module.ts"
    click DataService "https://github.com/franndeli/blooming/tree/main/frontend/src/app/services"
    click GraphicsService "https://github.com/franndeli/blooming/tree/main/frontend/src/app/services/graphics"
    click SceneGraph "https://github.com/franndeli/blooming/tree/main/frontend/src/app/graphics/arbol_escena"
    click ResourceManager "https://github.com/franndeli/blooming/blob/main/frontend/src/app/graphics/gestor_recursos/gestorRecursos.ts"
    click GraphicsMotor "https://github.com/franndeli/blooming/blob/main/frontend/src/app/graphics/motor/motorGrafico.ts"
    click CDN "https://github.com/franndeli/blooming/tree/main/frontend/src/assets"
    click CDN "https://github.com/franndeli/blooming/tree/main/frontend/src/assets/libs/apexcharts"
    click CDN "https://github.com/franndeli/blooming/tree/main/frontend/src/assets/libs/bootstrap"
    click CDN "https://github.com/franndeli/blooming/tree/main/frontend/src/assets/shaders"
    click API "https://github.com/franndeli/blooming/blob/main/backend/index.js"
    click Controllers "https://github.com/franndeli/blooming/blob/main/backend/controllers/*.js"
    click Routes "https://github.com/franndeli/blooming/blob/main/backend/routes/*.js"
    click Models "https://github.com/franndeli/blooming/blob/main/backend/models/*.js"
    click Associations "https://github.com/franndeli/blooming/blob/main/backend/models/associations.js"
    click ConfigDB "https://github.com/franndeli/blooming/blob/main/backend/database/configdb.js"
    click JWTHelper "https://github.com/franndeli/blooming/blob/main/backend/helpers/jwt.js"
    click JWTValidate "https://github.com/franndeli/blooming/blob/main/backend/middleware/validar-jwt.js"
    click RoleCheck "https://github.com/franndeli/blooming/blob/main/backend/middleware/validar-rol.js"
    click HashHelper "https://github.com/franndeli/blooming/blob/main/backend/middleware/hashHelper.js"
    click Validations "https://github.com/franndeli/blooming/blob/main/backend/middleware/validaciones.js"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,color:#1B2631
    classDef backend fill:#A9DFBF,stroke:#145A32,color:#1D8348
    classDef database fill:#F9E79F,stroke:#B9770E,color:#935116
    classDef auth fill:#D2B4DE,stroke:#6C3483,color:#512E5F
    classDef cdn fill:#D5D8DC,stroke:#566573,color:#1C2833
```
