How marienoir/ims-api works
Project type and purpose
• This is a back-end REST API for an Inventory Management System (IMS) written in Node.js/Express with PostgreSQL as the primary datastore. It also uses Redis for caching and Node-Cron for scheduled tasks. Its clients will be admin and user front-ends (web/mobile).
File structure and README
• Top-level:
• package.json, .babelrc, .eslintrc.json → Node/JS configuration
• migrations/… and migrations/sqls/… → database schema and seed management
• src/config → environment, database, Redis, logging
• src/router → Express route definitions
• src/middleware → authentication, validation, caching, pagination, business-rule checks
• src/controller → HTTP request handlers by resource (user, purchase, sales, refund, stock, auth)
• src/services → business logic, Cron scheduler
• src/db/queries → SQL query abstractions
• src/utils, src/validation → shared helpers and schema validations
• README confirms the API’s core features and technology stack.
Main components
a. External clients (Admin Dashboard, User App)
b. API Gateway / Load Balancer (optional if scaled horizontally)
c. Express Application
• Router Layer
• Middleware Layer (Auth, Validation, Caching, Pagination, ProductCheck)
• Controller Layer
• Service Layer (including Cron Scheduler)
• Data-access Layer (DB Queries module)
d. PostgreSQL Database
e. Redis Cache
f. Logger (e.g., Winston)
g. Environment Configuration (dev/test/prod)
h. CI/CD / Migration subsystem (migrations + seeds)
i. External Postman Documentation (optional)
Relationships and data flows
• Client → HTTP(s) → Load Balancer → Express Router
• Router → Middleware Chain → Controller
• Controller → Service
• Service → Queries → PostgreSQL
• Middleware Cache → Redis (GET/SET)
• Service (or Cron) → Redis for cache invalidation or lookups
• Cron Scheduler → Service → Database (periodic reporting tasks)
• Logger intercepts at various layers to record application logs
• Migration subsystem applies schema changes to PostgreSQL
Architectural patterns & design principles
• Layered Architecture: clear separation of concerns (API → Business → Data)
• Repository Pattern: db/queries abstracts raw SQL
• Middleware Pattern: cross-cutting concerns (auth, caching)
• Scheduler Pattern: Node-Cron jobs decoupled from request flow
Essential elements
• Component names and directory references for traceability
• A note on the migration/seed subsystem as part of the deployment pipeline