How sriyakat/nodejs-auth-system works
This is an Express authentication and product-management API. Clients register, log in, and use access tokens to reach protected profile, admin, and product endpoints; product operations return records through the API. Authentication includes password hashing, token issuance and refresh-token persistence, logout, and password reset. Product CRUD is a separate domain branch, with admin-only writes. The graph follows the sampled route, controller, service, repository, and database layers; product-repository behavior is represented from its indexed database reference, while unsampled details are omitted.
Main entry points: auth.routes.js Auth routes · app.js Express app · product.routes.js Product routes · db.js SQL connection pool
Components 15
API runtime
- HTTP server
server.js - Express app
src/app.js
Authentication
- Auth routes
src/modules/auth/auth.routes.js - Input validation
src/modules/auth/auth.validation.js - Auth controller
src/modules/auth/auth.controller.js - Auth service
src/modules/auth/auth.service.js - Token and role guards
src/middleware/auth.middleware.js
Product management
- Product routes
src/modules/product/product.routes.js - Product controller
src/modules/product/product.controller.js - Product service
src/modules/product/product.service.js
Persistence
- Auth repository
src/modules/auth/auth.repository.js - Product repository
src/modules/product/product.repository.js - SQL connection pool
src/config/db.js
Other components
- API client
- SQL Server
Connections 16
- API client → Express app: sends HTTP
src/app.js - HTTP server → Express app: listens on
server.js - Express app → Auth routes: mounts auth
src/app.js - Express app → Product routes: mounts products
src/app.js - Auth routes → Input validation: validates input
src/modules/auth/auth.routes.js - Auth routes → Auth controller: dispatches handlers
src/modules/auth/auth.routes.js - Auth routes → Token and role guards: guards routes
src/modules/auth/auth.routes.js - Auth controller → Auth service: calls
src/modules/auth/auth.controller.js - Auth service → Auth repository: executes auth actions
src/modules/auth/auth.service.js - Auth repository → SQL connection pool: uses SQL pool
src/modules/auth/auth.repository.js - Product routes → Product controller: dispatches handlers
src/modules/product/product.routes.js - Product routes → Token and role guards: guards routes
src/modules/product/product.routes.js - Product controller → Product service: calls
src/modules/product/product.controller.js - Product service → Product repository: executes product actions
src/modules/product/product.service.js - Product repository → SQL connection pool: uses SQL pool
src/modules/product/product.repository.js - SQL connection pool → SQL Server: connects to
src/config/db.js