How anwarmoussaoui/makefriends works
Project Type & Purpose
• Full-stack social media platform (“MakeFriends”).
• Frontend: Next.js (React, SSR/CSR).
• Backend: Spring Boot microservice with REST controllers, JWT security, WebSocket chat, file storage, and a relational database.
File Structure
• front/
– Next.js app, pages, components, API calls
• back/ (Maven)
– src/main/java/com/workshop/back:
• Controller: REST endpoints (AuthenticationRequest/Response, UserController, PostController, MessageController, ProfileController, etc.)
• Service: Business logic layers (AuthenticationService, UserService, PostService, MessageService, ProfileService, StorageService)
• Repository: Spring Data JPA Repos for Entities (User, Post, Comment, Like, Message, FileData, ImageData, ProfileSett, etc.)
• Entity/DTO: JPA Entities and Data Transfer Objects
• config: Spring Security (JwtService, JwtAuthenticationFilter, SecurityConfig), CORS config, WebSocketConfig & ChatWebSocketHandler
– resources/application.properties: DB and JWT settings
Key Architectural Patterns
• Layered (Controller → Service → Repository → DB)
• JWT-based stateless authentication filter
• WebSocket for real-time chat
• File storage (blob/images via StorageService and StorageRepository)
Main Components
A. Frontend (Next.js client)
B. API Gateway / Backend REST Service (Spring Boot)
1. Authentication Controller (login/signup)
2. User/Post/Comment/Follow Controllers
3. Business Services
4. Data Repositories
C. WebSocket Chat Service
D. Database (e.g., MySQL/PostgreSQL)
E. File Storage (local disk or cloud blob store)
Relationships & Data Flow
• HTTP(S) calls: Next.js → Spring Boot REST controllers → Services → Repositories → Database
• JWT flow: Login request → JwtAuthentificationFilter → JwtService issues token → Token sent with each API call → SecurityConfig validates
• WebSocket: Next.js WS client ↔ ChatWebSocketHandler → MessageService → MessagRepository
• File upload/download: Next.js → StorageService → StorageRepository → File system / Blob
Final Checklist
– Call out JWT auth flow next to the SecurityConfig block
– Group Controllers, Services, Repositories inside the Spring Boot boundary