How markandeshwaragoudapatil/api works
This is an Express/Mongoose user and product API. Clients register or log in to receive a JWT cookie; authenticated requests pass through route middleware to profile or product handlers, which call services and, for products and profiles, persist through models. Admin authorization protects product mutations. The README is empty, so the map reflects the source index and excerpts; the session-related modules are included, but their runtime wiring is not established by the shown code.
Main entry points: app.js Express app · productRoutes.js Product routes · jwtAuthMiddleware.js JWT authentication · profileService.js Profile service
Components 25
API routing
- Express app
app.js - Login routes
routes/loginRoutes.js - Registration routes
routes/registerRoutes.js - Logout routes
routes/logoutRoutes.js - Profile routes
routes/profileRoutes.js - Product routes
routes/productRoutes.js - Async wrapper
utils/asyncHandler.js - Application error
utils/AppError.js
Identity and access
- Login handler
controllers/loginController.js - Registration handler
controllers/registerController.js - Logout handler
controllers/logoutController.js - Profile handler
controllers/profileController.js - JWT authentication
middleware/jwtAuthMiddleware.js - Admin authorization
middleware/userAuthMiddleware.js - Auth middleware
middleware/authMiddleware.js - JWT utility
utils/jwt.js - Session service
services/loginService.js - Logout service
services/logoutService.js - Profile service
services/profileService.js
Product catalog
- Product handler
controllers/productController.js - Product service
services/productService.js
Data models
- Session records
models/Session.js - User records
models/User.js - Product records
models/productModel.js
Other components
- API client
Connections 28
- API client → Express app: sends requests
- Express app → Login routes: mounts routes
app.js - Express app → Registration routes: mounts routes
app.js - Express app → Logout routes: mounts routes
app.js - Express app → Profile routes: mounts routes
app.js - Express app → Product routes: mounts routes
app.js - Login routes → Login handler: routes to
routes/loginRoutes.js - Registration routes → Registration handler: routes to
routes/registerRoutes.js - Logout routes → Logout handler: routes to
routes/logoutRoutes.js - Profile routes → Profile handler: routes to
routes/profileRoutes.js - Product routes → Product handler: routes to
routes/productRoutes.js - Product routes → Async wrapper: wraps handlers
routes/productRoutes.js - Product routes → JWT authentication: authenticates with
routes/productRoutes.js - Product routes → Admin authorization: authorizes with
routes/productRoutes.js - Profile routes → JWT authentication: authenticates with
routes/profileRoutes.js - Logout routes → JWT authentication: authenticates with
routes/logoutRoutes.js - Login handler → Profile service: checks credentials
controllers/loginController.js - Login handler → JWT utility: creates token
controllers/loginController.js - Registration handler → Profile service: creates user
controllers/registerController.js - Registration handler → JWT utility: creates token
controllers/registerController.js - Profile handler → Profile service: gets profile
controllers/profileController.js - Product handler → Product service: calls operations
controllers/productController.js - Product service → Product records: reads and writes
services/productService.js - Product service → Application error: raises errors
services/productService.js - Profile service → User records: reads and writes
services/profileService.js - JWT authentication → Application error: raises errors
middleware/jwtAuthMiddleware.js - Session service → Session records: reads and creates
services/loginService.js - Logout service → Session records: uses sessions
services/logoutService.js