How youngyangyang04/kamanotes works
Project type and purpose
• Full-stack web application: “Kama Notes” is an online knowledge-sharing and note platform for programmers.
• Frontend: React + TypeScript app (user and admin interfaces).
• Backend: Spring Boot REST API + WebSocket, MyBatis persistence, Redis caching, file storage, scheduler and email tasks.
Top-level architecture components
a. Frontend
• User App (domain/user sections, note listings, comments, messaging)
• Admin App (category, question, user, dashboard management)
• Shared base components, domain services, state store (Redux)
b. Backend
• REST controllers (com.kama.notes.controller) exposing HTTP endpoints
• WebSocket handler (realtime messaging & notifications)
• Service layer (business logic)
• Data access layer (MyBatis mappers + XML)
• Configuration (security, web, Redis, scheduler)
• AOP aspects (NeedLogin, trace ID injection)
• Filters/interceptors (authentication, trace IDs)
• Scheduled tasks (email verification, daily stats)
• Event listeners (internal message events)
• Utilities (JWT, Markdown, file handling)
c. External systems & infrastructure
• MySQL database (note data, users, comments, stats)
• Redis cache (session tokens, rate limiting, hot data)
• Local file system (image/note attachments)
• SMTP/email server (via Spring Email tasks)
• WebSocket clients in browser
• Build/deployment: Docker (Dockerfile in front & back), Maven, Vite
Relationships and data flows
• Browser → HTTP(S) → Spring Boot REST API
• Browser ↔ WebSocket ↔ Spring Boot WebSocket handler
• REST API ↔ MyBatis → MySQL
• Service layer ↔ Redis for caching & sessions
• Service layer ↔ Local file system (upload/download)
• Scheduled tasks (via SchedulerConfig) publish Spring events → handlers for email and statistics
• REST API issues events to WebSocket handler for push notifications
Architectural patterns and principles
• Layered architecture (Controller → Service → Mapper → DB)
• MVC on backend, component/domain driven on frontend
• AOP for cross-cutting concerns (authentication, logging/tracing)
• Event-driven internals (Spring events + listeners)
• Token-based stateless auth (JWT + Spring Security)
• Caching for performance (Redis)
• Scheduled batch jobs for async tasks
Detail level
• Backend sub-components as collapsible:
• “Auth & AOP” (NeedLoginAspect, TokenInterceptor)
• “Scheduler & Tasks” (EmailTaskConsumer, DailyStatistics)
• “Event Bus” (MessageEvent → MessageEventListener → WebSocket push)
• Admin vs. user routes if desired
• Configuration (application-dev.yaml, Dockerfiles)