# diegotorresmijarra/tfg-jaimelozano-diegotorres architecture

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

- Interactive diagram: https://gitdiagram.com/diegotorresmijarra/tfg-jaimelozano-diegotorres
- Repository: https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres

## Overview

##### Project Type and Its Purpose
- This project is a full-stack application designed for managing online stores (Bio-Online). It contains a back-end built with Spring Boot (Java/Maven), a front-end built with Angular and Ionic, and it uses PostgreSQL and MongoDB for data persistence. The README also clearly explains that the application supports secure data handling, JWT security, and real-time notifications (e.g., web sockets) for tasks such as order updates, while also being containerized with Docker.

##### File Structure
- There are two top-level application folders: “backApp” and “frontApp.”
- The backApp folder follows a standard Spring Boot project structure with layers such as controllers (REST endpoints), services, repositories, models, DTOs, mappers, and configuration classes (security, CORS, Swagger, WebSocket). It also includes unit test folders.
- The frontApp folder contains an Angular/Ionic project (pages, components, services, models, guards, pipes) that interfaces with the back-end API.
- There are Dockerfiles and docker-compose files—one for back-end/database development, and another for production deployment. This indicates containerization of both the application and its databases.
- Additional directories like “database” and “documentacion” provide scripts and manuals/documentation that support deployment and maintenance.

##### Main Components
a. Front-end Client:
- Client Users: Representing web and mobile users.
- Angular/Ionic Application: Highlight the components (header, footer, views/pages, services, interceptors, routing).
b. Back-end Server:
- API Gateway/Controller Layer: Handling incoming HTTP requests, REST endpoints grouped in modules (addresses, auth, orders, products, restaurants, evaluations, etc.).
- Service & Business Logic Layer: Handling the core business logic (e.g., authentication, data processing, order management).
- Data Access Layer: Repositories, mappers, and integration with databases.
- Security & WebSocket Modules: JWT security, filters, and web socket handlers for live notifications.
- Configuration & Infrastructure: Swagger configuration, CORS, environment variables, and Docker integration.
c. Databases:
- PostgreSQL: Used for primary relational data (likely for orders, products, users, etc.).
- MongoDB: Also referenced in some service layers (possibly for non-relational data, like logging, caching, or common repository implementations).
d. External/Supporting Services:
- Docker Containers: Representing deployment units for back-end, front-end, and databases.
- External API/CI/CD Integrations: Including GitFlow for branching management and deployment automation.

##### Relationships and Interactions
- The Front-end interacts with the Back-end via RESTful API calls (secured using JWT tokens), as shown by the controllers and service endpoints.
- The Back-end communicates with both PostgreSQL and MongoDB databases for data operations.
- WebSockets in the back-end allow real-time communication (for instance, notifications of order status) with the front-end.
- Docker Compose orchestrates these services in a containerized environment, where Dockerfiles indicate isolated containers for each major component.
- Additionally, external security (authentication and authorization) is embedded into the interactions for safe data exchange.

