Bazaar API is a modern, modular backend built using Nest.js,
Prisma, and PostgreSQL.
It powers a functional online marketplace with authentication, product
listings, carts, orders, and reviews.
This backend is designed to be scalable, cleanly organized, and
portfolio-ready.
- Nest.js -- backend framework
- Prisma ORM -- type-safe database client
- PostgreSQL -- relational database
- Node.js + TypeScript
- JWT Authentication
- Docker (optional for local DB)
- Register / Login
- JWT-based auth
- Password hashing
- Role-based access
- buyer\
- seller\
- admin
- Sellers can create, update, delete products
- Public product browsing
- Product details endpoint
- Image URL support (S3-ready)
- One cart per user
- Add / remove / update items
- Clear cart
- Server-side persistence
- Buyers can create orders
- Order item records
- Total calculation
- Buyer order history
- Buyers can review products they purchased
- Rating + optional comment
- Review listing per product
- Learn and demonstrate Nest.js architecture
- Provide a complete backend for the Bazaar Angular client
- Showcase Prisma relational modeling
- Implement robust authentication and guards
- Build real marketplace-domain functionality
authusersproductscartordersreviewsprisma
- Controllers for routing\
- Services for business logic\
- DTOs with validation\
- Guards for authentication\
- Prisma client for DB access
UserProductOrderOrderItemCartCartItemReview
- A user has one cart\
- A user can have many orders\
- A seller (user) has many products\
- A product has many reviews\
- A cart has many cart items\
- An order has many order items
- Node.js\
- PostgreSQL or Docker\
- npm
git clone https://github.com/your-username/bazaar-api.git
cd bazaar-api
npm install
Create a .env file:
DATABASE_URL="postgresql://postgres:password@localhost:5432/bazaar"
JWT_SECRET="your-secret"
PORT=3000
docker run --name bazaar-db -e POSTGRES_PASSWORD=password -e POSTGRES_DB=bazaar -p 5432:5432 -d postgres
npx prisma migrate dev
npm run start:dev
Variable Description
DATABASE_URL PostgreSQL connection string
JWT_SECRET Secret key for JWT signing
PORT API port
NODE_ENV environment mode
npm run start # production
npm run start:dev # development
npm run build # build project
npx prisma studio # database browser
npx prisma migrate dev # run migrations
POST /auth/registerPOST /auth/login
GET /users/me
GET /productsGET /products/:idPOST /products(seller only)PATCH /products/:idDELETE /products/:id
GET /cartPOST /cart/addPATCH /cart/item/:idDELETE /cart/item/:idDELETE /cart/clear
POST /ordersGET /orders/mine
POST /reviewsPATCH /reviews/:idDELETE /reviews/:idGET /reviews/product/:productId
- Jest unit tests
- E2E tests with Supertest (optional future work)
- Use
docker-composeto bundle API + DB - Set production
DATABASE_URLandJWT_SECRET - Run migrations before deploy
- Use a connection pooler (e.g., PG Bouncer)
- Product categories
- Search + filtering
- Image uploads via S3
- Admin moderation tools
- Rate limiting
- Email verification
MIT License