How huynhlephcvinh/swp391_petsocial_petlover works
Project Type and Purpose
• This is a full-stack social networking web application (“DC Social Network”) for cat and dog lovers.
• Frontend is built with React (SPA) providing pages for posts, pets, exchanges, chat, admin dashboards, user authentication, payments, etc.
• Backend is a Spring Boot application exposing REST endpoints, handling security (JWT + OAuth2), processing payments (PayPal), managing media (Cloudinary), persisting data, and supporting real-time features via WebSocket.
File-Structure Analysis
• Top level:
• /frontend – React app with component hierarchy (pages, shared components, context providers, socket.js for real-time).
• /backend – Spring Boot service structured in config, controller, service/serviceImp, repository, model, payload, exception, websocket folders.
• Key patterns:
• MVC REST layer (Controller → Service → Repository → Database)
• Layered architecture: config components (security, JWT, OAuth2, PayPal, Cloudinary), service interfaces + implementations, data access (Spring Data JPA repositories), domain entities.
• Real-time messaging: WebSocketConfig, event listener, controllers and domain/dto/repository/service under websocket package.
• Deployment config: Maven wrapper, application.properties, React’s package.json.
README Insights
• Describes features: user auth, posting pets, admin moderation, item exchange, real-time chat/notifications, payment integration.
• Illustrates tech stack: Java, Spring Boot, React, WebSocket/STOMP, JWT, OAuth2, Cloudinary, PayPal.
a. Main Components
• User’s Browser (React SPA)
• REST API Layer (Spring Boot Controllers)
• Authentication & Authorization (JWT + OAuth2 Config)
• Business Logic Layer (Services)
• Data Layer (Spring Data Repositories → Relational DB)
• Real-Time Messaging Layer (WebSocket Endpoints + Message Broker)
• External Services: OAuth Providers (Google/Facebook), PayPal API, Cloudinary Media Storage
• Admin Dashboard Module (React)
b. Relationships & Interactions
• Browser ↔ REST API: HTTP(S) JSON calls via Axios (login, CRUD on posts/pets/exchanges/comments/reactions)
• Browser ↔ WebSocket: STOMP over WS for chat messages and notifications
• REST API ↔ Database: JPA repositories reading/writing entities
• REST API ↔ OAuth Providers: OAuth2UserService for social login
• REST API ↔ PayPal: PaypalService for payment orders and callbacks
• REST API ↔ Cloudinary: CloudinaryService for image upload URLs
• Service layer orchestrates calls between controllers, repositories, and external services
c. Architectural Patterns & Design Principles
• Layered Architecture (Presentation, Service, Data)
• Dependency Injection for decoupling config, controllers, services, repos
• Repository Pattern via Spring Data JPA
• Security separated into JwtProvider, JwtTokenValidator, SecurityConfig
• Real-time communication using WebSocketConfig + domain-specific controllers/services
d. Key Technologies & Frameworks
• Frontend: React, React Context, React Router, Axios, Socket.IO (or STOMP client)
• Backend: Spring Boot, Spring Security (JWT + OAuth2), Spring Data JPA, WebSocket (STOMP), Maven
• External: PayPal API, Cloudinary API, Google/Facebook OAuth2