How faeiqkhan/healthvaultbackend works
1. Overall shape
HealthVault is a Spring Boot + PostgreSQL backend for secure medical-record storage and sharing. The repository currently exposes the core domain/persistence layer plus a small audit service, while the README describes the higher-level API/security features that sit on top of it.
2. Application entry point
HealthVaultApplication is the Spring Boot bootstrap class. It starts the application, wires Spring components, and connects the domain packages to the database configured in src/main/resources/application.yaml.
3. Identity and access boundary
The user package models the system’s primary identity layer:
- User
- Role
- KycStatus
This is the foundation for JWT-based authentication and role-based access control described in the README. The diagram should show user identity as a gate in front of record access and KYC-dependent workflows.
4. KYC subsystem
The kyc package contains Doctor and Patient entities plus repositories for each. This is the verification boundary that distinguishes healthcare providers from patients and likely controls who can be granted access to records. It is the business layer that supports the “authorized doctor” model.
5. Medical record subsystem
The record package centers on Record and RecordRepository. This is the persistence boundary for medical files/record metadata. In the architecture diagram, this should be the main protected asset: records are created by patients, stored in PostgreSQL-backed persistence, and later retrieved only through authenticated/authorized flows.
6. Audit subsystem
The audit package provides Audit, UserType, AuditRepository, and AuditService. This is a cross-cutting security trail for sensitive actions such as uploads, sharing, access attempts, or verification events. It should be shown as a side-channel that receives events from the main workflows rather than as part of the core record path.
7. Secure file handling
The README states the system uses hybrid encryption (AES + RSA) with a zero-knowledge approach. Architecturally, that means:
- file contents are encrypted before durable storage,
- AES is used for the bulk data,
- RSA protects the AES key or key material,
- the server/database should not need plaintext access.
This is a major trust boundary and should be drawn between client-side/file-ingest processing and database persistence.
8. Sharing flow
The main data flow is: patient uploads record → record is encrypted and stored → access is controlled by auth + KYC status + role checks → authorized doctor can retrieve/share views of the record. The architecture is therefore not just CRUD; it is an access-controlled sharing system with patient ownership at the center.
9. Persistence model
Each domain area has its own Spring Data repository:
- UserRepository
- DoctorRepository
- PatientRepository
- RecordRepository
- AuditRepository
This indicates a repository-per-aggregate style, with Spring Data JPA handling database access and the service layer coordinating business rules.
10. Supporting tooling and operational surface
The project uses the Maven wrapper (mvnw, pom.xml) for build/test lifecycle, and a basic test class exists under src/test. The README also mentions Swagger documentation, which implies an API layer intended for interactive testing and integration, even though controllers are not visible in the current tree.
11. What to emphasize in an architecture diagram
The most important boundaries are:
- API/auth layer in front of the system,
- user/KYC/role validation as access control,
- record storage as the protected data plane,
- audit logging as a parallel security trail,
- PostgreSQL as the durable backend,
- encryption/key handling as the confidentiality boundary.
The current repository mostly contains the domain and persistence pieces that those flows connect to.
Main entry points: HealthVaultApplication.java HealthVault · application.yaml PostgreSQL · RecordRepository.java Record repo · AuditService.java Audit service
Components 18
Platform
Spring Boot bootstrap and build/runtime surface.
- HealthVault · Application bootstrap and Spring component wiring.
src/main/java/com/faeiq/healthvault/HealthVaultApplication.java - Maven build · Maven wrapper and project build lifecycle.
pom.xml - API layer · Conceptual API and authentication boundary described in the repository documentation.
Identity
Users, roles, and KYC verification boundary.
- User · Primary account and access identity.
src/main/java/com/faeiq/healthvault/user/entity/User.java - Role · Authorization roles for access control.
src/main/java/com/faeiq/healthvault/user/entity/Role.java - KYC status · Verification state used in access decisions.
src/main/java/com/faeiq/healthvault/user/entity/KycStatus.java - Doctor · Verified clinician identity and profile.
src/main/java/com/faeiq/healthvault/kyc/entity/Doctor.java - Patient · Patient identity and ownership side of records.
src/main/java/com/faeiq/healthvault/kyc/entity/Patient.java - User repo · Persistence for user accounts.
src/main/java/com/faeiq/healthvault/user/repository/UserRepository.java - Doctor repo · Persistence for doctor verification records.
src/main/java/com/faeiq/healthvault/kyc/repository/DoctorRepository.java - Patient repo · Persistence for patient verification records.
src/main/java/com/faeiq/healthvault/kyc/repository/PatientRepository.java
Data
Record storage, encryption boundary, and PostgreSQL persistence.
- Encryption · Zero-knowledge file protection boundary before durable storage.
- Record · Protected record metadata and file reference.
src/main/java/com/faeiq/healthvault/record/entity/Record.java - Record repo · Persistence boundary for records.
src/main/java/com/faeiq/healthvault/record/repository/RecordRepository.java - PostgreSQL · Durable backend for domain entities and records.
src/main/resources/application.yaml
Audit
Security trail for sensitive actions and access events.
- Audit service · Coordinates audit events for sensitive actions.
src/main/java/com/faeiq/healthvault/audit/service/AuditService.java - Audit · Stored audit event for access and workflow tracing.
src/main/java/com/faeiq/healthvault/audit/entity/Audit.java - Audit repo · Persistence for audit events.
src/main/java/com/faeiq/healthvault/audit/repository/AuditRepository.java
Connections 25
- Maven build → HealthVault: builds · Maven build produces the Spring Boot application.
- HealthVault → API layer: starts · Bootstraps the HTTP and security-facing application surface.
- HealthVault → User repo: wires · Spring injects identity persistence into the application context.
- HealthVault → Doctor repo: wires · Spring injects KYC persistence into the application context.
- HealthVault → Patient repo: wires · Spring injects KYC persistence into the application context.
- HealthVault → Record repo: wires · Spring injects record persistence into the application context.
- HealthVault → Audit service: wires · Spring injects audit coordination into the application context.
- API layer → User: authenticates · API/security decisions are anchored on the user identity model.
- API layer → Role: authorizes · Role-based access control gates protected actions.
- API layer → KYC status: checks · Verification state influences access and workflow eligibility.
- API layer → Doctor: validates · Doctor status is part of the authorized clinician boundary.
- API layer → Patient: validates · Patient identity establishes ownership of records.
- API layer → Encryption: uploads · Incoming files are encrypted before persistence.
- Encryption → Record repo: stores via · Encrypted record payloads are persisted through the record repository.
- Record repo → Record: persists · Record metadata and references are stored as domain entities.
- User repo → PostgreSQL: persists · User accounts are stored in PostgreSQL.
- Doctor repo → PostgreSQL: persists · Doctor KYC data is stored in PostgreSQL.
- Patient repo → PostgreSQL: persists · Patient KYC data is stored in PostgreSQL.
- Record repo → PostgreSQL: persists · Record metadata is stored in PostgreSQL.
- Audit service → Audit: writes · Audit service creates trail entries for sensitive actions.
- Audit service → Audit repo: persists · Audit entries are saved through the repository boundary.
- Audit repo → PostgreSQL: persists · Audit trail data is stored in PostgreSQL.
- API layer → Audit service: logs · Authentication, access, and sharing events are audited.
- Encryption → PostgreSQL: protects · Encrypted data reaches storage without requiring plaintext at rest.
- API layer → Record repo: reads · Authorized users retrieve records through guarded flows.