# juanluismm521/uja-api architecture

> Architecture diagram of the GitHub repository juanluismm521/uja-api, 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/juanluismm521/uja-api
- Repository: https://github.com/juanluismm521/uja-api

## Overview

##### Main Components
- Client: Represent any consumer (could be a web client or mobile app) making the POST /login requests.
- API Server: This is your Express-based Node.js server (bootstrapped in main.js). It is responsible for receiving requests and orchestrating the scraping process.
- Scraping Module: Although the file tree only shows main.js and gym.js, gym.js is likely a dedicated module that encapsulates the Puppeteer-based scrapping logic from the Platea platform.
- External Platform: The remote UJA Platea system (Platea) where the user data is scraped from.
- Docker: The existence of a Dockerfile indicates that the API server may be containerized for deployment.

##### Relationships and Interactions
- The Client sends a POST request to the API Server’s /login endpoint with user credentials.
- The API Server uses its Express framework to route the request and then calls the scraping module (gym.js).
- The scraping module uses Puppeteer to perform login and data extraction from the external UJA Platea website.
- Once the data is retrieved, the API Server packages the user data into a JSON response, which is then sent back to the Client.
- Optionally, the Docker container (if used) encapsulates the running Node.js API for deployment.

##### Architectural Patterns and Design Principles
- Modularity: Separation between the main server logic (main.js) and the scraping functionality (gym.js).
- Use of third-party libraries: It’s essential to note that Puppeteer (for scraping) and Express (for routing) are at the core of this design.

##### Relevant Technologies
- Node.js as the runtime environment.
- Express as the web framework.
- Puppeteer as the web scraping library.
- Docker (via Dockerfile) for containerization and deployment.
- (Package management) npm, as evident from package.json and package-lock.json.

##### Putting It All Together
- The routing logic handling the /login endpoint.
- The interaction with the scraping module (gym.js).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client (HTTP POST /login)"]:::clientStyle

    Docker["Docker Container"]:::dockerStyle
    API_Server["API Server (Express/Node.js)"]:::serverStyle
    Scraping["Scraping Module (Puppeteer in gym.js)"]:::scrapingStyle
    External["UJA Platea Platform"]:::externalStyle

    subgraph "Dependencies"
        PkgJSON["package.json"]:::pkgStyle
        PkgLock["package-lock.json"]:::pkgStyle
    end

    Client -->|"POST /login"| API_Server
    API_Server -->|"callsGymJS"| Scraping
    Scraping -->|"scrapesData"| External
    External -->|"returnsData"| Scraping
    Scraping -->|"userData"| API_Server
    API_Server -->|"JSONResponse"| Client

    Docker -->|"runs"| API_Server
    API_Server -.->|"npmDepends"| PkgJSON
    API_Server -.->|"npmDepends"| PkgLock

    click API_Server "https://github.com/juanluismm521/uja-api/blob/master/main.js"
    click Scraping "https://github.com/juanluismm521/uja-api/blob/master/gym.js"
    click Docker "https://github.com/juanluismm521/uja-api/tree/master/Dockerfile"
    click PkgJSON "https://github.com/juanluismm521/uja-api/blob/master/package.json"
    click PkgLock "https://github.com/juanluismm521/uja-api/blob/master/package-lock.json"

    classDef clientStyle fill:#cfe2f3,stroke:#6d9eeb,stroke-width:2px;
    classDef dockerStyle fill:#f9cb9c,stroke:#e69138,stroke-width:2px;
    classDef serverStyle fill:#ffe599,stroke:#bf9000,stroke-width:2px;
    classDef scrapingStyle fill:#b6d7a8,stroke:#6aa84f,stroke-width:2px;
    classDef externalStyle fill:#ead1dc,stroke:#b854a6,stroke-width:2px;
    classDef pkgStyle fill:#d9d2e9,stroke:#8e7cc3,stroke-width:2px;
```
