Loading repository data…
Loading repository data…
ankitdoi-coder / repository
A robust Smart Healthcare Management System backend built with Java and Spring Boot. Features strict Role-Based Authorization, stateless JWT/OAuth2 authentication, and seamless Razorpay integration for secure appointment billing.
A production-ready, secure, and scalable RESTful API for a Smart Healthcare Appointment & Records System, built with Java 17 + Spring Boot 3.5. Implements real-world engineering practices including JWT-based auth with Redis-backed token revocation, role-based access control, centralized exception handling, request validation, OAuth2 social login, Razorpay payment gateway integration, billing management, Cloudinary-backed cloud file storage, server-side pagination, and automated API documentation.
Frontend Repository: 🔗 HealthCare-Frontend — React 19 | Vite | Redux Toolkit | Tailwind CSS | Razorpay Checkout
I've recorded short walkthroughs breaking down some of the trickier features and bugs in this project — not just showing that it works, but explaining the reasoning behind the implementation.
| # | Topic | Link |
|---|---|---|
| 1 | 🔔 Notification Feature — Overview | ▶ Watch |
| 2 | 🧩 Notification Feature — Service & Repository Layer | ▶ Watch |
| 3 | ✅ In-App Notification Feature — Completed Walkthrough | ▶ Watch |
| 4 | 🐞 JWT Authentication Bug Fix — Root Cause & Resolution | ▶ Watch |
| 5 | ✅ Bean Validation & Global Exception Handler | ▶ Watch |
| 6 | 📧 OTP-Based Registration Flow | ▶ Watch |
| 7 | 🔑 OTP Email-Based Password Reset | ▶ Watch |
💡 These videos are meant to give reviewers a look into my thought process — how I debug, design, and reason through real backend problems, not just the final code.
| Feature | Details |
|---|---|
| 🔐 JWT Auth + Role-Based Access | Stateless authentication with role-scoped endpoints (ADMIN / DOCTOR / PATIENT) |
| 🚪 Redis-Backed Token Revocation | True server-side logout for stateless JWTs — a blacklisted token is rejected at the filter level even before its natural expiry, with the Redis key TTL matching the token's remaining lifetime exactly |
| ⚡ Redis-Backed OTP Store | Email verification OTPs live in Redis with native key expiry (SETEX) instead of a manually-expired MySQL table — no cleanup job, no stale rows |
| 📧 Email OTP Verification | 6-digit OTP sent via email before registration; 10-minute expiry, single-use, auto-cleared on resend |
| 🌐 Google OAuth2 Social Login | Patients and doctors can sign in with Google via Spring OAuth2 client |
| 💳 Razorpay Payment Gateway | Real, verified online payments for appointment billing — UPI, Cards & Netbanking, with server-side signature verification |
| ☁️ Cloudinary Cloud Media Storage | Profile pictures uploaded via multipart requests are validated, streamed, and persisted to Cloudinary — no local disk dependency, fully production-portable |
| 📄 Server-Side Pagination | Every major list endpoint (Admin's Doctors/Patients/Billing, Doctor's Appointments/Patients, Patient's Doctors/Appointments/Prescriptions) accepts page/size query params and returns a Spring Data Page<T> instead of a full unbounded list |
| 🛡️ Global Exception Handler | @RestControllerAdvice catches all exceptions — validation, auth, not-found, duplicates — and returns consistent JSON error responses with timestamp |
| ✅ Bean Validation | @Valid + Jakarta Validation annotations (@NotNull, @NotBlank, @Email, @Digits) on all request DTOs |
| 🩺 Doctor Approval Workflow | Doctors register but are locked out until an Admin approves their account |
| 🔑 Password Reset Flow | Forgot-password → token generation → reset-password via secure token |
To maintain professional-grade data traceability, the system implements JPA Auditing.
AuditorAware.@MappedSuperclass with BaseAuditEntity to eliminate boilerplate, ensuring consistent created_at, updated_at, created_by, and updated_by fields across the entire database schema.
Classic 3-tier layered architecture, with Redis sitting alongside MySQL as a second, purpose-built data store for short-lived state:
Controller (REST API) → Service (Business Logic) → Repository (JPA / MySQL)
│
└──▶ RedisTemplate → Redis (OTPs, JWT blacklist)
The codebase is organized by domain modules (feature-based packaging), not by layer — keeping related code co-located and the project scalable.
com.ankit.HealthCare_Backend/
├── appointment/ # Appointment booking, status updates, paginated repository queries
├── authentication/ # JWT + Redis blacklist, Redis-backed OTP, OAuth2, Security config
├── billing/ # Billing records, payment, revenue stats, Razorpay integration, paginated billing list
├── communication/ # Contact Us feature
├── core/ # Shared enums (AppointmentStatus, BillingStatus), Role entity, RedisConfig
├── Exception/ # GlobalExceptionHandler + custom exceptions
├── filemanagement/ # Profile picture upload/retrieval, Cloudinary integration
├── Notification/ # Notification entity & repository
├── prescription/ # Doctor pre
| 💰 Billing & Revenue Module | Appointments auto-generate billing records; Admin can view daily/monthly revenue stats |
| 📁 Role-Aware File Management | Multipart profile picture upload/retrieval shared across PATIENT and DOCTOR roles, backed by Cloudinary |
| 🔔 Real-time Appointment Notifications | Dual-channel notifications (in-app + email) for appointment creation & status tracking; includes time & reason details |
| 📬 Notification Entity | In-app notification system with read/unread tracking and multi-type support (Appointment, Prescription, Payment, Registration) |
| 📚 Swagger / OpenAPI Docs | Auto-generated interactive API docs via SpringDoc OpenAPI 2.5 |
| 🌍 CORS Configured | Whitelisted for React frontend at localhost:5173 and localhost:3000 via allowedOriginPatterns, safely combined with credentialed requests |
| ⚡ Stateless Sessions | SessionCreationPolicy.STATELESS — no server-side session state |
| 🏗️ Auditing & Persistence Infrastructure | @MappedSuperclass with BaseAuditEntity eliminates boilerplate, ensuring consistent created_at, updated_at, created_by, updated_by across the schema |