GeezerVison is showing github.com โ GitHub - mfarim/spring-elearning-react: E-Learning for online examination at Junior high school
Folders and files| Name | Name | Last commit message | Last commit date |
|---|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Repository files navigation๐ Spring E-Learning & CBT Platform

๐ฎ๐ฉ Baca dalam Bahasa Indonesia
๐ Looking for the Laravel & Livewire edition? A companion monolithic edition built with Laravel 13, Livewire 3, and Laravel Reverb is available at: https://github.com/mfarim/laravel-elearning
A full-featured web-based E-Learning and Computer Based Test (CBT) platform for managing modern academic learning activities between Admin, Teacher, and Student. Built as a containerized modular monolith with a decoupled SPA frontend: Java 21 LTS, Spring Boot 3.5+, React 19, and Tailwind CSS v4, featuring stateless JWT authentication with Redis-backed refresh-token rotation and impersonation, WebSocket STOMP real-time candidate proctoring, and Apache POI Excel batch processing.
| Feature |
Description |
| Dashboard |
Real-time statistics overview: teachers, students, classrooms, subjects, CBT metrics |
| Teachers |
Full CRUD with automatic user account provisioning & NIP validation |
| Students |
CRUD + classroom filtering + ๐ฅ Excel Batch Import (.xlsx) + Exam Cards Print |
| Classrooms |
CRUD + homeroom teacher assignment + capacity & academic year management |
| Subjects |
CRUD + subject code + credit units + assigned teacher mapping |
| Announcements |
CRUD + multi-target broadcasting (All / Teacher / Student) + publish toggle |
| Impersonation |
Instant one-click login as teacher or student for administrative debugging |
| Security |
Spring Security 6 stateless JWT tokens, BCrypt hashing, and method-level @PreAuthorize |
๐จโ๐ซ Teacher Panel
| Feature |
Description |
| Dashboard |
Teaching metrics, scheduled examinations, active assignments, and recent activity |
| Learning Materials |
CRUD + multi-type content (Document, Video, Text, Link, Audio) + student view tracking |
| Assignments |
CRUD + deadline dates + instructions + submission grading with feedback |
| CBT Examinations |
CRUD + duration timer + passing grade (KKM) + randomize questions/options + retry toggles |
| Question Builder |
Multiple Choice (A-E), True/False, Essay + points allocation + ๐ฅ Excel Import |
| Live Telemetry Monitor |
Real-time WebSocket candidate status, question progress bar, and anti-cheat flag alerts |
| Exam Hall Tickets |
Print ready-to-use official CBT student candidate cards with NIS barcodes |
๐จโ๐ Student Panel โ Mobile-First Design
| Feature |
Description |
| Home Dashboard |
Responsive mobile drawer, upcoming exams countdown, active assignments, announcements |
| Learning Modules |
Browse, read, and download structured course materials per enrolled subject |
| Assignment Hub |
View assignment instructions + file upload dropzone + feedback review |
| CBT Exam Room |
Fullscreen examination runner with countdown timer, anti-cheat detection, and auto-submit |
| Grades & GPA Summary |
Subject average breakdown, progress bars, and passing grade pass/fail status |
๐ฅ๏ธ CBT Exam System Workflow
Exam List โ Confirmation & Instructions โ Secure Exam Runner
โโโ โฑ๏ธ Synchronized Timer (auto-submit on expiry)
โโโ ๐ Anti-Cheat Proctoring (fullscreen & tab change alerts)
โโโ ๐ Color-Coded Question Palette (answered / remaining)
โโโ ๐พ Instant Auto-Save (on every option selection)
โโโ ๐ Real-Time Proctor Telemetry (WebSocket push to teacher)

| Dashboard |
Teachers Management |
 |
 |
| Students Management |
Classrooms Management |
 |
 |
| Subjects Management |
Announcements |
 |
 |
๐จโ๐ซ Teacher Panel
| Dashboard |
Learning Materials |
 |
 |
| Assignments Management |
CBT Examinations |
 |
 |
| Question Builder & Bank |
 |
๐จโ๐ Student Panel (Mobile-First Design)
| Home Dashboard |
Learning Materials |
Assignments Hub |
 |
 |
 |
| Examination Room |
Grades & Report Card |
 |
 |
