# proyectoxacademy/incubadoranoc architecture

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

- Interactive diagram: https://gitdiagram.com/proyectoxacademy/incubadoranoc
- Repository: https://github.com/proyectoxacademy/incubadoranoc

## Overview

##### Main Components
- Frontend Application (Angular):
– Represents the client-side layer.
– Contains multiple modules and components (views, core components like header, footer, sidebar, and specific pages such as login, dashboard, courses, registrations, etc.).
– Uses Angular services to handle API calls.
- Backend API (Node.js/Express):
– Organized into several directories: Config (for database and passport configurations), Controllers (handling requests and responses), Routes (defining API endpoints), Models (defining the data schema), Services (business logic and utilities like hashing passwords), and Middlewares (authentication, error handling).
– Implements RESTful endpoints for resources such as users, roles, courses, registrations, payments, and content.
– Uses token-based authentication (with Passport, as seen in the passportConfig.js, and auth middleware) to secure the endpoints.
- Data Storage (Database):
– Although the exact type isn’t specified explicitly in the file tree, the presence of dbConfig.js indicates the existence of a database configuration. It should be represented as the persistent storage layer.
- Testing Framework:
– The Cypress-based tests in the “testing” directory are key to verifying the end-to-end functionality of the system.
- Documentation and API Specs:
– Swagger documentation is mentioned (http://localhost:3000/api-docs/#/); this should be represented as part of the backend documentation and interface for API consumers.

##### Relationships and Interactions
- The Frontend Angular Application communicates with the Backend API endpoints using HTTP calls (GET/POST/PUT/DELETE).
- The Backend’s Routes layer directs incoming requests to the appropriate Controllers.
- Controllers call Services to process the business logic.
- Services interact with Models to retrieve or update data from the Database.
- Middlewares (authentication and error handlers) are applied to secure and manage requests/responses.
- External documentation (Swagger) is used for API testing and integration.
- The Cypress tests simulate real user interactions and ensure that the integration between frontend and backend works as expected.

##### Architectural Patterns and Technologies
- MVC-like Pattern in the backend: Routes/Controllers/Models.
- RESTful API design: Multiple endpoints are provided for standard CRUD operations.
- Token-based authentication: Require a token after login to access further functionalities.
- Angular structure for the frontend: Modules/Components/Services, aligning with a component-based architecture.
- Layered testing strategy using Cypress for E2E tests.

##### Final Elements
- Clear and concise labels for every component.
- Annotations for external systems like API documentation (Swagger) and testing (Cypress).

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer (Angular)"
        FE["Angular Frontend"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        BAPI["Backend API"]:::backend
        subgraph "Backend Components"
            direction TB
            CONF["Configurations"]:::config
            ROUTES["Routes"]:::routes
            MIDDLE["Middlewares (Auth,Error)"]:::middleware
            CTLR["Controllers"]:::controller
            SRV["Services"]:::service
            MODELS["Models"]:::model
        end
    end

    %% Data Storage and External Tools
    DB(("Database")):::database
    SWAGGER["Swagger API Docs"]:::documentation
    CYPRESS["Cypress E2E Tests"]:::testing

    %% Connections between Frontend and Backend
    FE -->|"HTTPCalls(withToken)"| BAPI
    BAPI -->|"ForwardsRequest"| ROUTES

    %% Internal Backend Flow
    ROUTES -->|"Intercepts"| MIDDLE
    MIDDLE -->|"Validates"| CTLR
    ROUTES -->|"RoutesDirectly(forLogin)"| CTLR
    CTLR -->|"Invokes"| SRV
    SRV -->|"OperatesOn"| MODELS
    MODELS -->|"CRUD"| DB
    DB -->|"ReturnsData"| MODELS
    MODELS -->|"PassesData"| SRV
    SRV -->|"SendsResponse"| CTLR
    CTLR -->|"SendsResponse"| ROUTES
    ROUTES -->|"ReturnsTo"| BAPI
    BAPI -->|"SendsResponse"| FE

    %% External Tools and Annotations
    FE ---|"LoginReturnsToken"| ROUTES
    ROUTES -->|"ExposesAPI"| SWAGGER
    CYPRESS -->|"TestsFrontendBackend"| FE
    CYPRESS -->|"TestsFrontendBackend"| ROUTES

    %% Click Events
    click FE "https://github.com/proyectoxacademy/incubadoranoc/tree/main/front/src/app"
    click BAPI "https://github.com/proyectoxacademy/incubadoranoc/tree/main/back"
    click CONF "https://github.com/proyectoxacademy/incubadoranoc/tree/main/back/Config"
    click ROUTES "https://github.com/proyectoxacademy/incubadoranoc/tree/main/back/Routes"
    click CTLR "https://github.com/proyectoxacademy/incubadoranoc/tree/main/back/Controllers"
    click SRV "https://github.com/proyectoxacademy/incubadoranoc/tree/main/back/Services"
    click MODELS "https://github.com/proyectoxacademy/incubadoranoc/tree/main/back/Models"
    click MIDDLE "https://github.com/proyectoxacademy/incubadoranoc/tree/main/back/Middlewares"
    click CYPRESS "https://github.com/proyectoxacademy/incubadoranoc/tree/main/testing/cypress/e2e"

    %% Styles
    classDef frontend fill:#C2E7FF,stroke:#1B69C6,stroke-width:2px;
    classDef backend fill:#E0F7FA,stroke:#00ACC1,stroke-width:2px;
    classDef config fill:#FFF3CD,stroke:#CCA43B,stroke-width:2px;
    classDef routes fill:#D1E7DD,stroke:#0DA886,stroke-width:2px;
    classDef middleware fill:#F8D7DA,stroke:#C82333,stroke-width:2px;
    classDef controller fill:#E2E3E5,stroke:#6C757D,stroke-width:2px;
    classDef service fill:#D1C4E9,stroke:#6A1B9A,stroke-width:2px;
    classDef model fill:#FCEBC4,stroke:#F0AD4E,stroke-width:2px;
    classDef database fill:#FFFFFF,stroke:#343A40,stroke-width:2px,stroke-dasharray: 5 5;
    classDef documentation fill:#E8F0FE,stroke:#4285F4,stroke-width:2px;
    classDef testing fill:#DFF0D8,stroke:#3C763D,stroke-width:2px;
```
