A modular Node.js + Express REST API scaffold for users, products, and shopping carts β built for learning, interviews, and production-style growth.
- Overview
- Features
- Architecture
- Tech stack
- Project structure
- Getting started
- API reference
- Example requests
- Roadmap
- Interview talking points
- Contributing
- License
Ecommerce Startup API is a backend service that exposes REST endpoints for users, products, and per-user carts. The server uses Express middleware for JSON parsing and mounts feature routes under clear URL prefixes (/users, /products, /cart).
Current stage: Route handlers return placeholder responses. The structure (separate route modules, centralized
server.js) is production-oriented and ready for controllers, validation, persistence, and auth.
Add a screenshot at docs/images/api-demo.png after running the server.
| Area | Status | Description |
|---|---|---|
| REST routing | β | Modular routers for users, products, cart |
| JSON body parsing | β | express.json() enabled |
| Health / welcome | β | GET / returns welcome message |
| Database | π | MongoDB / PostgreSQL (planned) |
| Auth (JWT) | π | Register, login, protected routes |
| Validation | π | Request schema validation (e.g. Zod/Joi) |
| Tests | π | Unit + integration (Jest/Supertest) |
| Docker / CI | π | Container + GitHub Actions |
flowchart TB
subgraph Client
C[Web / Mobile / Postman]
end
subgraph Server["Express Server :3000"]
S[server.js]
S --> U["/users β userRoutes"]
S --> P["/products β productRoutes"]
S --> CART["/cart β cartRoutes"]
end
subgraph Future["Planned layers"]
CTRL[Controllers]
SVC[Services]
DB[(Database)]
U --> CTRL
P --> CTRL
CART --> CTRL
CTRL --> SVC --> DB
end
C -->|HTTP JSON| S
Request flow (today):
- Client sends HTTP request to Express.
server.jsapplies global middleware and mounts route modules.- Route handler responds (placeholder text until controllers/DB are added).
| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express 5.x |
| Module style | CommonJS (require) |
| API style | REST |
ecommerce-startup/
βββ server.js # App entry: middleware, route mounting, listen
βββ routes/
β βββ userRoutes.js # User CRUD-style endpoints
β βββ productRoutes.js # Product catalog endpoints
β βββ cartRoutes.js # Cart per userId
βββ package.json
βββ package-lock.json
βββ docs/
βββ images/ # README assets (banner, diagrams, screenshots)
- Node.js 18+ (LTS recommended)
- npm (comes with Node)
git clone https://github.com/<your-username>/ecommerce-startup.git
cd ecommerce-startup
npm installnode server.jsServer listens on port 3000:
Server is running on port 3000
Open http://localhost:3000 β you should see the welcome HTML message.
Create .env (do not commit secrets):
PORT=3000
NODE_ENV=development
# DATABASE_URL=
# JWT_SECRET=Update server.js to use process.env.PORT || 3000 when you add dotenv.
"scripts": {
"start": "node server.js",
"dev": "node --watch server.js"
}Base URL: http://localhost:3000
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Welcome message |
| Method | Endpoint | Description |
|---|---|---|
GET |
/users |
List all users (placeholder) |
POST |
/users |
Create user (placeholder) |
GET |
/users/:id |
Get user by ID (placeholder) |
| Method | Endpoint | Description |
|---|---|---|
GET |
/products |
List all products (placeholder) |
POST |
/products |
Create product (placeholder) |
GET |
/products/:id |
Get product by ID (placeholder) |
| Method | Endpoint | Description |
|---|---|---|
GET |
/cart/:userId |
Get cart for user |
POST |
/cart/:userId |
Add item to user's cart |
Welcome
curl http://localhost:3000/Users
curl http://localhost:3000/users
curl -X POST http://localhost:3000/users -H "Content-Type: application/json" -d "{\"name\":\"Jane\"}"
curl http://localhost:3000/users/42Products
curl http://localhost:3000/products
curl http://localhost:3000/products/101Cart
curl http://localhost:3000/cart/42
curl -X POST http://localhost:3000/cart/42 -H "Content-Type: application/json" -d "{\"productId\":\"101\",\"qty\":2}"Production-minded milestones you can implement and mention in interviews:
- Layered architecture: routes β controllers β services β repositories
- Database: persist users, products, cart lines
- Auth: JWT + hashed passwords (bcrypt)
- Validation & errors: consistent
{ success, data, error }responses - Security: helmet, rate limiting, CORS
- Observability: structured logging (pino/winston), health check
/health - Testing: Supertest integration tests per route
- Deploy: Docker + Render/Railway/Fly.io + GitHub Actions CI
Use this repo to demonstrate how you think about backend systems, not only syntax:
- Separation of concerns β Route files isolate domains (users vs products vs cart); next step is controllers so routes stay thin.
- REST design β Resource-oriented URLs; cart scoped by
userIdmirrors real e-commerce patterns. - Express middleware β
express.json()for body parsing; global vs route-level middleware. - Scalability path β Stateless API β horizontal scaling behind a load balancer once sessions/JWT and DB are in place.
- Trade-offs β Placeholder handlers ship fast for learning; production needs validation, idempotency on cart updates, and transactional inventory.
- What youβd do next β Pick one vertical slice (e.g.
POST /productswith DB + tests) and complete it end-to-end β strong interview story.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes with clear messages
- Open a Pull Request
This project is licensed under the ISC License β see package.json.
Built with Express Β· Ready to grow into a production e-commerce backend


