How kornchhimheng/medicore3 works
Project Type and Purpose
• This is a full-stack hospital management application split into two main parts:
a) A Java Spring Boot monolithic backend (“Project-Hospital-Management-System-testing” and its V2 variant with JWT and appointment support)
b) A React-based single-page frontend (“my-medicare-dashboard”)
• The backend exposes RESTful endpoints secured with Spring Security and JWT. It implements core hospital features (user/role management, patient/doctor entities, appointment scheduling in V2). The frontend offers UI for patients, receptionists, billing, prescriptions, and uses the backend APIs.
File Structure Analysis
• Top-level directories:
• Project-Hospital-Management-System-testing (Backend V1)
• Project-Hospital-Management-System V2 with Spring Security and JWT (Backend V2)
• my-medicare-dashboard (Frontend)
• Backend modules follow a layered MVC style under src/main/java:
• api.core: configuration (WebConfig, SecurityConfig), filters (JWTAuthFilter), exception handling, utilities
• api.features.hospitalmanagement: controllers, DTOs (request/response), entities, repositories, services/impl
• Resources include application.yml, log4j2 for logging, and Data JSON scripts in V2.
• Frontend uses a standard Vite+React structure: src/components, src/pages, centralized App.jsx, and config files.
Key README Insights
• The README only names the project (“medicorev2”) but the file tree reveals use of Spring Boot, JWT, Log4j2, a relational database (SQL scripts), and a React frontend.
Diagramming the System Architecture
a. Main Components
1. Client/User Interface
• Web browser running the React SPA (“my-medicare-dashboard”)
2. API Gateway / Backend
• Spring Boot application (V2 recommended):
• Security Layer (SecurityConfig, JWTAuthFilter, CustomAuthenticationProvider)
• Controllers (AuthenticationController, PatientController, DoctorController, AppointmentController)
• Service Layer (AuthenticationService, PatientService, UserService, AppointmentService)
• Repository Layer (Spring Data JPA repositories)
• Domain Entities (User, Patient, Doctor, Appointment, Role, Permission)
3. Database
• Relational database (configured via application.yml, populated by Data/ScriptDatabase.sql)
4. Auxiliary Services
• Log storage (Log4j2 → logs/hospital-management)
• External API calls if any (e.g., medication lookup) – currently handled through a React component and possibly a backend util.
b. Relationships and Interactions
• Browser ←→ React SPA: user actions trigger HTTP requests (REST calls)
• React SPA → Backend Controllers: POST/GET to /api/auth, /api/patients, /api/appointments, etc.
• Controllers → Services → Repositories → Database: standard Spring layered calls
• Security Filter Chain (JWTAuthFilter) intercepts incoming requests, validates token via JwtTokenUtil, delegates to OurUserDetailsService
• ExceptionHandleAdviser globally handles exceptions, formatting ErrorResponse/ApiResponse
• Logging intercepts API calls (api-logging.log) and system events (system-logging.log)
c. Architectural Patterns & Principles
• Layered Architecture (Controller → Service → Repository)
• Security as a cross-cutting concern via Spring Security filters
• DTO mapping to decouple API contract from persistence entities
• Exception handling with @ControllerAdvice
• Configuration management via YAML profiles
d. Technologies & Frameworks
• Backend: Java 17+, Spring Boot, Spring Security, JWT, Spring Data JPA, Hibernate, Log4j2, Maven
• Frontend: React, Vite, JSX, CSS, ESLint
• Database: Any RDBMS (SQL scripts included)