How ahsanhanif657/supermarket-backend works
This is a small Express backend for supermarket product CRUD, backed by SQLite. A client request enters through the server, is routed to product handlers, and reads or changes product records before receiving a response. Category CRUD is also implemented in separate routes and handlers, with validation on category creation and updates, but index.js does not mount those routes. The sampled database setup creates only the products table. Product validation and the error handler are present but are not wired into the sampled request flow.
Main entry points: db.js Database connection · categoryroutes.js Category routes · index.js Express server · productRoutes.js Product routes
Components 9
HTTP routing
- Express server
index.js - Product routes
routes/productRoutes.js - Category routes
routes/categoryroutes.js
Domain handlers
- Category validation
middleware/categoryValidation.js - Product handlers
controllers/productController.js - Category handlers
controllers/categorycontroller.js
SQLite storage
- Database connection
database/db.js - SQLite database
database/supermarket.db
Other components
- API client
Connections 8
- API client → Express server: sends requests
- Express server → Product routes: mounts /products
- Product routes → Product handlers: dispatches CRUD
- Category routes → Category validation: validates writes
- Category routes → Category handlers: dispatches CRUD
- Product handlers → Database connection: queries products
- Category handlers → Database connection: queries categories
- Database connection → SQLite database: opens database