How atefoub/juggleflow works
Purpose and Topology
JuggleFlow is a school/association juggling-learning platform: a React PWA for students, teachers, and administrators backed by a Spring Boot REST API. It supports progressive paths, practice/progress tracking, gamification, classroom management, licensing, and GDPR workflows. The monorepo is orchestrated with Nx; primary app entry points are apps/frontend/src/main.tsx and apps/backend/src/main/java/com/juggleflow/backend/JuggleFlowApplication.java.
Frontend Application and Role Routing
The React 19/Vite frontend mounts the application, auth/query providers, and role-aware routing. Pages and layouts are partitioned by student, teacher, and administrator, creating the main client-side authorization/navigation boundary.
• apps/frontend/src/app/app.tsx
• apps/frontend/src/router/AppRouter.tsx
• apps/frontend/src/context/AuthContext.tsx
API Boundary and Backend Layers
Spring controllers expose REST endpoints, DTOs isolate HTTP contracts from JPA entities, and services contain domain rules. Repositories persist the model. This is the central request flow: browser API wrapper → controller → service → repository → PostgreSQL → response DTO.
• apps/backend/src/main/java/com/juggleflow/backend/controller/AuthController.java
• apps/backend/src/main/java/com/juggleflow/backend/service/ProgressService.java
• apps/backend/src/main/java/com/juggleflow/backend/repository/UserProgressRepository.java
Identity, Authorization, and Abuse Controls
Authentication uses access JWTs plus rotating refresh tokens in HttpOnly cookies. Spring Security/JWT filters establish identity and role access; token revocation and distributed rate limiting can use Redis. Production safety validation prevents dangerous bootstrap/public-doc/registration settings.
• apps/backend/src/main/java/com/juggleflow/backend/security/SecurityConfig.java
• apps/backend/src/main/java/com/juggleflow/backend/security/JwtFilter.java
• apps/backend/src/main/java/com/juggleflow/backend/config/ProdSafetyChecks.java
Pedagogical Domain and Progression
The durable core models users by establishment/class/role and connects tricks, learning paths and steps, individual/class assignments, practice sessions, progress, streaks, badges, favorites, daily challenges, and brain-module completion. Assignment resolution prioritizes individual student paths over class paths.
• apps/backend/src/main/java/com/juggleflow/backend/model/LearningPath.java
• apps/backend/src/main/java/com/juggleflow/backend/service/LearningPathService.java
• apps/backend/src/main/java/com/juggleflow/backend/service/PathAssignmentResolver.java
Offline-First PWA Synchronization
The client caches catalog/path and animation content and maintains local IndexedDB-backed state. Offline progress updates enter a queue and synchronize later through the service worker/Background Sync path; authentication requests remain network-only. UI exposes connectivity and sync state.
• apps/frontend/src/utils/offlineQueue.ts
• apps/frontend/src/utils/offlineCatalogueStore.ts
• apps/frontend/src/lib/pwaRegister.ts
Administration, GDPR, and Establishment Isolation
Admin services manage users, classes, resource uploads, license seat limits, audit events, parental consent, personal-data exports, and anonymization. Teacher operations are constrained by class access; establishment settings form a tenant/licensing boundary.
• apps/backend/src/main/java/com/juggleflow/backend/service/GdprService.java
• apps/backend/src/main/java/com/juggleflow/backend/service/AdminAuditService.java
• apps/backend/src/main/java/com/juggleflow/backend/service/EstablishmentLicenseService.java
Data, Runtime, and Deployment
Java 21/Spring Boot runs the API; PostgreSQL 17 is schema-managed by Flyway and Redis 7 supports production security state. The frontend is static PWA output served separately. Local/prod-like Compose and Kubernetes manifests provision PostgreSQL, Redis, backend, ingress, health probes, and database backups.
• apps/backend/src/main/resources/db/migration/V1__init_schema.sql
• docker-compose.yml
• k8s/30-backend.yaml
Main entry points: AuthController.java REST controllers · UserProgressRepository.java JPA repositories · main.tsx PWA application · docker-compose.yml Compose environment
Components 18
React PWA
Role-based learning client with offline support.
- PWA application
apps/frontend/src/main.tsx - Role-aware routing · Partitions student, teacher, and administrator views.
apps/frontend/src/router/AppRouter.tsx - Auth context
apps/frontend/src/context/AuthContext.tsx - Offline catalogue store · Caches catalogue, paths, and animation content.
apps/frontend/src/utils/offlineCatalogueStore.ts - Offline progress queue
apps/frontend/src/utils/offlineQueue.ts - Service worker sync · Background Sync sends queued progress when connected.
apps/frontend/src/lib/pwaRegister.ts
Spring Boot API
REST, security, and domain-service layers.
- REST controllers · DTO contracts isolate HTTP from JPA entities.
apps/backend/src/main/java/com/juggleflow/backend/controller/AuthController.java - Security & JWT filter · Authenticates JWTs and enforces role access.
apps/backend/src/main/java/com/juggleflow/backend/security/SecurityConfig.java - Progress service · Records practice, progress, streaks, badges, and challenges.
apps/backend/src/main/java/com/juggleflow/backend/service/ProgressService.java - Learning path resolution · Individual assignments override class paths.
apps/backend/src/main/java/com/juggleflow/backend/service/PathAssignmentResolver.java - Admin, licensing & GDPR · Manages tenant access, audits, consent, export, and anonymization.
apps/backend/src/main/java/com/juggleflow/backend/service/GdprService.java - JPA repositories · Persists users, classes, paths, assignments, and progress.
apps/backend/src/main/java/com/juggleflow/backend/repository/UserProgressRepository.java - Production safety checks · Rejects unsafe bootstrap, public-doc, and registration settings.
apps/backend/src/main/java/com/juggleflow/backend/config/ProdSafetyChecks.java
Data & Security State
- PostgreSQL · Schema and durable pedagogical/tenant data.
- Flyway schema migration
apps/backend/src/main/resources/db/migration/V1__init_schema.sql - Redis · Supports refresh-token revocation and distributed rate limits.
Deployment
- Compose environment · Provisions frontend, backend, PostgreSQL, and Redis.
docker-compose.yml - Kubernetes backend · Runs the API with ingress and health probes.
k8s/30-backend.yaml
Connections 21
- PWA application → Role-aware routing: mounts
- PWA application → Auth context: provides identity
- Role-aware routing → REST controllers: browser API calls
- Auth context → REST controllers: access JWT
- Offline catalogue store → PWA application: offline content
- Offline progress queue → Service worker sync: queued updates
- Service worker sync → REST controllers: sync progress
- REST controllers → Security & JWT filter: secured by
- Security & JWT filter → Redis: revocation and rate limits
- REST controllers → Progress service: progress requests
- REST controllers → Learning path resolution: path requests
- REST controllers → Admin, licensing & GDPR: admin workflows
- Progress service → JPA repositories: persists progress
- Learning path resolution → JPA repositories: resolves assignments
- Admin, licensing & GDPR → JPA repositories: manages tenant data
- JPA repositories → PostgreSQL: JPA persistence
- Flyway schema migration → PostgreSQL: initializes schema
- Production safety checks → REST controllers: validates startup
- Compose environment → PostgreSQL: provisions
- Compose environment → Redis: provisions
- Kubernetes backend → REST controllers: deploys