How davidchau21/eforum-blog-web works
Main Components Identification
a. Client/Frontend Layers:
• User Interface (Frontend): Located in the “frontend” directory, it is built with React (using Vite), TailwindCSS, and uses Axios for API connections. It provides pages for the forum (posts, chat, notifications, profile, etc.).
• Admin Interface (Admin-web): Found in the “admin-web” directory, this is also a React-based application that provides administrative capabilities (user and post management, statistics, content moderation, etc.). Notice that it has its own set of API calls and state management.
b. Backend API Services:
• REST API and Business Logic: The “backend” and “server” directories both implement the core API servers using Express. They are structured with routers, controllers, middleware (e.g., verifyToken), and models/schemas (for Blogs, Comments, Users, etc.), which suggests a layered (MVC-like) architecture.
• Real-Time Messaging: Both backend directories include “socket” modules using socket.io to support realtime chat and notifications.
c. External Services & Integrations:
• Database: MongoDB is used as the primary data store for forums (posts, comments, notifications, etc.). The schemas in both backend/server directories indicate document-based models.
• Cloud Storage & Third-party APIs: AWS S3 for image/storage, Firebase for Google authentication integration, and integration with Google API (via googleapis package) are used.
• Email Services: Various services are integrated (nodemailer, mailtrap, brevo, oauth2) for mail functionalities including OTP and password resets.
Relationships and Interactions Between Components
• Both frontends (user and admin) communicate with the backend REST API using HTTP (Axios in the frontend) to fetch/post data.
• Socket.io connections are established between the client apps and the backend to handle realtime messaging.
• The API layer (backend/server) interacts with the MongoDB database for data persistence and retrieval.
• The backend also calls external services (AWS S3, Firebase, various email services, Google API) as needed.
• Modular components inside the backend (controllers, routers, services, middleware) indicate a separation of concerns where HTTP requests follow a request–response pattern and realtime communications use socket connections.
Architectural Patterns and Design Principles
• Separation of Concerns: Clear delineation between the user interfaces (frontend vs. admin-web) and business logic (backend/server controllers and routers).
• Layered Architecture: For backend components (routers handling endpoints, controllers managing business logic, services for external integrations, and models/schemas for data management).
• Realtime Communication: Use of socket.io shows an event-driven pattern for chat and notifications.
• External Integration: Direct connections from the API layer to services like AWS, Firebase, and email providers are critical.