# psmri/helpline1097-api architecture

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

- Interactive diagram: https://gitdiagram.com/psmri/helpline1097-api
- Repository: https://github.com/psmri/helpline1097-api

## Overview

##### Project type and purpose
- This is a standalone Spring-Boot microservice (HelpLine1097 API) written in Java 8, built with Maven.
- Its purpose is to expose RESTful endpoints for a national AIDS helpline (inbound/outbound calls), manage counseling/referral/feedback workflows, and synchronize beneficiary adherence data with an external “Everwell” system.
- It uses MySQL for persistence, Redis for caching/session management, JWT for authentication, and Swagger for API documentation.

##### File structure
- Top-level artifacts:
- Dockerfile, pom.xml, .github/workflows (CI/CD pipelines for build, SAST, packaging).
- src/main/java: standard layered packages:
– config (CORS, interceptors, Redis, Swagger)
– controller (REST controllers grouped by functional domain)
– service (business logic interfaces + implementations)
– repository (Spring Data repositories + custom implementations)
– data (entity/DTO classes organized by domain)
– utils (JWT, HTTP interceptors, mappers, email gateway, Redis storage, exception handling)
– src/main/resources: application.properties, logging config.
- Environment files under src/main/environment for CI, Docker, examples.
- Tests under src/test/java targeting the main application class.

