A complete e-commerce system:
- Backend: NestJS + TypeORM + PostgreSQL, JWT auth with role-based access (admin / customer)
- Frontend: Next.js 14 (App Router) + TypeScript + Tailwind CSS
- Features: storefront (home, product listing, product detail, cart, checkout, order history) and a full admin panel (dashboard, products CRUD, categories CRUD, order management, user management)
ecommerce-project/
backend/ → NestJS API (port 4000)
frontend/ → Next.js app (port 3000)
- Node.js 18+
- PostgreSQL 14+ (or Docker)
cd backend
cp .env.example .env # edit DB credentials if needed
npm installStart PostgreSQL. Easiest way, with Docker:
docker compose up -dOr point .env at your own existing Postgres instance.
Run the API in dev mode (TypeORM synchronize: true will auto-create tables):
npm run start:devSeed the database with an admin user, a customer user, categories and sample products:
npm run seedSeeded accounts:
| Role | Password | |
|---|---|---|
| Admin | admin@shop.com | Admin123! |
| Customer | customer@shop.com | Customer123! |
API runs at http://localhost:4000/api.
| Resource | Endpoints |
|---|---|
| Auth | POST /auth/register, POST /auth/login, GET /auth/me |
| Categories | GET /categories, POST /categories (admin), PATCH /categories/:id (admin), DELETE /categories/:id (admin) |
| Products | GET /products (paginated/filterable), GET /products/admin/all (admin), GET /products/slug/:slug, GET /products/:id, POST /products (admin), PATCH /products/:id (admin), DELETE /products/:id (admin) |
| Cart | GET /cart, POST /cart/items, PATCH /cart/items/:id, DELETE /cart/items/:id, DELETE /cart |
| Orders | POST /orders (checkout from cart), GET /orders/mine, GET /orders/mine/:id, GET /orders (admin), PATCH /orders/:id/status (admin) |
| Users | GET /users, POST /users, PATCH /users/:id, DELETE /users/:id (all admin-only) |
cd frontend
cp .env.local.example .env.local # points to http://localhost:4000/api by default
npm install
npm run devApp runs at http://localhost:3000.
Storefront
/— Home page (hero, categories, newest arrivals)/products— Product listing with search, category filter, sort, pagination/products/[id]— Product detail with quantity picker and add-to-cart/cart— Cart with quantity edit, remove, and checkout (creates an order)/orders— Customer's order history/login,/register— Auth
Admin (requires an account with role admin)
/admin— Dashboard: revenue, order count, low-stock alerts, recent orders/admin/products— Product list with edit/delete,/admin/products/newand/admin/products/[id]/editfor create/edit/admin/categories— Category list with inline create/edit/delete/admin/orders— Order list with expandable line items and status updates/admin/users— User list with role toggle and enable/disable
User(id, name, email, password, role, isActive)Category(id, name, slug, description, imageUrl)Product(id, name, slug, description, price, stock, imageUrl, isActive, categoryId)Cart(id, userId) → has manyCartItem(productId, quantity)Order(id, userId, total, status, shippingAddress) → has manyOrderItem(productId, productName, unitPrice, quantity — snapshotted at checkout time)
- Set
synchronize: falseinapp.module.tsand use TypeORM migrations once your schema stabilizes. - Change
JWT_SECRETto a strong, unique value. - Add HTTPS / a reverse proxy in front of the API.
- Consider adding refresh tokens, rate limiting, and file uploads (currently product/category images are simple URLs).