How khoavu1831/facebook_clone works
Project type and purpose
• This is a full‑stack “Facebook‑clone” social media application.
• Frontend: React SPA uses REST and WebSocket for UI, real‑time chat, posting, friend management.
• Backend: Spring Boot handles authentication, user/profile management, posts, comments, friends, real‑time messaging (STOMP over WebSocket).
• Database: JSON files in “database/” simulate persistent storage; likely will be replaced by a relational DB in production.
• File storage: “uploads/” directory for user‑uploaded images.
File structure
• Top level:
• /frontend → React application (components, pages, services, config)
• /backend → Maven‑based Spring Boot service (controller, service, repository, model, config)
• /database → JSON files representing data store
• /uploads → media storage
• Backend folders follow layered architecture (config, controller, service, repository, model).
• frontend/src configures API base URL, WebSocket client, React context for user state.
• Application.properties configures ports, CORS, WebSocket endpoints.
README for additional insights
• Commands to install and run frontend (npm install, npm start) and backend (mvn spring-boot:run).
• Mentions STOMP and SockJS for real‑time.
• Client (Web Browser) running React SPA
• Spring Boot Backend Service
• Data Store (JSON files or replaceable by RDBMS like MySQL/PostgreSQL)
• File Storage (uploads folder or external S3 bucket)
• Real‑time Messaging (WebSocket + STOMP endpoint)
• External services (e.g., authentication provider or CDN if any)
b. Relationships & interactions:
• React SPA → HTTP(S) REST calls → Spring Boot controllers
• React SPA → WebSocket (SockJS/STOMP) → Spring Boot WebSocketConfig → ChatController
• Spring Boot → Repository layer → Data Store
• Spring Boot → FileStorageService → Local uploads folder (or external)
• Sequence: User clicks “Post” → POST /posts → PostController → PostService → PostRepository → JSON DB → response → React updates UI
c. Architectural patterns & principles:
• Layered (Controller → Service → Repository → Model) in backend
• Component/Container in frontend (pages, UI components, context for state)
• Observer pattern via WebSocket subscriptions (chat messages)
• CORS configuration to allow cross‑origin between frontend and backend
d. Relevant technologies/frameworks:
• Frontend: React, Context API, STOMP.js, SockJS-client, Axios (or fetch), CSS modules
• Backend: Java, Spring Boot (Web, Data JPA if using RDBMS), Maven, WebSocket (STOMP), CORS
• Storage: Local file system (/uploads) or replaceable blob storage
• Mock DB: JSON files (could be MongoDB or SQL in future)