##### Insights from README
- Actors: Counseling Officer (CO) and Supervisor consume the API.
- Four core feature areas: Information, Counseling, Referral, Feedback.
- Outbound integration: fetch beneficiaries with missed doses from Everwell, call them, capture responses, and push updates back.
- Exposes all capabilities over REST with Swagger UI.

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef serviceLayer fill:#B8E986,stroke:#22863A,color:#22863A
    classDef repositoryLayer fill:#C6E0FF,stroke:#0366d6,color:#0366d6
    classDef utilLayer fill:#FEEFB3,stroke:#D1A000,color:#735C0F
    classDef configLayer fill:#F0F0F0,stroke:#6A737D,color:#24292E
    classDef infra fill:#BEE3F8,stroke:#0366d6,color:#0366d6
    classDef external fill:#FFD8BE,stroke:#D15704,color:#D15704
    classDef ci fill:#EDEFF2,stroke:#6A737D,color:#24292E

    %% Actors
    CO["Counseling Officer\n/Supervisor"]:::external

    %% API Boundary
    LoadBalancer["Load Balancer\n(API Gateway)"]:::infra

    CO -->|HTTP Request| LoadBalancer

    %% Microservice
    subgraph "HelpLine1097 Service" 
        direction TB

        %% Config Layer
        subgraph "Configuration" 
            direction TB
            CorsConfig["CorsConfig"]:::configLayer
            BlockingHttpMethodInterceptor["BlockingHttpMethodInterceptor"]:::configLayer
            InterceptorConfig["InterceptorConfig"]:::configLayer
            SwaggerConfig["SwaggerConfig"]:::configLayer
        end

        %% HTTP Layer
        subgraph "Controllers" 
            direction TB
            Service1097HistoryController["Service1097HistoryController"]:::frontend
            BeneficiaryController["BeneficiaryController"]:::frontend
            CalltypeController["CalltypeController"]:::frontend
            FeedbackController["FeedbackController"]:::frontend
            FeedbackRequestController["FeedbackRequestController"]:::frontend
            CategoryController["CategoryController"]:::frontend
            CommonController["CommonController"]:::frontend
            DesignationController["DesignationController"]:::frontend
            InstitutionController["InstitutionController"]:::frontend
            EverwellGuidelinesController["EverwellGuidelinesController"]:::frontend
            VersionController["VersionController"]:::frontend
        end

        %% Utility Layer
        subgraph "Utilities" 
            direction TB
            JwtUtil["JwtUtil"]:::utilLayer
            JwtAuthenticationUtil["JwtAuthenticationUtil"]:::utilLayer
            JwtUserIdValidationFilter["JwtUserIdValidationFilter"]:::utilLayer
            TokenDenylist["TokenDenylist"]:::utilLayer
            RedisConfig["RedisConfig"]:::configLayer
            RedisStorage["RedisStorage"]:::utilLayer
            InputMapper["InputMapper"]:::utilLayer
            OutputMapper["OutputMapper"]:::utilLayer
            EmailService["EmailService"]:::utilLayer
            GenericEmailServiceImpl["GenericEmailServiceImpl"]:::utilLayer
        end

        %% Service Layer
        subgraph "Business Services" 
            direction TB
            EverwellServiceImpl["EverwellServiceImpl"]:::serviceLayer
        end

        %% Repository Layer
        subgraph "Repositories" 
            direction TB
            EverwellGuidelinesRepo["EverwellGuidelinesRepo"]:::repositoryLayer
        end

        %% Runtime Entry
        HelpLine1097App["HelpLine1097Application\n(Spring Boot)"]:::serviceLayer
    end

    %% Data Stores and External
    MySQL["MySQL Database"]:::infra
    Redis["Redis Cache"]:::infra
    EverwellAPI["Everwell External API"]:::external
    SwaggerUI["Swagger UI"]:::external

    %% CI/CD
    subgraph "CI/CD Pipeline" 
        direction TB
        GitHubActions["GitHub Actions"]:::ci
        DockerfileNode["Dockerfile"]:::ci
        Workflows[".github/workflows"]:::ci
    end

    %% Flows
    LoadBalancer -->|routes to| HelpLine1097App
    HelpLine1097App -->|uses config| CorsConfig
    HelpLine1097App -->|uses config| InterceptorConfig
    HelpLine1097App -->|serves docs| SwaggerUI
    HelpLine1097App -->|invokes| Service1097HistoryController
    HelpLine1097App -->|invokes| BeneficiaryController
    Service1097HistoryController -->|calls| EverwellServiceImpl
    BeneficiaryController -->|calls| EverwellServiceImpl
    EverwellServiceImpl -->|fetch/push| EverwellAPI
    Service1097HistoryController -->|CRUD| MySQL
    Service1097HistoryController -->|cache/session| Redis
    HelpLine1097App -->|filters| JwtUserIdValidationFilter
    HelpLine1097App -->|reads| TokenDenylist
    GitHubActions -->|builds/tests| HelpLine1097App
    GitHubActions -->|packages| DockerfileNode
    GitHubActions -->|runs| Workflows

    %% Click events
    click HelpLine1097App "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/HelpLine1097Application.java"
    click Service1097HistoryController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/beneficiarycall/Service1097HistoryController.java"
    click BeneficiaryController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/BeneficiaryController.java"
    click CalltypeController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/CalltypeController.java"
    click FeedbackController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/FeedbackController.java"
    click FeedbackRequestController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/FeedbackRequestController.java"
    click CategoryController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/CategoryController.java"
    click CommonController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/CommonController.java"
    click DesignationController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/DesignationController.java"
    click InstitutionController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/co/InstitutionController.java"
    click EverwellGuidelinesController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/everwell/EverwellGuidelinesController.java"
    click VersionController "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/controller/version/VersionController.java"
    click CorsConfig "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/config/CorsConfig.java"
    click BlockingHttpMethodInterceptor "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/config/BlockingHttpMethodInterceptor.java"
    click InterceptorConfig "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/config/InterceptorConfig.java"
    click JwtUtil "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/JwtUtil.java"
    click JwtAuthenticationUtil "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/JwtAuthenticationUtil.java"
    click JwtUserIdValidationFilter "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/JwtUserIdValidationFilter.java"
    click TokenDenylist "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/TokenDenylist.java"
    click RedisConfig "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/config/RedisConfig.java"
    click RedisStorage "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/redis/RedisStorage.java"
    click InputMapper "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/mapper/InputMapper.java"
    click OutputMapper "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/mapper/OutputMapper.java"
    click EmailService "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/gateway/email/EmailService.java"
    click GenericEmailServiceImpl "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/utils/gateway/email/GenericEmailServiceImpl.java"
    click EverwellServiceImpl "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/service/everwell/EverwellServiceImpl.java"
    click EverwellGuidelinesRepo "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/repository/everwell/EverwellGuidelinesRepo.java"
    click SwaggerConfig "https://github.com/psmri/helpline1097-api/blob/develop/src/main/java/com/iemr/helpline1097/config/SwaggerConfig.java"
    click DockerfileNode "https://github.com/psmri/helpline1097-api/tree/develop/Dockerfile"
    click Workflows "https://github.com/psmri/helpline1097-api/tree/develop/.github/workflows"
    click GitHubActions "https://github.com/psmri/helpline1097-api/blob/develop/.github/workflows/build-on-pull-request.yml"
```
