# panchoalenda/clinica architecture

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

- Interactive diagram: https://gitdiagram.com/panchoalenda/clinica
- Repository: https://github.com/panchoalenda/clinica

## Overview

##### Project’s Main Components
- Frontend – Built with React (using Vite for bundling) and organized into components, views, routes, context, and styles.
- Backend – A Spring Boot application developed in Java, implementing REST APIs with controllers, services, repositories, and domain models.
- Database – Although not explicitly visible in the file tree, the README indicates the use of MySQL (for production) and H2 (for development/testing).
- External Services/Documentation – Swagger API documentation and links to QA documentation hint at external integrations and testing adjuncts.

##### Out the Architectural Structure
a. For the Backend:
- A layered architecture:
- Controllers (“controladores”): e.g., AdminController, AppointmentController, DoctorController, etc.
- Services: Business logic and service implementations (e.g., AppointmentService, AdminService).
- Repositories: Data access layer interfacing with the database (e.g., AppointmentRepository, DoctorRepository).
- Domain Models: The Java classes under “models” (Appointment, Doctor, Patient, etc.) that represent the entities.
- Utility and Request/Response Models: Classes in "models/request" and "models/response" that structure the API’s communications.
- A representation of the configuration (i.e., application.properties) which handles settings such as server port and datasource credentials.

b. For the Frontend:
- Main parts such as:
- Pages/Views: Login, Administrar (administration of doctors, patients, secretaries), Busqueda (search functionalities), Turnos (appointments management).
- Components: Navigation bars (NavBar, NavBarLanding), Banner, Search components, etc.
- Context/Data Provider: e.g., UserContext for state management.
- Routing: Managed via route configuration (e.g., UserRoute.jsx).
- How the Frontend makes API calls to the Backend’s endpoints.

##### Relationships and Interactions
- Frontend sends HTTP requests (via the HttpClient in data/HttpClient.jsx) to the backend.
- Backend Controllers receive these requests and delegate to appropriate Services.
- Services interact with Repositories to fetch or persist data in the Database.
- Responses are then sent back through the API to the Frontend.
- If needed, annotate components that handle authentication (for admin login) as indicated in the README.

##### Architectural Patterns and Technologies
- The Backend follows a typical Spring Boot layered architecture (Controller-Service-Repository pattern).
- The separation of concerns is maintained (e.g., separate modules for administration, search, appointments).
- The Frontend emphasizes component-based UI design adherent to modern React practices.
- Notes about RESTful APIs and usage of Swagger for backend documentation.
- Mention that testing is also part of the process (e.g., “src/test” in the backend), although not a primary component in the final design.

##### Elements
- Clear labels for each component (e.g., “DoctorController”, “DoctorService”, “Doctor Repository” or “React NavBar Component”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend"
        FE1["React Application"]
        FE2["Components (Navigation, Banner, Search, TurnoSearch)"]
        FE3["Views/Pages (Login, Administrar, Buscar, Turnos, Landing, Info)"]
        FE4["Routing (UserRoute.jsx)"]
        FE5["Context (UserContext.jsx)"]
        FE6["HTTP Client (HttpClient.jsx)"]
    end

    %% Backend Processing Subgraph
    subgraph "Backend"
        BE1["Spring Boot Application"]
        BE2["Controllers (Admin, Appointment, Doctor, Patient, Rol, Secretary)"]
        BE3["Services"]
        BE4["Repositories"]
        BE1 -->|"routesRequest"| BE2
        BE2 -->|"callsService"| BE3
        BE3 -->|"queriesRepository"| BE4
        BE4 -->|"accesses"| DB
    end

    %% Backend Models and Configuration Subgraph
    subgraph "Backend Models & Config"
        BE5["Domain Models"]
        BE6["Request Models"]
        BE7["Response Models"]
        BE8["Configuration (application.properties)"]
    end

    %% Database Node
    DB(("Database (MySQL/H2)"))

    %% Data Flow and Interactions
    FE6 -->|"sendsRequest"| BE2
    BE2 -->|"parsesRequest"| BE6
    BE2 -->|"formatsResponse"| BE7
    BE3 -->|"usesModels"| BE5

    %% Styles Definitions
    classDef frontend fill:#cce5ff,stroke:#002752,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef models fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef db fill:#fff3cd,stroke:#856404,stroke-width:2px;

    %% Assign Classes
    class FE1,FE2,FE3,FE4,FE5,FE6 frontend;
    class BE1,BE2,BE3,BE4 backend;
    class BE5,BE6,BE7,BE8 models;
    class DB db;

    %% Click Events for Frontend
    click FE1 "https://github.com/panchoalenda/clinica/tree/main/Frontend/"
    click FE2 "https://github.com/panchoalenda/clinica/tree/main/Frontend/src/components/"
    click FE3 "https://github.com/panchoalenda/clinica/tree/main/Frontend/src/views/"
    click FE4 "https://github.com/panchoalenda/clinica/blob/main/Frontend/src/routes/UserRoute.jsx"
    click FE5 "https://github.com/panchoalenda/clinica/blob/main/Frontend/src/context/UserContext.jsx"
    click FE6 "https://github.com/panchoalenda/clinica/blob/main/Frontend/src/data/HttpClient.jsx"

    %% Click Events for Backend
    click BE1 "https://github.com/panchoalenda/clinica/tree/main/Backend/"
    click BE2 "https://github.com/panchoalenda/clinica/tree/main/Backend/src/main/java/com/medical/app/controladores/"
    click BE3 "https://github.com/panchoalenda/clinica/tree/main/Backend/src/main/java/com/medical/app/services/"
    click BE4 "https://github.com/panchoalenda/clinica/tree/main/Backend/src/main/java/com/medical/app/repository/"
    click BE5 "https://github.com/panchoalenda/clinica/tree/main/Backend/src/main/java/com/medical/app/models/"
    click BE6 "https://github.com/panchoalenda/clinica/tree/main/Backend/src/main/java/com/medical/app/models/request/"
    click BE7 "https://github.com/panchoalenda/clinica/tree/main/Backend/src/main/java/com/medical/app/models/response/"
    click BE8 "https://github.com/panchoalenda/clinica/blob/main/Backend/src/main/resources/application.properties"
```
