How ultimatrix2/calmquest works
1. System purpose and entry points
CalmQuest is a mental-wellness platform for students and care staff: mood/emotion tracking, AI chat and reports, community support, appointments, notifications, and role-based administration. The React SPA starts at frontend/src/main.tsx and defines client routing in frontend/src/App.tsx. The Spring Boot REST API starts at backend/src/main/java/com/calmquest/CalmQuestApplication.java.
2. Frontend application shell
The Vite/React/TypeScript frontend provides public, authenticated, and role-specific dashboard flows. Route guards and OAuth callback processing form the browser-side access boundary:
• frontend/src/App.tsx
• frontend/src/components/ProtectedRoute.tsx
• frontend/src/components/oauth2-redirect-handler.tsx
DashboardLayout hosts dashboard navigation; Redux holds cross-page auth, chat, sidebar, and theme state. Page-level services are the HTTP boundary to the backend:
• frontend/src/components/DashboardLayout.tsx
• frontend/src/store/store.ts
• frontend/src/services/authService.ts
3. API, domain, and persistence layers
Backend controllers expose feature-oriented REST APIs, delegating business work to services and persistence to Spring Data JPA repositories. DTOs separate request/response shapes from entities; GlobalExceptionHandler centralizes API error handling.
• backend/src/main/java/com/calmquest/controller/AuthController.java
• backend/src/main/java/com/calmquest/service/AuthService.java
• backend/src/main/java/com/calmquest/entity/User.java
PostgreSQL is the system of record for identities, roles, wellness logs, chat sessions/messages, assessment/report artifacts, appointments, notifications, and community interactions. Repository/entity pairs make these persistence boundaries explicit, e.g.:
• backend/src/main/java/com/calmquest/entity/ChatSession.java
• backend/src/main/java/com/calmquest/entity/Appointment.java
• backend/src/main/java/com/calmquest/repository/CommunityPostRepository.java
4. Identity, authorization, and operational roles
Authentication supports credentials/JWT and Google OAuth2. Spring Security applies authorization; the JWT filter/provider establish API caller identity, while rate limiting protects requests. User-derived domain models distinguish students, doctors, college admins, and super admins.
• backend/src/main/java/com/calmquest/config/SecurityConfig.java
• backend/src/main/java/com/calmquest/security/jwt/JwtAuthFilter.java
• backend/src/main/java/com/calmquest/security/oauth2/OAuth2SuccessHandler.java
Admin controllers/services provide scoped college and platform oversight:
• backend/src/main/java/com/calmquest/controller/CollegeAdminController.java
• backend/src/main/java/com/calmquest/controller/SuperAdminController.java
5. Wellness analysis and AI workflow
Browser-side facial detection runs locally against bundled face-api models; detected results cross to backend logging/analysis services. Voice recordings similarly feed backend analysis. Assessment answers are scored and persisted, with AI report generation represented by assessment/report entities.
• frontend/src/components/FacialEmotionDetector.tsx
• frontend/src/components/VoiceRecorder.tsx
• backend/src/main/java/com/calmquest/service/AssessmentService.java
Chat requests flow from ChatPage through ChatService, retain session/message history, and invoke Gemini for contextual replies. Gemini is also the AI integration for generated reports.
• frontend/src/pages/dashboard/ChatPage.tsx
• backend/src/main/java/com/calmquest/service/ChatService.java
• backend/src/main/java/com/calmquest/service/GeminiService.java
6. Support, care, and community workflows
Community operations manage posts, media, reactions, comments, bookmarks, and reports; uploads are delegated to Cloudinary. Notifications and SOS are separate backend workflows surfaced by shared frontend controls.
• backend/src/main/java/com/calmquest/service/CommunityService.java
• backend/src/main/java/com/calmquest/service/CloudinaryService.java
• frontend/src/components/SosButton.tsx
Appointment flow connects students and doctors: request/book, review status, then join a Jitsi-based meeting from the dashboard.
• backend/src/main/java/com/calmquest/service/AppointmentService.java
• frontend/src/pages/dashboard/doctor/BookAppointment.tsx
• frontend/src/pages/dashboard/doctor/MeetingRoom.tsx
7. Scheduled and external infrastructure
The deployment requires Java 17/Spring Boot, PostgreSQL, and a Node/Vite frontend. Backend configuration centrally supplies database, JWT, SMTP mail, Cloudinary, OAuth2, and Gemini settings:
• backend/src/main/resources/application.properties
• backend/src/main/java/com/calmquest/config/CloudinaryConfig.java
• backend/src/main/java/com/calmquest/config/RecommendationScheduler.java
Daily recommendations are a scheduled backend process; startup seeding initializes platform data, including the super-admin baseline:
• backend/src/main/java/com/calmquest/service/RecommendationService.java
• backend/src/main/java/com/calmquest/config/DataSeeder.java
Main entry points: User.java JPA domain entities · CalmQuestApplication.java Spring Boot application · authService.ts Frontend API services · AssessmentService.java Wellness assessment service
Components 19
React frontend
- SPA bootstrap & routes · Public, protected, and role dashboard routes.
frontend/src/App.tsx - Route guards & OAuth callback
frontend/src/components/ProtectedRoute.tsx - Dashboard shell & state
frontend/src/components/DashboardLayout.tsx - Frontend API services
frontend/src/services/authService.ts - Local emotion & voice capture · Facial detection runs locally before results are logged.
frontend/src/components/FacialEmotionDetector.tsx - Chat dashboard
frontend/src/pages/dashboard/ChatPage.tsx - Appointments & meetings
frontend/src/pages/dashboard/doctor/BookAppointment.tsx
Spring Boot API
- Spring Boot application · Feature controllers expose wellness, care, community, and admin APIs.
backend/src/main/java/com/calmquest/CalmQuestApplication.java - Security & JWT authorization · Credentials and Google OAuth2 establish authorized API identities.
backend/src/main/java/com/calmquest/config/SecurityConfig.java - Identity & role service
backend/src/main/java/com/calmquest/service/AuthService.java - Wellness assessment service · Scores assessments and persists report artifacts.
backend/src/main/java/com/calmquest/service/AssessmentService.java - Chat service · Maintains contextual sessions and message history.
backend/src/main/java/com/calmquest/service/ChatService.java - Community & care services · Handles posts, SOS, notifications, and appointments.
backend/src/main/java/com/calmquest/service/CommunityService.java - Recommendations & data seeding
backend/src/main/java/com/calmquest/config/RecommendationScheduler.java - JPA domain entities · Users, logs, chats, reports, appointments, notifications, and community records.
backend/src/main/java/com/calmquest/entity/User.java
External services
- PostgreSQL
- Gemini · Generates chat replies and wellness reports.
backend/src/main/java/com/calmquest/service/GeminiService.java - Cloudinary
backend/src/main/java/com/calmquest/service/CloudinaryService.java - Jitsi
Connections 22
- SPA bootstrap & routes → Route guards & OAuth callback: enforces routes
- Route guards & OAuth callback → Dashboard shell & state: admits users
- Dashboard shell & state → Frontend API services: uses
- Local emotion & voice capture → Frontend API services: logs results
- Chat dashboard → Frontend API services: sends chat
- Appointments & meetings → Frontend API services: books care
- Frontend API services → Spring Boot application: REST / JWT
- Spring Boot application → Security & JWT authorization: secures requests
- Security & JWT authorization → Identity & role service: authenticates
- Spring Boot application → Wellness assessment service: assessment APIs
- Spring Boot application → Chat service: chat APIs
- Spring Boot application → Community & care services: support APIs
- Identity & role service → JPA domain entities: users and roles
- Wellness assessment service → JPA domain entities: stores assessments
- Chat service → JPA domain entities: stores sessions
- Community & care services → JPA domain entities: stores workflows
- Recommendations & data seeding → JPA domain entities: seeds and recommends
- JPA domain entities → PostgreSQL: JPA persistence
- Chat service → Gemini: contextual replies
- Wellness assessment service → Gemini: AI reports
- Community & care services → Cloudinary: media uploads
- Appointments & meetings → Jitsi: joins meeting