# nicomargo/centroeducativodew architecture

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

- Interactive diagram: https://gitdiagram.com/nicomargo/centroeducativodew
- Repository: https://github.com/nicomargo/centroeducativodew

## Overview

##### Project type and purpose
- This is a full-stack Java EE web application (“centroEducativoDEW”) for managing educational center data (students, courses, professors).
- The UI is rendered with JSPs and static assets (CSS/JS), the server uses Servlets + Filters, business logic in a service layer, and it calls an external “Centro” service via HTTP.

##### File structure
- Top level:
- scriptCragarDatosLanzaAplicacion.sh – helper script to load data and launch the app
- README.md – minimal project description
- cucu – (ignore or legacy file)
- NOL/ – the Eclipse-based webapp project root
- Under NOL/src/main/java/dew:
- filter/ – servlet filters (authentication, logging, debug)
- main/ – Servlet controllers (AlumnoServlet, AsignaturaServlet)
- service/ – business services (AlumnoService, AsignaturaService, CentroClient)
- helper/ – utilities (InputValidator)
- models/ – domain objects (Alumno, Asignatura, Profesor, AuthResult)
- Under NOL/src/main/webapp:
- WEB-INF/web.xml and credentials.properties – deployment/configuration
- WEB-INF/jsp – error pages
- jsp folders (alumno, asignatura) and top-level JSPs (login.jsp, index.jsp)
- static assets: css/, js/, img/, includes/

##### README
- Very brief: “Trabajo final centro educativo … Desarrollo Web.”

##### Main components
a. Presentation Layer
- Client Browser (HTML/CSS/JS)
- Static assets served by the container
b. Web Layer (Deployed in a Servlet container like Tomcat)
- Servlet Container / Web Server
- Filter Chain:
- DataAuthFilter (authorization)
- DebugFilter (debug logging)
- LogsFilter (request/response logging)
- Controllers: AlumnoServlet, AsignaturaServlet
- web.xml & credentials.properties (configuration)
c. Business Layer
- Service classes: AlumnoService, AsignaturaService
- Helper: InputValidator
d. Integration Layer
- CentroClient – HTTP client calling external Centro Educativo API
- Dependencies: Apache HttpClient, Gson for JSON binding, RxJava for reactive streams
e. Data/External Services
- External “Centro” REST API (authentication & data provider)
- No local database – relies on external service

##### Interactions and data flow
1. User sends HTTP request from browser → Web Server
2. Request passes through Filters in order → Filters perform auth, debug, logging
3. Filter forwards to corresponding Servlet (based on URL mapping)
4. Servlet validates input (InputValidator), invokes Service layer
5. Service calls CentroClient → makes REST HTTP call → receives JSON → parses with Gson → returns domain models
6. Service returns data/model to Servlet → Servlet selects JSP view → populates JSP with model → JSP renders HTML
7. Response travels back through Filters (for any post-processing logs) → delivered to browser

##### Architectural patterns & design principles
- MVC (Model-View-Controller):
- Controller = Servlets
- View = JSP + static resources
- Model = domain objects + service results
- Filter Chain for cross-cutting concerns (auth, logging, debug)
- Layered Architecture: clear separation between presentation, business, integration
- Use of Reactive Streams (RxJava) in HTTP client for non-blocking calls (if leveraged)

