# juanmeza21/gestioncitasventascentrooptico_pdn architecture

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

## Overview

##### Main Components
- Frontend: Represent the React application which includes components for user registration, login, and distinct user views for secretaries and optometrists. Note that components are organized under separate directories (e.g., “optometrist-comp”, “secretary-comp”) to support role-based functionalities.
- Backend: Capture the Spring Boot application with its core packages. In the backend’s Java source, highlight areas like configuration (CORS and Firebase), controllers (for authentication and data handling), and integration with Firebase (for role verification and potentially authentication).
- Database: Include PostgreSQL as the relational data store. Even though the file tree doesn’t show database scripts explicitly, the README indicates that PostgreSQL is the intended database.
- External Services: Include Firebase since the backend configuration and some Java classes reference Firebase (for authentication and retrieving roles). This interaction should be shown as an external dependency that feeds user authentication information.

##### Relationships and Interactions
- The backend processes incoming requests through its controllers (such as AutenticacionController) and interacts with both its configuration components (CORS, Firebase) and the database.
- For data persistence, illustrate a connection between the backend and PostgreSQL to indicate CRUD operations on clients, sales, appointments, and clinical histories.

##### Architectural Patterns and Design Principles
- Layered Architecture: The application clearly follows a separation-of-concerns pattern where the frontend (presentation layer) is decoupled from the backend (business logic layer) and the database (persistence layer).
- RESTful Communication: Emphasize the API layer in the backend which handles RESTful endpoints.
- Security and CORS: Note that the backend includes configuration for CORS and Firebase integration, key aspects for securing and managing cross-origin requests.
- Role-based Functionality: Differentiate routes or application flows for the two system roles (Secretaria and Optómetra).

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: React and Tailwind CSS.
- Backend: Spring Boot (with Java), utilizing Gradle for build automation.
- Database: PostgreSQL.
- External Service: Firebase is used for authentication and role management.
- Additional Configurations: CORS settings are included which are important to note for interoperability between the frontend and backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE1["React Frontend"]:::frontend
        FE2["RegisterAccount Component"]:::frontend
        FE3["Login Component"]:::frontend
        FE4["Optometrist Components"]:::frontend
        FE5["Secretary Components"]:::frontend
    end

    subgraph "Backend Layer"
        BE1["Spring Boot API"]:::backend
        BE2["Authentication Controller"]:::backend
        BE3["CORS Configuration"]:::backend
        BE4["Firebase Configuration"]:::backend
        BE5["Firebase Role Verification"]:::backend
    end

    subgraph "Database Layer"
        DB["PostgreSQL Database"]:::db
    end

    subgraph "External Services"
        EX["Firebase Authentication Service"]:::external
    end

    %% Connections between frontend and backend
    FE1 -->|"RESTAPICall"| BE2
    FE1 -->|"RESTcalls"| BE1

    %% Backend internal relationships
    BE1 -->|"Manages"| BE2
    BE1 -->|"Uses"| BE3
    BE1 -->|"Uses"| BE4
    BE1 -->|"Handles"| BE5

    %% Controller interactions with data and external auth
    BE2 -->|"CRUDoperations"| DB
    BE2 -->|"Auth/RoleCheck"| BE5
    BE5 -->|"Verifies"| EX

    %% Click Events for Frontend
    click FE1 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/tree/master/frontend/"
    click FE2 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/frontend/src/components/RegisterAccount.js"
    click FE3 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/frontend/src/components/login.js"
    click FE4 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/tree/master/frontend/src/components/optometrist-comp/"
    click FE5 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/tree/master/frontend/src/components/secretary-comp/"

    %% Click Events for Backend
    click BE1 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/backend/src/main/java/com/example/backend_GCVCO/BackendGcvcoApplication.java"
    click BE2 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/backend/src/main/java/com/example/backend_GCVCO/Controller/AutenticacionController.java"
    click BE3 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/backend/src/main/java/com/example/backend_GCVCO/Config/CorsConfig.java"
    click BE4 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/backend/src/main/java/com/example/backend_GCVCO/Config/FirebaseConfig.java"
    click BE5 "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/backend/src/main/java/com/example/backend_GCVCO/FirebaseGetRol.java"

    %% Click Events for Database
    click DB "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/backend/src/main/resources/application.properties"
    click DB "https://github.com/juanmeza21/gestioncitasventascentrooptico_pdn/blob/master/docs/backend.md"

    %% Class Definitions for Colors
    classDef frontend fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef backend fill:#FDD,stroke:#333,stroke-width:2px;
    classDef db fill:#CEF,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#FAC,stroke:#333,stroke-width:2px,stroke-dasharray: 2 2;
```
