This guide will help you set up and run the AmarShop e-commerce platform with backend, frontend, and database.
- Node.js 20+ installed
- PostgreSQL 15+ (or Docker Desktop)
- npm or pnpm package manager
-
Start Docker Desktop on your machine
-
Start all services with Docker Compose:
docker-compose up -d
This will start:
- PostgreSQL database on port 5433
- Redis cache on port 6379
- Backend API on port 4000
- Frontend on port 3000
-
Run database migrations:
cd backend npx prisma migrate deploy npx prisma db seed
Download and install PostgreSQL 15 from postgresql.org
During installation:
- Set password:
shawon12 - Port:
5433
Download Redis for Windows from GitHub
Or skip Redis - the app will work with in-memory caching.
Open pgAdmin or use psql:
CREATE DATABASE amarshop;# Navigate to backend
cd backend
# Install dependencies
npm install
# Copy environment variables
copy .env.example .env # or manually create .env
# Run migrations
npx prisma migrate deploy
# Seed database (creates admin user)
npm run seedcd backend
npm run start:devBackend will be available at: http://localhost:4000/api/v1
# In root directory (not backend)
npm installnpm run devFrontend will be available at: http://localhost:3000
After running npm run seed in the backend, the following users are created:
| Role | Phone | Password |
|---|---|---|
| Admin | 01712345678 |
admin123 |
| Seller | 01711111111 |
seller123 |
| Customer | 01700000000 |
customer123 |
The application supports the following user roles:
- CUSTOMER - Regular users who can browse, buy, and review products
- SELLER - Users who can create stores and sell products
- ADMIN - Administrators who can manage the entire platform
- LOGISTICS - Users who manage shipping and delivery
- MODERATOR - Users who moderate content and handle disputes
- Go to
/auth/register - Enter name, phone number, and password
- User is automatically logged in after registration
- Go to
/auth/login - Enter phone number and password
- JWT token is stored in localStorage
- Go to
/admin/login - Enter admin credentials
- System verifies user has ADMIN role
- Non-admin users are redirected back to login
/checkout- Requires authentication/orders- Requires authentication/account- Requires authentication
/admin/*- All admin routes require ADMIN role/admin/users- View all users/admin/products- Manage products/admin/orders- View all orders/admin/settings- Platform settings
/seller/*- Seller dashboard and tools/seller/products- Manage store products/seller/orders- View store orders/seller/ai/*- AI-powered tools
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- User loginGET /api/v1/auth/profile- Get user profile (requires auth)
GET /api/v1/products- List all productsGET /api/v1/products/:id- Get product detailsGET /api/v1/category/:slug- Get category products
GET /api/v1/orders- Get user orders (requires auth)POST /api/v1/orders- Create new order (requires auth)
GET /api/v1/cart- Get cart items (requires auth)POST /api/v1/cart- Add to cart (requires auth)DELETE /api/v1/cart/:id- Remove from cart (requires auth)
If you see "database connection error":
- Ensure PostgreSQL is running
- Check DATABASE_URL in
backend/.env - Verify database
amarshopexists
If ports are already in use:
- Port 3000: Frontend - change in
package.jsondev script - Port 4000: Backend - change PORT in
backend/.env - Port 5433: PostgreSQL - change during installation
- Port 6379: Redis - change in docker-compose.yml
Run npm run typecheck in the root directory to check for TypeScript errors.
Clear the .next folder and rebuild:
rm -rf .next
npm run buildcurl -X POST http://localhost:4000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"Test User","phone":"+8801711000002","password":"test123"}'curl -X POST http://localhost:4000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"phone":"+8801711000002","password":"test123"}'curl http://localhost:4000/api/v1/auth/profile \
-H "Authorization: Bearer YOUR_JWT_TOKEN"For production deployment, update the following:
-
Environment Variables:
- Set strong
JWT_SECRET - Use production database URL
- Set
NODE_ENV=production
- Set strong
-
Database:
- Use a managed PostgreSQL service (AWS RDS, Supabase, etc.)
- Enable SSL for database connections
-
Frontend:
- Build with
npm run build - Deploy to Vercel, Netlify, or your own server
- Build with
-
Backend:
- Build with
npm run build - Deploy to AWS, Google Cloud, or your own server
- Use PM2 or Docker for process management
- Build with
For issues and questions:
- Check the existing documentation in
backend/README.md - Review the Prisma schema in
backend/prisma/schema.prisma - Check API routes in
backend/src/modules/