# ssg192/sistemasismos architecture

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

## Overview

##### Main Components
- Frontend: This is located in the “Desarrollo/Front” directory. It is a React-based application (with App.jsx, App.js, and MapaMexico.jsx) and uses an Nginx configuration for serving static assets. It interacts with the backend via HTTP requests.
- Backend: Found in “Desarrollo/Back/sismos”, this backend service is built using Java with Maven, Quarkus, and follows an MVC/microservices-style architecture. Within its package structure (mx.com.escom.sismos), it separates core business logic, REST controllers (SismoController), persistence (JPA with SismoDao, SismoJpaRepository), and utility components (state machine, error handling).

##### Relationships and Interactions
- The Backend connects to the Database by executing SQL scripts and using JPA/Hibernate to persist and retrieve data concerning seismic events.
- Docker Compose orchestrates the containers—likely one for the frontend, one for the backend, and one for the database—so include that as the deployment/operational layer.

##### Architectural Patterns and Key Technologies
- Layered Architecture: Break the backend into layers such as the REST Controller layer, service (business logic) layer, and persistence (repository/DAO) layer.
- Use of Quarkus: Emphasize that the backend is built with Quarkus and related technologies (JPA, Hibernate, RESTEasy Reactive).
- State Machine Integration: Show that the backend includes a state machine module for handling the lifecycle of seismic events.
- Docker Containers: The presence of multiple Dockerfiles (for frontend and backend) and a docker-compose.yml suggest containerization and orchestration.
- Frontend Framework: React is used for the client-side application, which is complemented by an Nginx server for static content.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-Level User
    U["User Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (React + Nginx) (Port 3000)"]:::frontend
        FE_AppJSX["App.jsx"]:::frontendFile
        FE_AppJS["src/App.js"]:::frontendFile
        FE_Mapa["src/MapaMexico.jsx"]:::frontendFile
        FE_Nginx["nginx.conf"]:::frontendFile
        FE_Docker["Dockerfile"]:::dockerFile
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend (Quarkus App) (Port 9090)"]:::backend
        BE_RC["REST API Controller (SismoController)"]:::backendFile
        BE_BS["Business Logic (SismoBs)"]:::backendFile
        BE_SM1["StateMachine (mx.com.escom.sismos)"]:::backendFile
        BE_SM2["StateMachine (mx.com.escom.util)"]:::backendFile
        BE_DAO["JPA/DAO (SismoDao)"]:::backendFile
        BE_JPA["JPA Repository (SismoJpaRepository)"]:::backendFile
        BE_EH["Error Handling Utilities"]:::backendFile
        BE_Docker["Dockerfile"]:::dockerFile
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["SQL Database (Earthquake Data)"]:::database
        DB_Placas["placas_tectonicas.sql"]:::databaseFile
        DB_Registros["registros_sismos.sql"]:::databaseFile
        DB_Diag["Diagrama"]:::databaseFile
    end

    %% Deployment Layer (Docker Compose)
    subgraph "Deployment (Docker Compose)"
        DC_FE["Frontend Container"]:::docker
        DC_BE["Backend Container"]:::docker
        DC_DB["Database Container"]:::docker
    end

    %% Interactions and Data Flow
    U -->|"HTTP_REQUEST"| FE
    FE -->|"API_CALL"| BE
    BE -->|"PERSISTENCE"| DB

    %% Internal Frontend Connections
    FE --- FE_AppJSX
    FE --- FE_AppJS
    FE --- FE_Mapa
    FE --- FE_Nginx
    FE --- FE_Docker

    %% Internal Backend Connections
    BE --- BE_RC
    BE --- BE_BS
    BE --- BE_Docker
    BE_RC -->|"delegates"| BE_BS
    BE_BS -->|"uses"| BE_SM1
    BE_BS -->|"uses"| BE_SM2
    BE_BS -->|"persists"| BE_DAO
    BE_DAO -->|"via"| BE_JPA
    BE_BS -->|"handlesErrors"| BE_EH

    %% Internal Database Connections
    DB --- DB_Placas
    DB --- DB_Registros
    DB --- DB_Diag

    %% Deployment to Components Connections
    DC_FE --> FE
    DC_BE --> BE
    DC_DB --> DB

    %% Click Events for Frontend Components
    click FE "https://github.com/ssg192/sistemasismos/tree/main/Desarrollo/Front"
    click FE_AppJSX "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Front/App.jsx"
    click FE_AppJS "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Front/src/App.js"
    click FE_Mapa "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Front/src/MapaMexico.jsx"
    click FE_Nginx "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Front/nginx.conf"
    click FE_Docker "https://github.com/ssg192/sistemasismos/tree/main/Desarrollo/Front/Dockerfile"

    %% Click Events for Backend Components
    click BE_RC "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Back/sismos/src/main/java/mx/com/escom/sismos/external/rest/controller/SismoController.java"
    click BE_BS "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Back/sismos/src/main/java/mx/com/escom/sismos/core/business/implementation/SismoBs.java"
    click BE_SM1 "https://github.com/ssg192/sistemasismos/tree/main/Desarrollo/Back/sismos/src/main/java/mx/com/escom/sismos/core/statemachine"
    click BE_SM2 "https://github.com/ssg192/sistemasismos/tree/main/Desarrollo/Back/sismos/src/main/java/mx/com/escom/util/statemachine"
    click BE_DAO "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Back/sismos/src/main/java/mx/com/escom/sismos/external/jpa/dao/SismoDao.java"
    click BE_JPA "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Back/sismos/src/main/java/mx/com/escom/sismos/external/jpa/repository/SismoJpaRepository.java"
    click BE_EH "https://github.com/ssg192/sistemasismos/tree/main/Desarrollo/Back/sismos/src/main/java/mx/com/escom/util/error/"
    click BE_Docker "https://github.com/ssg192/sistemasismos/tree/main/Desarrollo/Back/sismos/Dockerfile"

    %% Click Events for Database Components
    click DB_Placas "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Base de datos/scripts/placas_tectonicas.sql"
    click DB_Registros "https://github.com/ssg192/sistemasismos/blob/main/Desarrollo/Base de datos/scripts/registros_sismos.sql"
    click DB_Diag "https://github.com/ssg192/sistemasismos/tree/main/Desarrollo/Base de datos/diagrama"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef frontend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef frontendFile fill:#ccf,stroke:#333,stroke-width:1px,font-size:12px;
    classDef backend fill:#fbf,stroke:#333,stroke-width:2px;
    classDef backendFile fill:#fdd,stroke:#333,stroke-width:1px,font-size:12px;
    classDef database fill:#dfd,stroke:#333,stroke-width:2px;
    classDef databaseFile fill:#cfc,stroke:#333,stroke-width:1px,font-size:12px;
    classDef docker fill:#ffd,stroke:#333,stroke-width:2px;
    classDef dockerFile fill:#fee,stroke:#333,stroke-width:1px,font-size:12px;
```
