# arc-arnob/healthe-master architecture

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

- Interactive diagram: https://gitdiagram.com/arc-arnob/healthe-master
- Repository: https://github.com/arc-arnob/healthe-master

## Overview

##### Main Components
- API Service Layer: Show the entry point into the system (the API gateway, for example, catalog-service). It handles load balancing, security, and request routing.
- Composite Layer: This layer abstracts multiple backend API calls. It acts as a single point of contact for external requests and contains cross-cutting concerns (such as circuit breakers).
- Core Layer: This consists of the business and data services. In this project, it contains:
– Forum API (community discussion and thread management)
– Appointment Booking API (patient–doctor scheduling)
– Store Locator API (finding nearby pharmacies)
– Diagnosis API (sub-services for heart attack, stroke, and diabetes prediction that interface with Django/ML models)
– Medication API (prescription management)
- Support Services: These include the Authentication/Authorization API (using JWT), Mailing API (for sending notifications/emails), and possibly other auxiliary services.
- Infrastructure Components: Represent the underlying service registry (Eureka), load balancer (Ribbon), circuit breaker (Hystrix), proxy/gateway (Zuul) and even a dedicated JWT-based security infrastructure.

##### Relationships and Interactions
- Request Flow: External requests first hit the API Gateway which then routes to the composite layer. The composite layer aggregates calls, applies circuit breaking (using Hystrix), and then forwards requests to the appropriate core service.
- Internal Microservices Communication: Each microservice (forum, appointment, diagnosis, medication, store locator) uses its own database (SQL or NoSQL as seen in the file configuration) and communicates via REST APIs. They register with the service registry for dynamic discovery.
- Security: Every request (except unsafeguarded services like the Store Locator API) must carry an encrypted JWT token. Each service independently verifies and authenticates with the Authentication/Authorization API.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clearly organize the architecture into the API service layer, composite layer, and core/supported microservice layer.
- Microservice Principles: Emphasize that each microservice is independently deployable and has its own persistence mechanism, ensuring loose coupling.
- Fault Tolerance: Indicate the use of circuit breakers to prevent cascading failure.
- Service Discovery: Show how Eureka (or another service registry) enables dynamic service discovery.

##### Relevant Technologies and Frameworks
- Java, Spring Boot and Spring Cloud components.
- Netflix OSS components such as Hystrix, Ribbon, Zuul, and Eureka.
- Databases: MySQL for relational storage and MongoDB for NoSQL storage in some services.
- JWT for security and authentication.
- Third-party APIs (e.g., TOM TOM for maps).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client Application"]:::frontend
    Frontend["Frontend"]:::frontend

    subgraph "API Service Layer"
        Catalog["Catalog Service (API Gateway & Composite)"]:::api
    end

    subgraph "Core Microservices"
        Forum["Forum API"]:::core
        Appointment["Appointment Booking API"]:::core
        Store["Store Locator API"]:::core
        Diagnosis["Diagnosis API"]:::core
            subgraph "Diagnosis API Components"
                ML["ML Models"]:::core
                Django["Django API"]:::core
            end
        Medication["Medication API"]:::core
        ICD["Additional Diagnosis Gateway"]:::core
        Maps["Maps API Integration (TOM TOM)"]:::core
    end

    subgraph "Support Services"
        Auth["Auth/Authorization API"]:::support
        Mailing["Mailing API"]:::support
        Discovery["Service Discovery (Eureka)"]:::support
        Zuul["API Gateway (Zuul)"]:::support
    end

    subgraph "Infrastructure"
        Ribbon["Ribbon (Load Balancer)"]:::infra
        Hystrix["Hystrix (Circuit Breaker)"]:::infra
    end

    %% Request flow from clients to the API layer
    Client -->|"RESTCall"| Frontend
    Frontend -->|"RESTCall"| Catalog

    %% Load balancing and circuit breaking between API layer and core services
    Catalog -->|"RESTCall"| Ribbon
    Ribbon -->|"BalancedCall"| Forum
    Ribbon -->|"BalancedCall"| Appointment
    Ribbon -->|"BalancedCall"| Store
    Ribbon -->|"BalancedCall"| Diagnosis
    Ribbon -->|"BalancedCall"| Medication
    Ribbon -->|"BalancedCall"| ICD
    Ribbon -->|"BalancedCall"| Maps

    Catalog -->|"CircuitBreak"| Hystrix
    Hystrix -->|"Fallback"| Catalog

    %% Microservices service registration with Eureka
    Forum ---|"Register"| Discovery
    Appointment ---|"Register"| Discovery
    Store ---|"Register"| Discovery
    Diagnosis ---|"Register"| Discovery
    Medication ---|"Register"| Discovery
    ICD ---|"Register"| Discovery
    Maps ---|"Register"| Discovery
    Catalog ---|"Register"| Discovery

    %% Security and Authentication flows
    Catalog ---|"JWTAuth"| Auth
    Forum ---|"JWTAuth"| Auth
    Appointment ---|"JWTAuth"| Auth
    Diagnosis ---|"JWTAuth"| Auth
    Medication ---|"JWTAuth"| Auth

    %% Notification flow from Medication API to Mailing API
    Medication ---|"Notify"| Mailing

    %% Internal routing within Diagnosis API
    Diagnosis -->|"InternalCall"| ML
    Diagnosis -->|"InternalCall"| Django
    Diagnosis -->|"Route"| ICD

    %% Alternative client routing through Zuul Gateway
    Frontend -->|"AlternateREST"| Zuul

    %% Click Events for Components
    click Catalog "https://github.com/arc-arnob/healthe-master/tree/main/backend/composite/catalog-service"
    click Forum "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/forum"
    click Appointment "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/patientBooking/booking"
    click Store "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/storeLocator/booking_per_user"
    click ML "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/MlDiagnosis/ML_models"
    click Django "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/MlDiagnosis/django_api"
    click Medication "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/medicationSystem/medSystem"
    click Auth "https://github.com/arc-arnob/healthe-master/tree/main/backend/support/jwt-auth-service/jwt_auth_service"
    click Mailing "https://github.com/arc-arnob/healthe-master/tree/main/backend/support/mailing-service/mailing-service"
    click Discovery "https://github.com/arc-arnob/healthe-master/tree/main/backend/support/eureka-service/servicedis"
    click Zuul "https://github.com/arc-arnob/healthe-master/tree/main/backend/support/zuul-service"
    click ICD "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/gateway"
    click Maps "https://github.com/arc-arnob/healthe-master/tree/main/backend/core/mapsApi/tomtom_api"

    %% Styling
    classDef frontend fill:#B3D4FC,stroke:#1E90FF,stroke-width:2px;
    classDef api fill:#C2F0C2,stroke:#008000,stroke-width:2px;
    classDef core fill:#FFECB3,stroke:#FFA500,stroke-width:2px;
    classDef support fill:#FDCEDF,stroke:#FF69B4,stroke-width:2px;
    classDef infra fill:#D3D3D3,stroke:#696969,stroke-width:2px;
```
