# x1n4px/astrouma architecture

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

- Interactive diagram: https://gitdiagram.com/x1n4px/astrouma
- Repository: https://github.com/x1n4px/astrouma

## Overview

##### Main Components
- Frontend: A React application that includes pages, components (charts, maps, modals, layout, etc.), services, and configuration files. The structure segregates view components (e.g., pages for dashboard, authentication, astronomy reports) and service modules that interact with the backend.
- Backend: A Node.js API structured in several directories:
– Controllers: Handling specific request logic (e.g., activeShowerController, authController, etc.).
– Routes: Defining the endpoints for each of the controllers.
– Middlewares: Functions for handling JWT extraction, coordinate conversion, and validation.
– Database: A dedicated module for the MariaDB connection.
– Entry point (index.ts): Bootstraps the API.
- Database: MariaDB that stores meteor shower data.
- Auxiliary/Legacy Files: Additional directories (e.g., TFG_2022, Informes_Ejemplo, aux) that provide example data, reports, or legacy information. While not core to the online architecture, they might be referenced or used for testing/demo data.

##### Relationships and Data Flow
- Users access the application through a web browser, which loads the React frontend.
- The Frontend components make HTTP/HTTPS API calls (using the service modules like authService, stationService, etc.) to the Backend.
- The Backend handles incoming API calls—routing them through its routers, processing via controllers (with middleware assistance where needed for tasks like JWT validation), and finally interacting with the MariaDB database to query or update data.
- The responses flow back to the frontend, where data visualization components (charts, maps, etc.) render the results.
- Optionally, include any interactions with static reporting files or legacy modules that might support additional functionalities.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly split into Frontend and Backend. In the backend, the use of controllers, routes, and middlewares follows an MVC-like pattern.
- Modularity: Both the frontend and backend are organized into reusable modules/components. Services in the frontend abstract API calls, while the backend’s folder structure promotes modular API creation.
- Scalability and Maintainability: Configuration files (like package.json, vercel.json) and clear separation of service logic ensure that the project can scale and evolve.

##### Specify the Relevant Technologies and Tools
- Frontend: React, React Router, various chart and visualization libraries (as visible from the “chart” components like BarChart, LineChart, etc.), and configuration tools for localization and ESLint.
- Backend: Node.js, Express (or similar), TypeScript (given the index.ts file), a set of custom middlewares, and a MariaDB connector.
- Database: MariaDB, as specified in the README.
- Deployment/Integration: Vercel configuration indicates potential cloud deployment; version control is set up via Git.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    UB["User Browser"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        FR["Frontend React Application"]:::frontend
        PC["Pages"]:::frontend
        CP["Components"]:::frontend
        SM["Service Modules"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API Layer"
        EP["Entry Point (index.ts)"]:::backend
        RT["API Routes"]:::backend
        MD["Middlewares"]:::middleware
        MC["API Controllers"]:::backend
        DB["MariaDB Database"]:::database
    end

    %% Auxiliary / Legacy Files
    subgraph "Auxiliary/Legacy Files"
        INF["Informes_Ejemplo"]:::auxiliary
        TFG["TFG_2022"]:::auxiliary
        AUX["aux"]:::auxiliary
    end

    %% Data Flow Connections
    UB -->|"loads"| FR
    FR -->|"includes"| PC
    FR -->|"includes"| CP
    FR -->|"bundles"| SM
    SM -->|"calls"| RT
    EP -->|"bootstraps"| RT
    RT -->|"executes"| MD
    MD -->|"processes"| MC
    MC -->|"queries/updates"| DB
    DB -->|"returns data to"| MC
    MC -->|"responds via"| RT
    RT -->|"sends responses to"| SM

    %% Optional connection to auxiliary files (legacy/sample data)
    INF ---|"provides sample data"| MC
    TFG ---|"contains legacy reports"| MC
    AUX ---|"supports testing"| SM

    %% Click Events for Frontend
    click FR "https://github.com/x1n4px/astrouma/tree/main/Frontend"
    click PC "https://github.com/x1n4px/astrouma/tree/main/Frontend/src/pages"
    click CP "https://github.com/x1n4px/astrouma/tree/main/Frontend/src/components"
    click SM "https://github.com/x1n4px/astrouma/tree/main/Frontend/src/services"

    %% Click Events for Backend
    click EP "https://github.com/x1n4px/astrouma/blob/main/Backend/api/index.ts"
    click RT "https://github.com/x1n4px/astrouma/tree/main/Backend/api/routes"
    click MC "https://github.com/x1n4px/astrouma/tree/main/Backend/api/controllers"
    click MD "https://github.com/x1n4px/astrouma/tree/main/Backend/api/middlewares"
    click DB "https://github.com/x1n4px/astrouma/blob/main/Backend/api/database/connection.js"

    %% Click Events for Auxiliary/Legacy Files
    click INF "https://github.com/x1n4px/astrouma/tree/main/Informes_Ejemplo"
    click TFG "https://github.com/x1n4px/astrouma/tree/main/TFG_2022"
    click AUX "https://github.com/x1n4px/astrouma/tree/main/aux"

    %% Styles
    classDef user stroke:#333,fill:#f9f,stroke-width:2px;
    classDef frontend stroke:#1f77b4,fill:#c6dbef,stroke-width:2px;
    classDef backend stroke:#ff7f0e,fill:#fdd0a2,stroke-width:2px;
    classDef middleware stroke:#2ca02c,fill:#ccebc5,stroke-width:2px;
    classDef database stroke:#d62728,fill:#fbb4ae,stroke-width:2px;
    classDef auxiliary stroke:#8c564b,fill:#f7c6b8,stroke-width:2px;
```