##### Architectural Patterns/Design Principles
- Three-layer architecture: UI (Front-end), Business Logic (Back-end with well-structured RESTful controllers, services, and repositories), and Data Access (databases).
- Separation of concerns: The back-end is divided into modules (auth, addresses, orders, offers, etc.), each managing its request/response cycle, error handling, and data mapping.
- Containerization and orchestration: The use of Dockerfiles and docker-compose for development and production environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Front-end (Angular/Ionic)"]
    end

    %% Back-end Layer
    subgraph "Back-end (Spring Boot)"
        BECont["Back-end Container"]
        
        subgraph "API Controllers"
            Addr["Addresses Module"]
            Auth["Authentication Module"]
            Cat["Category Module"]
            Eval["Evaluation Module"]
            Offr["Offers Module"]
            Ord["Orders Module"]
            Prod["Products Module"]
            Rest["Restaurants Module"]
            UserCtrl["User Module"]
        end

        subgraph "Service Layer"
            AuthSvc["Authentication Services"]
            OtherSvc["Other Services"]
        end

        subgraph "Security & WebSocket"
            SecCfg["Security Configuration"]
            JwtFilt["JWT Authentication Filter"]
            WsMod["WebSocket Module"]
        end

        subgraph "Data Access"
            Repos["Repositories"]
        end
    end

    %% Databases
    subgraph "Databases"
        Postgres["PostgreSQL Database"]
        Mongo["MongoDB Database"]
    end

    %% Containerization & Support
    subgraph "Containerization & Support"
        DockerFE["Dockerfile (Front-end)"]
        DockerBE["Dockerfile (Back-end)"]
        DockerComposeDB["Docker Compose (DB)"]
        DockerComposeProd["Docker Compose (Prod)"]
        DBScripts["Back-end Database Scripts"]
        AddDBScripts["Additional DB Scripts"]
        Docs["Project Documentation"]
    end

    %% Connections from Frontend to API Controllers (REST calls)
    FE -->|"HTTP"| Auth
    FE -->|"HTTP"| Addr
    FE -->|"HTTP"| Cat
    FE -->|"HTTP"| Eval
    FE -->|"HTTP"| Offr
    FE -->|"HTTP"| Ord
    FE -->|"HTTP"| Prod
    FE -->|"HTTP"| Rest
    FE -->|"HTTP"| UserCtrl

    %% Connections from API Controllers to Service Layer
    Auth ---|"calls"| AuthSvc
    Addr ---|"calls"| OtherSvc
    Cat ---|"calls"| OtherSvc
    Eval ---|"calls"| OtherSvc
    Offr ---|"calls"| OtherSvc
    Ord ---|"calls"| OtherSvc
    Prod ---|"calls"| OtherSvc
    Rest ---|"calls"| OtherSvc
    UserCtrl ---|"calls"| OtherSvc

    %% Services to Data Access and Databases
    AuthSvc ---|"data_ops"| Repos
    OtherSvc ---|"data_ops"| Repos
    AuthSvc ---|"DB_ops"| Postgres
    AuthSvc ---|"DB_ops"| Mongo
    OtherSvc ---|"DB_ops"| Postgres
    OtherSvc ---|"DB_ops"| Mongo
    Repos ---|"persists"| Postgres
    Repos ---|"persists"| Mongo

    %% Security configuration affecting Controllers
    SecCfg ---|"secures"| Auth
    SecCfg ---|"secures"| Addr
    SecCfg ---|"secures"| Cat
    SecCfg ---|"secures"| Eval
    SecCfg ---|"secures"| Offr
    SecCfg ---|"secures"| Ord
    SecCfg ---|"secures"| Prod
    SecCfg ---|"secures"| Rest
    SecCfg ---|"secures"| UserCtrl

    %% JWT Filter applied to Authentication Module (example)
    JwtFilt ---|"filters"| Auth

    %% WebSocket bi-directional communication with Frontend
    FE <==>|"RealTime_WS"| WsMod

    %% Containerization orchestration connections
    DockerFE ---|"builds"| FE
    DockerBE ---|"builds"| BECont
    DockerComposeProd ---|"orchestrates"| FE
    DockerComposeProd ---|"orchestrates"| BECont
    DockerComposeProd ---|"orchestrates"| Postgres
    DockerComposeProd ---|"orchestrates"| Mongo

    %% Support scripts connection (indicative)
    BECont ---|"init_scripts"| DBScripts

    %% Click Events
    click FE "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/frontApp"
    click BECont "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp"
    click Addr "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/addresses"
    click Auth "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/auth"
    click Cat "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/category"
    click Eval "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/evaluation"
    click Offr "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/offers"
    click Ord "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/orders"
    click Prod "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/products"
    click Rest "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/restaurants"
    click UserCtrl "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/user"
    click AuthSvc "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/rest/auth/service"
    click SecCfg "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/blob/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/config/auth/SecurityConfig.java"
    click JwtFilt "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/blob/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/interceptors/JwtAuthenticationFilter.java"
    click WsMod "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/src/main/java/es/jaimelozanodiegotorres/backapp/config/websocket"
    click DockerFE "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/frontApp/Dockerfile"
    click DockerBE "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/Dockerfile"
    click DockerComposeDB "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/blob/master/backApp/docker-compose-db.yaml"
    click DockerComposeProd "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/blob/master/docker-compose.yaml"
    click DBScripts "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/backApp/database"
    click AddDBScripts "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/database"
    click Docs "https://github.com/diegotorresmijarra/tfg-jaimelozano-diegotorres/tree/master/documentacion"

    %% Styles
    classDef frontend fill:#ccf,stroke:#000,stroke-width:2px;
    classDef backend fill:#fbb,stroke:#000,stroke-width:2px;
    classDef database fill:#bfb,stroke:#000,stroke-width:2px;
    classDef container fill:#ddd,stroke:#000,stroke-width:2px;

    class FE,DockerFE frontend;
    class BECont,Addr,Auth,Cat,Eval,Offr,Ord,Prod,Rest,UserCtrl,AuthSvc,OtherSvc,SecCfg,JwtFilt,WsMod,Repos backend;
    class Postgres,Mongo database;
    class DockerBE,DockerComposeDB,DockerComposeProd,DBScripts,AddDBScripts,Docs container
```
