How sairajsawant/comment-system works
Main Components
Frontend Layer:
• React Single Page Application (in /src directory)
• WebSocket Client Connection
• Component Structure (Auth, Comments, Registration)
Backend Layer:
• Node.js/Express Server (backend/server.js)
• Authentication Service (JWT)
• WebSocket Server
• Route Controllers
• Models Layer
Data Layer:
• MongoDB (Primary Database)
• Redis (Caching Layer)
[Client Tier]
• ↕
[Application Tier]
• ↕
[Data Tier]
Specific Component Details
Frontend (React):
[React SPA]
• Auth Component
• Comment List Component
• Add Comment Component
• Register Component
Backend (Node.js/Express):
[Express Server]
• Auth Routes
• Comment Routes
• Cache Routes
• WebSocket Handler
Data Layer:
[Redis Cache]
• ↓
[MongoDB]
• User Model
• Comment Model
Key Flows to Highlight
a) Authentication Flow:
Client → Auth Route → JWT Service → Token Verification Middleware
b) Real-time Comment Flow:
Client → WebSocket → Redis Cache → MongoDB
Additional Elements
• System boundaries to separate different services
• Docker container boundaries
• Important ports (27017 for MongoDB, 6379 for Redis)
Technical Details
• JWT token flow
• WebSocket event propagation
• Cache invalidation paths
• Database read/write paths
• API endpoints grouping