# andresvillamil/api-citas-springboot architecture

> Architecture diagram of the GitHub repository andresvillamil/api-citas-springboot, 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/andresvillamil/api-citas-springboot
- Repository: https://github.com/andresvillamil/api-citas-springboot

## Overview

##### Main Components
- API Layer: This represents the HTTP endpoints and controllers. Include components for CitaController, DoctorController, and PacienteController.
- Service Layer: Show the business logic components (e.g., CitaService, DoctorService, and PacienteService along with their respective implementations). This layer processes incoming requests from the controllers.
- Repository/Data Access Layer: Represent the data access objects like CitaRepository, DoctorRepository, and PacienteRepository that interact with the database (MySQL as suggested by the README).
- Domain/Entities: Display the domain models (e.g., Cita, Doctor, Paciente, including any composite keys such as CitaId) that represent the data structures.
- Database: Although not directly part of the Java code, show the MySQL database interacting primarily with the repository layer.
- Configuration & Resources: Indicate configuration files such as application.properties which control settings for the Spring Boot application.
- Tests: Optionally, include a block for the testing layer (e.g., ApiCitasApplicationTests) to address quality assurance aspects.

##### Relationships and Interactions
- Database (MySQL) as the underlying data store connected to the repositories.
- Optionally, indicate that layers such as configuration and resources (application.properties) influence all layers if needed.

##### Architectural Patterns and Design Principles
- Separation of concerns: each layer has clearly defined responsibilities.
- Mention dependency injection as a key pattern used by Spring Boot, even if it’s abstract, to help illustrate component interactions.

##### Technologies and Frameworks
- Spring Boot: Central to the API implementation.
- MySQL: The chosen relational database for persistent storage.
- Maven: For build and dependency management (the pom.xml and mvnw files indicate Maven is used).
- Additionally, the project includes a testing framework (likely JUnit through the Spring Boot test annotations).

##### Detailing
- Since the project includes directories like Pruebas-api with screenshots, you might also annotate that these are used for testing the API endpoints, which reinforces the separation between the application layers and testing procedures.
- MVC structure provided by the package names under src/main/java/com/citas/apicitas/ (dividing by controllers, entities, repositories, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Client
    Client["REST Client/Postman"]:::client

    %% Configuration & Resources
    CFG["application.properties"]:::config

    %% API Layer (Controllers)
    subgraph "API Layer (Controllers)"
        CT1["CitaController"]:::controller
        CT2["DoctorController"]:::controller
        CT3["PacienteController"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        S1["CitaServiceImpl"]:::service
        S2["DoctorServiceImpl"]:::service
        S3["PacienteServiceImpl"]:::service
    end

    %% Repository/Data Access Layer
    subgraph "Repository Layer"
        R1["CitaRepository"]:::repository
        R2["DoctorRepository"]:::repository
        R3["PacienteRepository"]:::repository
    end

    %% Domain / Entities
    subgraph "Domain/Entities"
        E1["Cita & CitaId"]:::entity
        E2["Doctor"]:::entity
        E3["Paciente"]:::entity
    end

    %% Exception Handling
    subgraph "Exception Handling"
        EX1["ControllerExceptionHandler"]:::exception
        EX2["ErrorMessage"]:::exception
        EX3["ResourceNotFoundException"]:::exception
    end

    %% Database
    DB["MySQL Database"]:::database

    %% Testing Layer
    subgraph "Testing & QA"
        TEST["ApiCitasApplicationTests"]:::test
    end

    %% Additional API Testing Documents
    subgraph "API Testing Documents"
        API_T1["Pruebas-api/Citas"]:::test
        API_T2["Pruebas-api/Doctores"]:::test
        API_T3["Pruebas-api/Pacientes"]:::test
    end

    %% Connections
    Client --> CT1
    Client --> CT2
    Client --> CT3

    CT1 -->|"calls"| S1
    CT2 -->|"calls"| S2
    CT3 -->|"calls"| S3

    S1 -->|"accesses"| R1
    S2 -->|"accesses"| R2
    S3 -->|"accesses"| R3

    R1 -->|"reads/writes"| DB
    R2 -->|"reads/writes"| DB
    R3 -->|"reads/writes"| DB

    %% Exception Handling Flow
    CT1 ---|"error"| EX1
    CT2 ---|"error"| EX1
    CT3 ---|"error"| EX1
    EX1 ---|"error-response"| Client

    %% Influence of Configuration
    CFG -.->|"configures"| CT1
    CFG -.->|"configures"| S1
    CFG -.->|"configures"| R1
    CFG -.->|"configures"| DB

    %% Testing Flow (QA)
    TEST ---|"validates"| Client

    %% Styles
    classDef controller fill:#F8C,stroke:#333,stroke-width:2px;
    classDef service fill:#CCF,stroke:#333,stroke-width:2px;
    classDef repository fill:#CFC,stroke:#333,stroke-width:2px;
    classDef entity fill:#FCF,stroke:#333,stroke-width:2px;
    classDef exception fill:#FCC,stroke:#333,stroke-width:2px;
    classDef database fill:#F96,stroke:#333,stroke-width:2px;
    classDef config fill:#9CF,stroke:#333,stroke-width:2px;
    classDef test fill:#9F9,stroke:#333,stroke-width:2px;
    classDef client fill:#FFCC00,stroke:#333,stroke-width:2px;

    %% Click Events for API Layer (Controllers)
    click CT1 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/controllers/CitaController.java"
    click CT2 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/controllers/DoctorController.java"
    click CT3 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/controllers/PacienteController.java"

    %% Click Events for Service Layer
    click S1 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/services/CitaServiceImpl.java"
    click S2 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/services/DoctorServiceImpl.java"
    click S3 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/services/PacienteServiceImpl.java"

    %% Click Events for Repository Layer
    click R1 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/repositories/CitaRepository.java"
    click R2 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/repositories/DoctorRepository.java"
    click R3 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/repositories/PacienteRepository.java"

    %% Click Events for Domain/Entities
    click E1 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/entities/Cita.java"
    click E2 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/entities/Doctor.java"
    click E3 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/entities/Paciente.java"

    %% Click Events for Exception Handling
    click EX1 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/exceptions/ControllerExceptionHandler.java"
    click EX2 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/exceptions/ErrorMessage.java"
    click EX3 "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/java/com/citas/apicitas/exceptions/ResourceNotFoundException.java"

    %% Click Event for Configuration
    click CFG "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/main/resources/application.properties"

    %% Click Events for Testing Layer
    click TEST "https://github.com/andresvillamil/api-citas-springboot/blob/main/src/test/java/com/citas/apicitas/ApiCitasApplicationTests.java"

    %% Click Events for API Testing Documents
    click API_T1 "https://github.com/andresvillamil/api-citas-springboot/tree/main/Pruebas-api/Citas"
    click API_T2 "https://github.com/andresvillamil/api-citas-springboot/tree/main/Pruebas-api/Doctores"
    click API_T3 "https://github.com/andresvillamil/api-citas-springboot/tree/main/Pruebas-api/Pacientes"
```
