How envedupnu/envedu_server works
Project Type and Purpose
• This is a Java Spring Boot monolithic backend for a “Smart Environmental Education” platform.
• It ingests real-time sensor data from Arduino-based devices, persists it, and provides REST/WebSocket APIs for students, educators, and admins to monitor and manage devices and data.
High-Level Architecture Components
a. NGINX (Reverse Proxy & SSL)
b. Spring Boot Application (single WAR/JAR)
• Controller Layer (REST + WebSocket)
• Service Layer (business logic)
• Repository Layer (Spring Data JPA)
• Cross-cutting concerns: Security (JWT + Filters), Cookie utils, Exception handling
c. Relational Database (ERD in README)
d. Redis (authentication codes, planned message queue)
e. AWS S3 (object storage for file uploads)
f. External Open APIs (air/ocean quality)
g. Slack (log notifications/alerts)
Internal Modules (Spring Boot)
• Authentication & Authorization
• JWT filters, CorsConfig, SecurityConfig, PrincipalDetailsService
• Redis for storing verification codes
• User Management
• Student, Educator, InviteCode, relationships via Student_Educator
• Controllers: UserAuthorizeController, UserRegisterController, UserLogoutController
• Admin Management
• AdminController, AdminService, AdminCipher
• Device Management
• UserDeviceController, UserDeviceService, DeviceUpdateDTO, repository
• Data Ingestion & Persistence
• DataUploadController & Service → writes “Seed” entries
• SeedController & WebSocket/MessageController for real-time pushes
• Data Control Subsystems (each with Controller, Service, Repository, Entities)
• DataChunk (data compilation, educating classes, units)
• DataChart (custom charts, chart types, properties)
• DataClassroom (classroom, chapters, answers)
• DataFolder (hierarchical data folders)
• DataLiteracy (custom data sets, Redis-backed entities)
• Survey
• SurveyController, SurveyService, entities for questions & answers
• OpenAPI Integration
• OpenApiController, OpenApiService, repository with custom impl for air/ocean quality
• AWS & Multipart
• AwsService, S3Config, MultipartConfig
• Mail Service (MailService)
• Redis Service (RedisConfig, RedisService)
Relationships & Data Flows
• Client → NGINX → Spring Boot REST/API endpoints
• WebSocket traffic (seed socket) connects via NGINX to Spring Boot’s WebSocketConfig
• Spring Boot ↔ RDB (Hibernate/JPA) for persistent entities (Users, Devices, Seed, etc.)
• Spring Boot ↔ Redis for ephemeral data (auth codes, planning queue)
• Spring Boot → AWS S3 for file/object storage
• Spring Boot → External Open APIs → internal DTOs/entities → DB
• Spring Boot → Slack via webhook/service for log/alert messages
Architectural Patterns & Principles
• Layered architecture (Controller → Service → Repository)
• DTO conversion layer between Controllers and Services
• Spring MVC + WebSocket for real-time and REST interfaces
• JWT-based stateless authentication with filters
• Centralized configuration (application.yml, Spring @Configuration)
• Separation of concerns via clearly named packages
• Use of Spring Data JPA repositories and custom Query/Impl where needed
Essential Elements
• Clear component names (e.g., “DataFolderService”, “RedisService”)
• Notes for planned features (e.g., “Redis as MQ – future”)