How quangngonz/isph-stock-exchange-express-clientapi works
Main Components
• API Server: Represent the Node.js/Express server (the entry point is server.js). This component handles incoming HTTP requests, routing them to the appropriate controllers.
• Controllers: Group these as distinct functional units (admin, teacher, user, stocks, transactions) that process business logic and interact with services.
• Routes: Map each controller to a set of defined endpoints (e.g., /admin, /teacher, /user, /stocks, /health) that detail the exposed endpoints of your API.
• Middleware: Highlight components such as authentication (authMiddleware.js) and role verification middleware (roleMiddleware.js) that secure the endpoints.
• Services: Identify auxiliary services that handle specialized tasks such as evaluating events (evaluateEventService.js), managing WebSocket connections (webSocketServer.js), and integrating with Firebase (firebaseService.js).
• Database Layer: While the project relies on Firebase for real-time data and authentication, also include the DBML-defined schema (from database.dbml) that outlines relational or structured data concepts (like Users, Stocks, Portfolios, Transactions, etc.). This illustrates that even if Firebase is main, the design is supported by a detailed database schema.
• Deployment/Configuration: Include aspects such as Vercel and Heroku configurations (Procfile, vercel.json) to indicate deployment and environment settings.
Relationships and Data Flow
• Controllers should show connections to Middleware, ensuring that each request is authenticated and authorized before processing.
• From Controllers, indicate how the business logic is delegated to Services for tasks like connecting to Firebase or handling real-time events.