How bishalspkt/share-my-desk works
Main Components Identification
a) API Layer
• Entry point (index.js and lib/server.js)
• Routes layer (routes/*.js files)
• Authentication middleware (JWT/Passport.js)
b) Service Layer
• AuthService
• DeskService
• OfficeLocationsService
c) Data Layer
• MongoDB (via Mongoose)
• Models (User, Desk)
• Static Data (officeLocations.json)
[Client Applications]
• ↓
[API Gateway/Load Balancer]
• ↓
[Express.js Server]
• ↙ ↓ ↘
[Routes Layer]
• ↙ ↓ ↘
[Services Layer]
• ↙ ↓ ↘
[Data Layer]
Specific Component Details
API Layer (Blue):
• Three main route handlers: AuthWs, DeskWs, OfficeLocationsWs
• JWT authentication flow
• Connection to Passport.js
Service Layer (Green):
• Three services: AuthService, DeskService, OfficeLocationsService
• Their interactions with models and static data
Data Layer (Yellow):
• MongoDB connection through Mongoose
• Two main models: User and Desk
• Static JSON data for office locations
Additional Elements
Supporting components:
• Logger utility (lib/logger.js)
• Constants configuration
• Utility functions (lib/utils.js, lib/webUtils.js)
Flow Representations
Key flows:
• Authentication flow (JWT token generation and verification)
• Desk sharing operations (listing, booking)
• Office location queries
Technical Details
Technical annotations:
• Express.js as the main framework
• Passport.js for authentication
• Mongoose for MongoDB ORM
• RAML for API documentation