Full-featured REST API for Simba e-commerce platform built with Node.js, Express, Prisma, and PostgreSQL.
- ✅ Product management with categories
- ✅ Order processing & tracking
- ✅ User reviews & ratings
- ✅ Blog system with likes & comments
- ✅ Banner management
- ✅ Full CRUD operations
- ✅ Pagination support
- ✅ Database seeding
- Runtime: Node.js + TypeScript
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Validation: Zod
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env
# Edit .env with your database credentials
# Push database schema
npm run db:push
# Generate Prisma client
npm run db:generate
# Seed database
npm run db:seed
# Start development server
npm run devGET /api/products- Get all products (with pagination)GET /api/products/featured- Get featured productsGET /api/products/top- Get top selling productsGET /api/products/:id- Get single productPOST /api/products- Create productPUT /api/products/:id- Update productDELETE /api/products/:id- Delete product
GET /api/categories- Get all categoriesGET /api/categories/:id- Get category with productsPOST /api/categories- Create categoryPUT /api/categories/:id- Update categoryDELETE /api/categories/:id- Delete category
GET /api/orders- Get all ordersGET /api/orders/:id- Get single orderPOST /api/orders- Create orderPUT /api/orders/:id/status- Update order statusPUT /api/orders/:id/payment- Update payment status
GET /api/reviews/product/:productId- Get product reviewsPOST /api/reviews- Create reviewDELETE /api/reviews/:id- Delete review
GET /api/blogs- Get all blogsGET /api/blogs/:id- Get single blogPOST /api/blogs- Create blogPUT /api/blogs/:id- Update blogDELETE /api/blogs/:id- Delete blogPOST /api/blogs/:id/like- Toggle likePOST /api/blogs/:id/comment- Add comment
GET /api/banners- Get all bannersPOST /api/banners- Create bannerPUT /api/banners/:id- Update bannerDELETE /api/banners/:id- Delete banner
{
"id": "uuid",
"name": "Product Name",
"slug": "product-slug",
"description": "Full description",
"shortDescription": "Brief description",
"price": 1500,
"comparePrice": 2000,
"sku": "PROD-001",
"stock": 100,
"lowStockAlert": 20,
"images": ["/path/to/image.jpg"],
"categoryId": "uuid",
"tags": ["tag1", "tag2"],
"isFeatured": true,
"isActive": true,
"isAlcohol": false,
"weight": 500,
"unit": "ml",
"viewCount": 0,
"salesCount": 0,
"rating": 4.5,
"reviewCount": 10,
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}The backend uses Prisma with PostgreSQL. Key models:
- Product
- Category
- User
- Cart & CartItem
- Order, OrderItem, OrderStatusLog
- Review
- Blog, BlogComment, BlogLike
- Banner
npm run dev # Start development server
npm run build # Build for production
npm start # Start production server
npm run db:push # Push schema to database
npm run db:generate # Generate Prisma client
npm run db:seed # Seed database with sample dataDATABASE_URL="postgresql://user:password@localhost:5432/simba_db"
PORT=5000
NODE_ENV=development
UPLOAD_PATH=./uploadsISC