How artemelyashevich/mmf-ask works
Project Type and Purpose
• This is a standalone, monolithic web-API built with Spring Boot that simulates a StackOverflow-style Q&A system.
• It exposes REST endpoints for posts, comments, categories, programming languages, users, favorites and handles authentication/authorization (JWT + email activation), plus a WebSocket chat.
Architectural Overview
• Layered, MVC-style design:
• API Layer (Controllers + DTOs + Mappers)
• Service Layer (business logic + converters)
• Data Access Layer (Spring Data MongoDB Repositories + Entities)
• Cross-cutting Concerns (Security, Configuration, Utilities)
• External Integrations (MongoDB, SMTP/email sender, Prometheus metrics)
Main Components
a. Client → API Gateway
• Clients (e.g., web UI, Postman) issue HTTP(S) requests to REST controllers.
• WebSocket clients connect to the /ws/chat endpoint for real-time messaging.
b. Spring Boot Application
• API Layer
• Controllers (e.g., PostController, AuthController, ChatController)
• DTOs and Mappers for request/response translation
• Service Layer
• Business services (PostService, AuthService, ChatService, etc.)
• Converters for domain transformations
• Data Access Layer
• MongoDB repositories for each aggregate (PostRepository, UserRepository, CommentRepository…)
• Domain entities representing collections
• Security
• JWT filter chain, AuthenticationEntryPoint, AccessDeniedHandler
• CORS config, WebSocket STOMP security interceptor
• Configuration
• SwaggerConfig (OpenAPI docs)
• WebSocketConfig, CommandLineRunner for startup data
c. External Systems
• MongoDB (persistent storage)
• SMTP/Email server (activation/reset code delivery via Thymeleaf templates)
• Prometheus (scrapes /actuator/prometheus for metrics)
• Docker & docker-compose orchestration
Relationships and Data Flows
• WebSocket handshake from clients to ChatController → ChatService → ChatMessageRepository.
• JWT issuance by AuthService → User through EmailSender → external SMTP.
Architectural Patterns & Principles
• Layered Architecture (separation of concerns)
• DTO/Mapper pattern for API boundary
• Repository pattern (Spring Data) for persistence
• Dependency Injection (Spring) in controllers, services, repositories
• Eventual consistency / stateless services
• Real-time messaging via STOMP over WebSocket
Essential Elements to Capture
• Controllers → Services → Repositories → MongoDB
• Auth flow (registration → email activation → JWT issuance → secured endpoints)
• WebSocket chat flow
• Docker-compose relationships (app ←→ mongo)
• Monitoring (Prometheus ←→ /actuator)