# diegobustos16/medicaltestvisor architecture

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

- Interactive diagram: https://gitdiagram.com/diegobustos16/medicaltestvisor
- Repository: https://github.com/diegobustos16/medicaltestvisor

## Overview

##### Main components
- API Gateway: Acts as the entry point for client requests and handles routing to the underlying services.
- Config Server: Centralizes externalized configurations for all microservices.
- Discovery Service: Enables dynamic service registration and discovery so that the various microservices can locate each other.
- Domain-Specific Microservices:
- Doctor Microservice
- Hospital Microservice
- Patient Microservice
- Test Microservice
- Client Applications / External Systems (if applicable): Although not immediately apparent in the file tree, these represent the consumers (e.g., clinics, professionals, patients) interacting with the system.
- Docker and Docker Compose: As each microservice contains its own Dockerfile and there is a docker-compose.yml, containerization and orchestration are also part of the system.

##### Relationships and interactions
- The API Gateway receives incoming requests from client applications and forwards them to the appropriate microservice.
- Before handling any request, services fetch their configuration data from the Config Server to ensure they are running with the up-to-date settings.
- The Discovery Service registers each microservice, and the API Gateway uses this registry for routing. Similarly, services may use discovery to communicate internally or via Feign clients (as indicated in some microservices).
- Communication between microservices may happen either synchronously (e.g., REST calls) or asynchronously as required.
- Each microservice uses its own database layer (repository, entity, service layers) to manage specific domain data.

##### Architectural patterns or design principles
- Microservices Architecture: Each service is designed as an independent bounded context with its own build, deployment, and runtime.
- API Gateway Pattern: Simplifies client interactions by routing requests and handling cross-cutting concerns (such as security and filtering).
- Service Discovery and Dynamic Configuration: Improves scalability and facilitates changes to the system without redeploying services.
- Containerization: With Docker and a centralized docker-compose file, the environment configuration and deployment is modular and consistent.
- Common practices such as centralized error handling, OpenAPI configuration for documentation, and security configurations are recurrent, emphasizing standardized integration patterns.

##### Relevant technologies, frameworks, and libraries
- Spring Boot (inferred from the source structure and typical Java conventions).
- Maven for dependency management and build automation.
- Spring Cloud components (e.g., for Config Server, Discovery Service, and API Gateway) are likely in use.
- Docker for containerization.
- Testing frameworks (as indicated in the test directories).

- Use clear, descriptive labels (e.g., “API Gateway”, “Config Server”, “Discovery Service”, “Doctor Microservice”, “Hospital Microservice”, “Patient Microservice”, “Test Microservice”).
- Optionally, note the integration of Docker containers by grouping the services inside a “Docker Compose” boundary if that level of detail is useful for deployment planning.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client Applications"]:::client
    APIGateway["API Gateway"]:::infrastructure
    ConfigServer["Config Server"]:::infrastructure
    DiscoveryService["Discovery Service"]:::infrastructure
    DockerCompose["Docker Compose"]:::container

    subgraph "Microservices"
        direction TB
        DoctorMS["Doctor Microservice"]:::microservice
        HospitalMS["Hospital Microservice"]:::microservice
        PatientMS["Patient Microservice"]:::microservice
        TestMS["Test Microservice"]:::microservice
    end

    %% External client sends request to API Gateway
    A -->|"Request"| APIGateway

    %% API Gateway interactions with infrastructure services
    APIGateway -->|"lookup"| DiscoveryService
    APIGateway -->|"fetchConfig"| ConfigServer

    %% Discovery Service routes to each microservice
    DiscoveryService -->|"route"| DoctorMS
    DiscoveryService -->|"route"| HospitalMS
    DiscoveryService -->|"route"| PatientMS
    DiscoveryService -->|"route"| TestMS

    %% Each microservice fetches configuration (dashed arrows)
    DoctorMS -.->|"fetchConfig"| ConfigServer
    HospitalMS -.->|"fetchConfig"| ConfigServer
    PatientMS -.->|"fetchConfig"| ConfigServer
    TestMS -.->|"fetchConfig"| ConfigServer

    %% Docker Compose oversees the containerized services
    DockerCompose -.->|"orchestrates"| APIGateway
    DockerCompose -.->|"orchestrates"| ConfigServer
    DockerCompose -.->|"orchestrates"| DiscoveryService
    DockerCompose -.->|"orchestrates"| DoctorMS
    DockerCompose -.->|"orchestrates"| HospitalMS
    DockerCompose -.->|"orchestrates"| PatientMS
    DockerCompose -.->|"orchestrates"| TestMS

    %% Click Events
    click APIGateway "https://github.com/diegobustos16/medicaltestvisor/tree/main/api-gateway/"
    click ConfigServer "https://github.com/diegobustos16/medicaltestvisor/tree/main/config-server/"
    click DiscoveryService "https://github.com/diegobustos16/medicaltestvisor/tree/main/discovery-service/"
    click DoctorMS "https://github.com/diegobustos16/medicaltestvisor/tree/main/doctor-microservice/"
    click HospitalMS "https://github.com/diegobustos16/medicaltestvisor/tree/main/hospital-microservice/"
    click PatientMS "https://github.com/diegobustos16/medicaltestvisor/tree/main/patient-microservice/"
    click TestMS "https://github.com/diegobustos16/medicaltestvisor/tree/main/test-microservice/"
    click DockerCompose "https://github.com/diegobustos16/medicaltestvisor/blob/main/docker-compose.yml"

    %% Styling Classes
    classDef client fill:#b3ffb3,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#f9d342,stroke:#333,stroke-width:2px;
    classDef microservice fill:#9ad1ff,stroke:#333,stroke-width:2px;
    classDef container fill:#ffcccb,stroke:#333,stroke-width:2px;
```