##### Be detailed
- Every filter in the chain
- Sequence of calls from Servlet → Service → CentroClient → External API
- Don’t omit any top-level lib or folder that plays a role in runtime (e.g., lib/*.jar)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Client Browser\n(HTML/CSS/JS)"]:::presentation
        CSS["CSS"]:::presentation
        JS["JS"]:::presentation
        IMG["Images"]:::presentation
        INCLUDES["Includes"]:::presentation
        indexJSP["index.jsp"]:::presentation
        loginJSP["login.jsp"]:::presentation
        perfilAlumnoJSP["perfilAlumno.jsp"]:::presentation
        infoAsignaturaJSP["infoAsignatura.jsp"]:::presentation
        error401JSP["error401.jsp"]:::presentation
        error404JSP["error404.jsp"]:::presentation
    end

    %% Web Layer
    subgraph "Web Layer\n(Apache Tomcat - Servlet Container)"
        direction TB
        Filters["Filter Chain"]:::web
        subgraph "Filters"
            direction TB
            DataAuthFilter["DataAuthFilter"]:::web
            DebugFilter["DebugFilter"]:::web
            LogsFilter["LogsFilter"]:::web
        end
        Controllers["Servlet Controllers"]:::web
        subgraph "Controllers"
            direction TB
            AlumnoServlet["AlumnoServlet"]:::web
            AsignaturaServlet["AsignaturaServlet"]:::web
        end
        Config["Configuration Files"]:::web
        subgraph "Configuration"
            direction TB
            webXml["web.xml"]:::web
            credsProp["credentials.properties"]:::web
        end
        Libs["Libraries (.jar)"]:::web
    end

    %% Business Layer
    subgraph "Business Layer"
        direction TB
        InputValidator["InputValidator"]:::business
        AlumnoService["AlumnoService"]:::business
        AsignaturaService["AsignaturaService"]:::business
    end

    %% Integration Layer
    subgraph "Integration Layer"
        direction TB
        CentroClient["CentroClient"]:::integration
    end

    %% External
    ExternalCentro[(Centro Educativo REST API)]:::external

    %% Data Load Script & README
    script["scriptCragarDatosLanzaAplicacion.sh"]:::misc
    readme["README.md"]:::misc

    %% Connections
    Browser -->|"HTTP Request"| Filters
    Filters --> DataAuthFilter
    DataAuthFilter --> DebugFilter
    DebugFilter --> LogsFilter
    LogsFilter --> Controllers
    Controllers --> AlumnoServlet
    Controllers --> AsignaturaServlet
    AlumnoServlet -->|validates| InputValidator
    AsignaturaServlet -->|validates| InputValidator
    AlumnoServlet -->|calls| AlumnoService
    AsignaturaServlet -->|calls| AsignaturaService
    AlumnoService -->|uses| CentroClient
    AsignaturaService -->|uses| CentroClient
    CentroClient -->|HTTP/JSON| ExternalCentro
    Controllers -->|renders| indexJSP
    Controllers -->|renders| loginJSP
    AlumnoServlet -->|renders| perfilAlumnoJSP
    AsignaturaServlet -->|renders| infoAsignaturaJSP
    Controllers -->|renders| error401JSP
    Controllers -->|renders| error404JSP
    CSS -->|served by| Browser
    JS -->|served by| Browser
    IMG -->|served by| Browser
    INCLUDES -->|served by| Browser
    script -.->|startup| Filters
    readme -.->|documentation| script

    %% Click Events
    click CSS "https://github.com/nicomargo/centroeducativodew/tree/main/NOL/src/main/webapp/css/"
    click JS "https://github.com/nicomargo/centroeducativodew/tree/main/NOL/src/main/webapp/js/"
    click IMG "https://github.com/nicomargo/centroeducativodew/tree/main/NOL/src/main/webapp/img/"
    click INCLUDES "https://github.com/nicomargo/centroeducativodew/tree/main/NOL/src/main/webapp/includes/"
    click indexJSP "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/index.jsp"
    click loginJSP "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/login.jsp"
    click perfilAlumnoJSP "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/alumno/perfilAlumno.jsp"
    click infoAsignaturaJSP "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/asignatura/infoAsignatura.jsp"
    click error401JSP "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/WEB-INF/jsp/error401.jsp"
    click error404JSP "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/WEB-INF/jsp/error404.jsp"
    click webXml "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/WEB-INF/web.xml"
    click credsProp "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/webapp/WEB-INF/credentials.properties"
    click DataAuthFilter "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/filter/DataAuthFilter.java"
    click DebugFilter "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/filter/DebugFilter.java"
    click LogsFilter "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/filter/LogsFilter.java"
    click AlumnoServlet "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/main/AlumnoServlet.java"
    click AsignaturaServlet "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/main/AsignaturaServlet.java"
    click AlumnoService "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/service/AlumnoService.java"
    click AsignaturaService "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/service/AsignaturaService.java"
    click CentroClient "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/service/CentroClient.java"
    click InputValidator "https://github.com/nicomargo/centroeducativodew/blob/main/NOL/src/main/java/dew/helper/InputValidator.java"
    click script "https://github.com/nicomargo/centroeducativodew/blob/main/scriptCragarDatosLanzaAplicacion.sh"
    click readme "https://github.com/nicomargo/centroeducativodew/blob/main/README.md"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#21618C,color:#1B2631;
    classDef web fill:#ABEBC6,stroke:#229954,color:#1B2631;
    classDef business fill:#F9E79F,stroke:#D4AC0D,color:#1B2631;
    classDef integration fill:#D7BDE2,stroke:#8E44AD,color:#1B2631;
    classDef external fill:#AAB7B8,stroke:#566573,color:#1B2631;
    classDef misc fill:#F5CBA7,stroke:#B9770E,color:#1B2631;
```
