# durgaprasad9032/medguide-smart-medication-manager architecture

> Architecture diagram of the GitHub repository durgaprasad9032/medguide-smart-medication-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/durgaprasad9032/medguide-smart-medication-manager
- Repository: https://github.com/durgaprasad9032/medguide-smart-medication-manager

## Overview

The available repository implements MedGuide’s Spring Boot backend foundation, especially authentication, JWT sessions, role-based authorization, health checking, and versioned database schema. The README describes medication-management, doctor, admin, and OCR capabilities as product goals, but those client and domain modules are not present in this tree. Edges reflect source-index references and the shown authentication calls; the schema is documented, but no runtime migration wiring was inspected.

Main entry points: [`backend/src/main/java/com/medguide/modules/auth/service/AuthService.java`](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/service/AuthService.java) (Auth workflows), [`backend/src/main/java/com/medguide/modules/auth/controller/AuthController.java`](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/controller/AuthController.java) (Auth endpoints), [`backend/src/main/java/com/medguide/security/JwtAuthenticationFilter.java`](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/JwtAuthenticationFilter.java) (JWT filter), [`backend/src/main/java/com/medguide/security/CustomUserDetailsService.java`](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/CustomUserDetailsService.java) (User details loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_auth_controller["Auth endpoints"]
  node_health_controller["Health endpoint"]
end

subgraph group_auth["Authentication"]
  node_auth_service["Auth workflows<br/>[AuthService.java]"]
  node_auth_payloads["Auth payloads"]
  node_refresh_entity["Refresh sessions<br/>[RefreshToken.java]"]
end

subgraph group_security["Security"]
  node_jwt_service["JWT and hashing<br/>[JwtService.java]"]
  node_jwt_filter["JWT filter"]
  node_principal["User principal<br/>[UserPrincipal.java]"]
  node_user_details["User details loader"]
  node_security_config["Security configuration"]
end

subgraph group_data["Persistence"]
  node_refresh_repo[("Refresh token store")]
  node_user_entity["User and roles<br/>[User.java]"]
  node_user_repo[("User store")]
  node_schema[("MySQL schema")]
end

subgraph group_platform["Backend platform"]
  node_exception_handler["API error handling"]
  node_response["API responses<br/>[ApiResponse.java]"]
  node_application["Spring Boot app"]
end

node_patient(("Patient client"))
node_doctor(("Doctor client"))
node_admin(("Admin client"))
node_prescription_ocr{{"Prescription OCR"}}
node_medication_workflows["Medication management"]
node_adherence["Adherence reports"]
node_localization["English and Telugu"]

node_patient -.->|"uses API"| node_auth_controller
node_doctor -.->|"uses API"| node_auth_controller
node_admin -.->|"uses API"| node_auth_controller
node_auth_controller -->|"delegates"| node_auth_service
node_auth_service -->|"uses"| node_auth_payloads
node_auth_service -->|"reads and writes"| node_user_repo
node_auth_service -->|"reads and writes"| node_refresh_repo
node_auth_service -->|"issues and hashes"| node_jwt_service
node_auth_service -->|"creates and checks"| node_user_entity
node_refresh_repo -->|"persists"| node_refresh_entity
node_user_repo -->|"persists"| node_user_entity
node_jwt_filter -->|"validates tokens"| node_jwt_service
node_jwt_filter -->|"builds identity"| node_principal
node_user_details -->|"loads user"| node_user_repo
node_user_details -->|"creates identity"| node_principal
node_security_config -->|"registers"| node_jwt_filter
node_security_config -->|"configures"| node_user_details
node_auth_controller -->|"wraps results"| node_response
node_exception_handler -->|"formats errors"| node_response
node_application -.->|"serves API"| node_health_controller
node_schema -.->|"defines user table"| node_user_entity
node_patient -.->|"manages medicines"| node_medication_workflows
node_patient -.->|"views reports"| node_adherence
node_patient -.->|"scans prescriptions"| node_prescription_ocr
node_doctor -.->|"manages treatments"| node_medication_workflows
node_doctor -.->|"issues prescriptions"| node_prescription_ocr
node_admin -.->|"oversees extraction"| node_prescription_ocr
node_localization -.->|"localizes UI"| node_patient
node_localization -.->|"localizes UI"| node_doctor

click node_auth_controller "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/controller/AuthController.java"
click node_health_controller "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/health/HealthController.java"
click node_auth_service "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/service/AuthService.java"
click node_auth_payloads "https://github.com/durgaprasad9032/medguide-smart-medication-manager/tree/main/backend/src/main/java/com/medguide/modules/auth/dto"
click node_refresh_entity "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/domain/RefreshToken.java"
click node_refresh_repo "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/repository/RefreshTokenRepository.java"
click node_user_entity "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/user/domain/User.java"
click node_user_repo "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/user/repository/UserRepository.java"
click node_jwt_service "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/JwtService.java"
click node_jwt_filter "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/JwtAuthenticationFilter.java"
click node_principal "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/UserPrincipal.java"
click node_user_details "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/CustomUserDetailsService.java"
click node_security_config "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/config/SecurityConfig.java"
click node_schema "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/resources/db/migration/V1__initial_schema.sql"
click node_exception_handler "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/common/exception/GlobalExceptionHandler.java"
click node_response "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/common/response/ApiResponse.java"
click node_application "https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/MedGuideApplication.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_controller,node_health_controller,node_patient,node_doctor,node_admin toneBlue
class node_auth_service,node_auth_payloads,node_refresh_entity toneAmber
class node_jwt_service,node_jwt_filter,node_principal,node_user_details,node_security_config toneMint
class node_refresh_repo,node_user_entity,node_user_repo,node_schema toneRose
class node_exception_handler,node_response,node_application,node_prescription_ocr,node_medication_workflows,node_adherence,node_localization toneIndigo
```

## Components

### REST API

- [Auth endpoints](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/controller/AuthController.java): `backend/src/main/java/com/medguide/modules/auth/controller/AuthController.java`
- [Health endpoint](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/health/HealthController.java): `backend/src/main/java/com/medguide/modules/health/HealthController.java`

### Authentication

- [Auth workflows](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/service/AuthService.java): `backend/src/main/java/com/medguide/modules/auth/service/AuthService.java`
- [Auth payloads](https://github.com/durgaprasad9032/medguide-smart-medication-manager/tree/main/backend/src/main/java/com/medguide/modules/auth/dto): `backend/src/main/java/com/medguide/modules/auth/dto`
- [Refresh sessions](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/domain/RefreshToken.java): `backend/src/main/java/com/medguide/modules/auth/domain/RefreshToken.java`

### Security

- [JWT and hashing](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/JwtService.java): `backend/src/main/java/com/medguide/security/JwtService.java`
- [JWT filter](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/JwtAuthenticationFilter.java): `backend/src/main/java/com/medguide/security/JwtAuthenticationFilter.java`
- [User principal](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/UserPrincipal.java): `backend/src/main/java/com/medguide/security/UserPrincipal.java`
- [User details loader](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/security/CustomUserDetailsService.java): `backend/src/main/java/com/medguide/security/CustomUserDetailsService.java`
- [Security configuration](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/config/SecurityConfig.java): `backend/src/main/java/com/medguide/config/SecurityConfig.java`

### Persistence

- [Refresh token store](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/auth/repository/RefreshTokenRepository.java): `backend/src/main/java/com/medguide/modules/auth/repository/RefreshTokenRepository.java`
- [User and roles](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/user/domain/User.java): `backend/src/main/java/com/medguide/modules/user/domain/User.java`
- [User store](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/modules/user/repository/UserRepository.java): `backend/src/main/java/com/medguide/modules/user/repository/UserRepository.java`
- [MySQL schema](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/resources/db/migration/V1__initial_schema.sql): `backend/src/main/resources/db/migration/V1__initial_schema.sql`

### Backend platform

- [API error handling](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/common/exception/GlobalExceptionHandler.java): `backend/src/main/java/com/medguide/common/exception/GlobalExceptionHandler.java`
- [API responses](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/common/response/ApiResponse.java): `backend/src/main/java/com/medguide/common/response/ApiResponse.java`
- [Spring Boot app](https://github.com/durgaprasad9032/medguide-smart-medication-manager/blob/main/backend/src/main/java/com/medguide/MedGuideApplication.java): `backend/src/main/java/com/medguide/MedGuideApplication.java`

### Other components

- **Patient client**
- **Doctor client**
- **Admin client**
- **Prescription OCR**
- **Medication management**
- **Adherence reports**
- **English and Telugu**

## Connections

- Patient client → Auth endpoints: uses API (evidence: `README.md`)
- Doctor client → Auth endpoints: uses API (evidence: `README.md`)
- Admin client → Auth endpoints: uses API (evidence: `README.md`)
- Auth endpoints → Auth workflows: delegates (evidence: `backend/src/main/java/com/medguide/modules/auth/controller/AuthController.java`)
- Auth workflows → Auth payloads: uses (evidence: `backend/src/main/java/com/medguide/modules/auth/service/AuthService.java`)
- Auth workflows → User store: reads and writes (evidence: `backend/src/main/java/com/medguide/modules/auth/service/AuthService.java`)
- Auth workflows → Refresh token store: reads and writes (evidence: `backend/src/main/java/com/medguide/modules/auth/service/AuthService.java`)
- Auth workflows → JWT and hashing: issues and hashes (evidence: `backend/src/main/java/com/medguide/modules/auth/service/AuthService.java`)
- Auth workflows → User and roles: creates and checks (evidence: `backend/src/main/java/com/medguide/modules/auth/service/AuthService.java`)
- Refresh token store → Refresh sessions: persists (evidence: `backend/src/main/java/com/medguide/modules/auth/repository/RefreshTokenRepository.java`)
- User store → User and roles: persists (evidence: `backend/src/main/java/com/medguide/modules/user/repository/UserRepository.java`)
- JWT filter → JWT and hashing: validates tokens (evidence: `backend/src/main/java/com/medguide/security/JwtAuthenticationFilter.java`)
- JWT filter → User principal: builds identity (evidence: `backend/src/main/java/com/medguide/security/JwtAuthenticationFilter.java`)
- User details loader → User store: loads user (evidence: `backend/src/main/java/com/medguide/security/CustomUserDetailsService.java`)
- User details loader → User principal: creates identity (evidence: `backend/src/main/java/com/medguide/security/CustomUserDetailsService.java`)
- Security configuration → JWT filter: registers (evidence: `backend/src/main/java/com/medguide/config/SecurityConfig.java`)
- Security configuration → User details loader: configures (evidence: `backend/src/main/java/com/medguide/config/SecurityConfig.java`)
- Auth endpoints → API responses: wraps results (evidence: `backend/src/main/java/com/medguide/modules/auth/controller/AuthController.java`)
- API error handling → API responses: formats errors (evidence: `backend/src/main/java/com/medguide/common/exception/GlobalExceptionHandler.java`)
- Spring Boot app → Health endpoint: serves API
- MySQL schema → User and roles: defines user table (evidence: `README.md`)
- Patient client → Medication management: manages medicines (evidence: `README.md`)
- Patient client → Adherence reports: views reports (evidence: `README.md`)
- Patient client → Prescription OCR: scans prescriptions (evidence: `README.md`)
- Doctor client → Medication management: manages treatments (evidence: `README.md`)
- Doctor client → Prescription OCR: issues prescriptions (evidence: `README.md`)
- Admin client → Prescription OCR: oversees extraction (evidence: `README.md`)
- English and Telugu → Patient client: localizes UI (evidence: `README.md`)
- English and Telugu → Doctor client: localizes UI (evidence: `README.md`)
