|
| 1 | +# CLAUDE.md - Common-API |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Common-API is the gateway microservice for the AMRIT healthcare platform. It provides shared APIs consumed by all frontend UIs including authentication, beneficiary registration, call handling, location masters, notifications, feedback, reporting, and integrations with external systems (c-Zentrix CTI, Everwell, eAusadha, eSanjeevani, ABDM, Firebase, Honeywell POCT devices). |
| 6 | + |
| 7 | +## Tech Stack |
| 8 | + |
| 9 | +- Java 17 |
| 10 | +- Spring Boot 3.2.2 |
| 11 | +- Spring Data JPA / Hibernate |
| 12 | +- MySQL 8.0 |
| 13 | +- Redis (session management, caching) |
| 14 | +- MongoDB (optional, for specific integrations) |
| 15 | +- Maven (build tool) |
| 16 | +- Swagger/OpenAPI (API documentation) |
| 17 | +- Lombok, MapStruct |
| 18 | +- CryptoJS-compatible AES encryption |
| 19 | +- Firebase Admin SDK |
| 20 | +- WAR packaging (deploys to Wildfly) |
| 21 | + |
| 22 | +## Build and Run |
| 23 | + |
| 24 | +```bash |
| 25 | +# Build |
| 26 | +mvn clean install -DENV_VAR=local |
| 27 | + |
| 28 | +# Run locally (start Redis first) |
| 29 | +mvn spring-boot:run -DENV_VAR=local |
| 30 | + |
| 31 | +# Package WAR |
| 32 | +mvn -B package --file pom.xml -P <profile> # profiles: dev, local, test, ci, uat |
| 33 | + |
| 34 | +# Run tests |
| 35 | +mvn test |
| 36 | +``` |
| 37 | + |
| 38 | +### Configuration |
| 39 | + |
| 40 | +- Copy `src/main/environment/common_example.properties` to `common_local.properties` and edit. |
| 41 | +- Environment selected via `-DENV_VAR=<env>`. |
| 42 | +- Swagger UI: `http://localhost:8083/swagger-ui.html` |
| 43 | + |
| 44 | +## Package Structure |
| 45 | + |
| 46 | +Base package: `com.iemr.common` |
| 47 | + |
| 48 | +| Layer | Package | Description | |
| 49 | +|-------|---------|-------------| |
| 50 | +| Controllers | `controller.*` | REST endpoints (40+ sub-packages) | |
| 51 | +| Services | `service.*` | Business logic | |
| 52 | +| Repositories | `repository.*`, `repo.*` | JPA repositories | |
| 53 | +| Entities | `data.*` | JPA entity classes | |
| 54 | +| DTOs | `model.*` | Transfer objects | |
| 55 | +| Mappers | `mapper.*` | Object mapping | |
| 56 | +| Config | `config.*` | Swagger, encryption, Firebase, Quartz, prototypes | |
| 57 | +| Constants | `constant` | Application constants | |
| 58 | +| Utils | `utils.*` | Redis, HTTP, session, validation, exception | |
| 59 | + |
| 60 | +## Key Functional Domains |
| 61 | + |
| 62 | +- **Authentication/Authorization**: `controller.users` - login, session, user management |
| 63 | +- **Beneficiary Registration**: `controller.beneficiary` - create, search, update beneficiaries |
| 64 | +- **Call Handling**: `controller.callhandling` - CTI integration, call lifecycle |
| 65 | +- **Feedback/Grievance**: `controller.feedback`, `controller.grievance` - feedback and complaint management |
| 66 | +- **Location**: `controller.location` - state, district, block, village masters |
| 67 | +- **Notifications**: `controller.notification` - alerts, SMS, email, Firebase push |
| 68 | +- **Reporting**: `controller.report`, `controller.secondaryReport` - CRM reports |
| 69 | +- **Helpline 104**: `controller.helpline104history` - medical advice history |
| 70 | +- **COVID**: `controller.covid` - vaccination status |
| 71 | +- **CTI Integration**: `controller.cti` - c-Zentrix computer telephony |
| 72 | +- **External Integrations**: `controller.eausadha`, `controller.esanjeevani`, `controller.everwell`, `controller.honeywell`, `controller.brd`, `controller.carestream` |
| 73 | +- **ABDM**: `controller.abdmfacility` - Ayushman Bharat Digital Mission |
| 74 | +- **KM File Management**: `controller.kmfilemanager` - OpenKM document management |
| 75 | +- **OTP/SMS**: `controller.otp`, `controller.sms` (via SMS gateway) |
| 76 | +- **Scheduling**: `controller.questionconfig`, `controller.scheme` |
| 77 | +- **Door-to-Door App**: `controller.door_to_door_app` - field worker support |
| 78 | +- **NHM Dashboard**: `controller.nhmdashboard` - National Health Mission integration |
| 79 | + |
| 80 | +## Architecture Notes |
| 81 | + |
| 82 | +- Entry point: `CommonMain.java` (main class in `utils` package) |
| 83 | +- Acts as the API gateway; all frontend UIs authenticate through Common-API |
| 84 | +- Session management via Redis with 27-minute timeout |
| 85 | +- HTTP interceptors attach `Authorization` and `ServerAuthorization` headers |
| 86 | +- Status code `5002` signals session expiration to frontends |
| 87 | +- AES + PBKDF2 encryption for password handling (`config.encryption`) |
| 88 | +- Firebase integration for push notifications (`config.firebase`) |
| 89 | +- Quartz scheduler for background jobs (`config.quartz`) |
| 90 | +- Extensive test coverage with unit tests under `src/test/` |
| 91 | + |
| 92 | +## CI/CD |
| 93 | + |
| 94 | +- GitHub Actions: `package.yml`, `build-on-pull-request.yml`, `sast.yml`, `commit-lint.yml`, `codeql.yml` |
| 95 | +- Conventional Commits enforced via Husky + commitlint |
| 96 | +- Checkstyle configuration in `checkstyle.xml` |
| 97 | +- JaCoCo for code coverage, SonarQube integration configured |
| 98 | +- Dockerfile for containerized deployment |
0 commit comments