| Layer |
Technology |
| Backend Core |
Java 21 LTS, Spring Boot 3.5.7 |
| Security & Auth |
Spring Security 6, JJWT 0.12.6, Method Security (@PreAuthorize), Impersonation Engine |
| Persistence |
PostgreSQL 16, Spring Data JPA, Hibernate 6, HikariCP, Flyway Migrations |
| Token Store & Realtime |
Redis 7 (refresh-token rotation, optional shared rate limits and cross-instance events), Spring WebSocket + STOMP (in-memory simple broker), SockJS |
| File Storage |
Local Docker volume or S3-compatible object storage (AWS S3, MinIO) |
| Batch Processing |
Apache POI (Excel .xlsx batch parsing for Students & Question Banks) |
| API Documentation |
Springdoc OpenAPI 3 / Swagger UI (/swagger-ui/index.html) |
| Frontend Core |
React 19, TypeScript 5+, Vite 6 |
| Styling |
Tailwind CSS v4 (Native CSS engine with @tailwindcss/vite) |
| State Management |
Zustand 5, Axios with JWT interceptors |
| Icons & UI |
Lucide React |
| Deployment |
Docker Compose, Multi-stage Dockerfiles (OpenJDK 21 Alpine & Node 22 Alpine), Nginx 1.28 |
๐๏ธ High-Level System Architecture
The platform is a modular monolith (one Spring Boot service split into domain modules) with a separate React SPA, deployed as Docker containers on a VPS behind Cloudflare, with defense-in-depth at every layer. Data model, request flows, design decisions, and scaling limits are documented in docs/ARCHITECTURE.md.
graph TD
Client["๐ Clients / Web Browsers<br/>(Admin, Teacher, Student)"]
subgraph Edge ["๐ก๏ธ Perimeter & Edge Layer"]
CF["Cloudflare Edge Proxy<br/>โข WAF & DDoS Shield<br/>โข SSL/TLS Termination<br/>โข CF-Connecting-IP Passthrough"]
end
subgraph Host ["๐ฅ๏ธ VPS Host Server"]
Nginx["Host Reverse Proxy / Nginx<br/>โข Port 80/443 Loopback (127.0.0.1)<br/>โข Security Headers (nosniff, SAMEORIGIN)<br/>โข Actuator Endpoints Blocked (404)"]
subgraph DockerNet ["Docker Network (elearning-network)"]
Frontend["๐ฆ elearning-frontend<br/>React 19 SPA + Vite + Tailwind v4"]
Backend["โ elearning-backend<br/>Java 21 LTS + Spring Boot 3.5.7<br/>โข Spring Security 6 (Stateless JWT)<br/>โข Bucket4j Login Rate Limiting (A07)<br/>โข STOMP WebSocket (in-memory simple broker)<br/>โข Apache POI with Batch Guards"]
Postgres[("๐ elearning-postgres<br/>PostgreSQL 16 Relational DB<br/>โข Flyway Automated Migrations<br/>โข HikariCP Connection Pool")]
Redis[("โก elearning-redis<br/>Redis 7<br/>โข Refresh-token store<br/>โข Rotation & revocation by jti")]
Storage[("๐ backend_storage<br/>Persistent Docker Volume<br/>โข Uploads (/app/storage/uploads)<br/>โข File Extension Whitelisting")]
end
end
Client -->|HTTPS / WSS| CF
CF -->|Proxied Traffic| Nginx
Nginx -->|Static Assets| Frontend
Nginx -->|/api/ & /ws| Backend
Backend -->|HikariCP / JPA| Postgres
Backend -->|Refresh tokens| Redis
Backend -->|Safe File I/O| Storage
Loading
๐ Security & OWASP Top 10 Mapping
| OWASP Standard |
Mitigation in this Platform |
| A01: Broken Access Control |
Method-level security (@PreAuthorize) on all administrative and user directory endpoints; classroom ownership validation preventing IDOR on assignments and discussions; STOMP WebSocket ChannelInterceptor verifying teacher/admin privileges. |
| A02: Cryptographic Failures |
BCrypt password hashing; HMAC-SHA256 JWT tokens with mandatory 256-bit+ secret key validation on application boot; automated fail-fast if JWT_SECRET is missing. |
| A03: Injection |
100% parameterized Spring Data JPA queries eliminating SQL Injection; no OS command execution; strict input DTO @Valid constraints. |
| A04: Insecure Design |
Examination answer keys and explanations strictly stripped (null) from student payloads; examination duration deadlines enforced on the server-side, not trusting client clocks. |
| A05: Security Misconfiguration |
Spring Boot Actuator endpoints strictly blocked (404) from public Nginx reverse proxy; all Docker service ports bound to loopback 127.0.0.1; security headers (X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN) enforced. |
| A06: Vulnerable Components |
Java 21 LTS, Spring Boot 3.5.7, PostgreSQL 16, Redis 7, React 19. Multi-stage Docker containers running under non-root spring:spring user. |
| A07: Identification Failures |
Bucket4j Login Rate Limiter: 5 attempts per minute per IP address (CF-Connecting-IP / X-Forwarded-For) and per account email, returning 429 Too Many Requests with Retry-After header. |
| A08: Software & Data Integrity |
Strict file upload extension whitelist (.pdf, .docx, .xlsx, .jpg, .png, etc.); executable and scriptable types (.html, .svg, .exe, .sh) explicitly rejected to prevent Stored XSS; safe download Content-Disposition. |
| A09: Logging & Monitoring |
Anti-cheat proctoring violation alerts logged with student NIS; internal /actuator/health probe available for container healthchecks. |
| A10: SSRF |
Zero user-controlled outbound HTTP requests from backend services. |
๐๏ธ Real-Time Telemetry & WebSocket Architecture
The live examination monitoring feature uses Spring WebSocket with STOMP and Spring's in-memory simple broker to push candidate progress to the teacher in real time. Answers and attempts are persisted in PostgreSQL first, then an event is broadcast. Moving to a Redis/RabbitMQ broker relay for multi-instance deployments is on the roadmap (see docs/ARCHITECTURE.md).
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Candidate in โโโโโโโโถโ Spring Controller โโโโโโโโถโ PostgreSQL โ โ โ
โ Exam Runner โ โ /api/v1/exams/... โ โ (attempts, answers) โ โ Spring STOMP โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ Message Broker โ
โ โ (/ws/cbt) โ
โ messagingTemplate.convertAndSend() โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโถโ โ
โโโโโโโโโโฌโโโโโโโโโโ
โ
Real-time Telemetry Push โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Teacher Proctoring โ
โ Monitor Dashboard โ
โ โ Instant auto-update โ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
| File / Component |
Purpose |
backend/.../WebSocketConfig.java |
Configures STOMP endpoints (/ws/cbt) and message broker destinations (/topic, /app) |
backend/.../ExamTelemetryMessage.java |
DTO representing real-time candidate heartbeat, progress, and anti-cheat violations |
backend/.../ExamService.java |
Broadcasts telemetry updates upon student answers, time alerts, and submission events |
frontend/src/pages/exams/ExamMonitor.tsx |
Proctoring dashboard with STOMP/SockJS client listener and candidate progress cards |
frontend/src/pages/exams/ExamRunner.tsx |
Secure candidate runner detecting window blur, tab switching, and fullscreen lock |
๐ Installation & Quick Setup
- Docker & Docker Compose
- Java 21 LTS (for local backend development)
- Node.js 22+ (for local frontend development)
Quick Setup (Docker Compose โ Recommended)
# Clone the repository
git clone https://github.com/mfarim/spring-elearning-react.git
cd spring-elearning-react
# Generate a JWT signing secret (required, no default)
echo "JWT_SECRET=$(openssl rand -base64 32)" > .env
# Launch full stack (PostgreSQL 16, Redis 7, Spring Boot backend, and React frontend)
docker compose up -d
# (Optional) Seed realistic demo data (teachers, classrooms, subjects, exams)
docker exec -i elearning-postgres psql -U postgres -d elearning < backend/src/main/resources/db/migration/seed_demo_data.sql
Access the services:
For contribution guidelines and coding standards, see CONTRIBUTING.md.
Manual Setup (Local Development)
docker compose up -d postgres redis
2. Start Backend (Spring Boot)
cd backend
# JWT_SECRET must be set (same value as in .env)
export $(grep JWT_SECRET ../.env)
./mvnw clean spring-boot:run
3. Start Frontend (React + Vite)
cd frontend
npm install
npm run dev
The database comes pre-seeded with ready-to-test accounts for each academic role:
Quick Demo Login buttons are also available directly on the login screen for instant one-click access.
๐ฅ Student Excel Import Format
The student batch importer accepts standard .xlsx spreadsheets with the following columns:
| Column Header |
Required |
Example Value |
Description |
| Name |
โ
|
Andi Pratama |
Student's full registered name |
| Email |
โ
|
[email protected] |
Unique login credential email |
| NIS |
โ
|
20250001 |
Student identification number (unique barcode identifier) |
| Classroom |
โ
|
X IPA 1 |
Target classroom name |
| NISN |
โ |
0012345678 |
National student identification number |
| Gender |
โ |
L / P (or M / F) |
Gender identification |
| Address |
โ |
Jl. Merdeka No. 45 |
Residential home address |
๐งช Testing & Validation
Frontend Build & Lint Check
cd frontend
npm run build
spring-elearning-react/
โโโ backend/
โ โโโ src/main/java/com/elearning/
โ โ โโโ config/ # Spring Security filter chain, WebSocket/STOMP config
โ โ โโโ security/ # JWT provider & filter, refresh-token store, rate limiting
โ โ โโโ common/ # Base entity, response wrappers, exception handler
โ โ โโโ modules/
โ โ โโโ auth/ # Login, refresh, logout, password change, impersonation
โ โ โโโ user/ # Users, Teachers, Students
โ โ โโโ academic/ # Classrooms, Subjects
โ โ โโโ announcement/ # Announcements
โ โ โโโ material/ # Learning Materials & Material Views
โ โ โโโ assignment/ # Assignments, Submissions, Discussions
โ โ โโโ exam/ # CBT Exams, Question Bank, Attempts, Telemetry
โ โ โโโ grade/ # Grade summaries
โ โโโ src/main/resources/
โ โโโ db/migration/ # Flyway SQL schema migrations & seeders
โ โโโ application.yml # Spring Boot profile configurations
โโโ frontend/
โ โโโ public/ # Favicons, App Logo, OG Banner image
โ โโโ src/
โ โ โโโ api/ # Axios HTTP client with JWT auto-refresh interceptors
โ โ โโโ components/ # Common Layout, Sidebar, Top Navbar, ProtectedRoute
โ โ โโโ pages/ # Admin, Teacher, Student, CBT Runner, Exam Monitor
โ โ โโโ store/ # Zustand authentication & state management
โ โ โโโ types/ # TypeScript interfaces & DTO schemas
โ โโโ index.html # Semantic HTML with complete OpenGraph & JSON-LD SEO
โ โโโ vite.config.ts # Vite 6 config with Tailwind CSS v4 native plugin
โโโ docs/ARCHITECTURE.md # Data model, sequence diagrams, design decisions, scaling limits
โโโ screenshots/ # Application showcase captures across roles
โโโ docker-compose.yml # Multi-container orchestration definition
๐ข Production Deployment
For production deployments:
- Use the optimized multi-stage
backend/Dockerfile and frontend/Dockerfile.
- Configure external production PostgreSQL and Redis connection strings in environment variables (
SPRING_DATASOURCE_URL, SPRING_DATA_REDIS_HOST).
- Set a strong JWT secret (
JWT_SECRET) with a minimum of 256 bits.
- Deploy behind Nginx or Cloudflare with SSL/TLS termination and WebSocket header forwarding (
Upgrade and Connection headers).
- Add your public domain to
APP_CORS_ALLOWED_ORIGINS (also used as the allowed WebSocket origins).
- Default accounts must change their password on first login. Set
APP_DEMO_MODE=true only on a public demo instance with shared demo accounts.
- Keep
SPRINGDOC_ENABLED=false and APP_REGISTRATION_ENABLED=false unless you need them.
- The refresh token is an httpOnly
Secure cookie, so serve the app over HTTPS. Set APP_REFRESH_COOKIE_SECURE=false only for plain-HTTP local runs (the local docker-compose.yml already does).
- The SPA sends a Content-Security-Policy. If you enable analytics, allow its hosts on the frontend container, e.g.
CSP_SCRIPT_SRC_EXTRA="https://www.googletagmanager.com" and CSP_CONNECT_SRC_EXTRA="https://*.google-analytics.com".
- Several backend instances: set
APP_REALTIME_MODE=redis, APP_RATE_LIMIT_STORE=redis, and APP_STORAGE_TYPE=s3 with APP_STORAGE_S3_BUCKET (plus APP_STORAGE_S3_ENDPOINT and APP_STORAGE_S3_PATH_STYLE=true for MinIO), and enable sticky sessions for /ws. Details in docs/ARCHITECTURE.md.
- Real client IP / rate limiting: the backend trusts
X-Forwarded-For only from internal proxies (Docker network). If the site is behind Cloudflare, restore the visitor IP on the host Nginx, otherwise all users share Cloudflare's IPs for rate limiting:
# http {} block of the host nginx โ keep the list in sync with https://www.cloudflare.com/ips/
set_real_ip_from 173.245.48.0/20; # ...add every Cloudflare IPv4/IPv6 range
real_ip_header CF-Connecting-IP;
# and in the proxied location:
proxy_set_header X-Forwarded-For $remote_addr;
This project is open-sourced software licensed under the MIT license.
AboutE-Learning for online examination at Junior high school TopicsResourcesContributingStars4 stars Watchers0 watching Forks
|