How thykp/oop_project works
Project Type and Purpose
• This is a full-stack web application (“SingHealth Clinic Management System”) with a React/Vite frontend and a Spring Boot monolith backend.
• It supports three roles (Patient, Staff, Administrator), real-time updates (WebSocket/SSE), queue management (Kafka + Redis), persistent storage (relational database via JPA), and file storage (Supabase).
File Structure (Top-Level Components)
• frontend/ – React + TypeScript UI, Vite build, Supabase + WebSocket clients.
• backend/ – Spring Boot monolith, organized by packages: config, controller, service, repository, model, dto, util.
• database/ – SQL migration scripts for Postgres (or your chosen RDBMS).
• docker-compose.yml – orchestrates backend dependencies: Kafka, Zookeeper, Redis, database.
README for Architecture Insights
• REST API endpoints (controllers) exposed on port 8080.
• Asynchronous event streams:
• Kafka topics for queue events & notifications
• Redis queues & SSE streams for clinic queues
• WebSocket config for real-time updates
• Supabase for file/treatment-note storage.
• SecurityConfig for role-based access.
Main Components and Their Interactions
A. User Interface Layer (Browser/React Client)
• Pages & reusable UI components
• Uses REST calls (HTTP/HTTPS) and WebSockets/SSE
B. API Layer (Spring Boot Controllers)
• AuthController, AppointmentController, QueueControllers, etc.
• Exposes RESTful endpoints => documented in Swagger/OpenAPI (if enabled)
C. Business Logic Layer (Services)
• AppointmentService, QueueSseService, KafkaProducer/Consumer services, Notification services, SupabaseStorageService
D. Data Access Layer (Repositories)
• JPA repositories for Appointment, User, Clinic, TimeSlot, TreatmentNote, etc.
E. Database (Relational DB)
• Stores entities; migrations under database/migrations
F. Message Brokers & Caches
• Kafka cluster: topics for queue events & notifications
• Redis: per-clinic queues, SSE state (clinic:*:queue, clinic:*:nowServing)
G. File Storage / External Services
• Supabase Storage for treatment note attachments
• External email service (SMTP) via NotificationEmailConsumer
H. Real-Time Channels
• WebSocket endpoints for push notifications
• Server-Sent Events (SSE) for queue updates
Relationships & Data Flows
1. User → Frontend (UI interactions)
2. Frontend → Backend (REST API calls for login, booking, check-in, reports… )
3. Backend → Database (CRUD operations via repositories)
4. Backend → Kafka (publish queue events, notification events)
5. Kafka → Backend (consumers processing events)
6. Backend → Redis (enqueue/dequeue patient in queue streams)
7. Backend → Supabase (upload/download treatment note files)
8. Backend → WebSocket/SSE → Frontend (real-time updates)
9. Backend → SMTP / Email Service (email notifications)
Architectural Patterns
• Layered architecture (Controller → Service → Repository)
• Event-driven integration (Kafka producers/consumers, Redis queues, SSE)
• Asynchronous config (AsyncConfig)
• Role-based security (SecurityConfig)
• Configuration via Spring Profiles (application.properties, application-prod.properties)
Technologies, Frameworks, Libraries
• Frontend: React, TypeScript, Vite, Supabase JS, native WebSocket/SSE
• Infrastructure: Docker Compose (Kafka, Zookeeper, Redis, Postgres), Maven wrapper