Complete step-by-step guide to set up the Shazan marketplace platform.
- Node.js: v16.0.0 or higher
- npm or yarn: Package manager
- PostgreSQL: v12 or higher
- Git: Version control
git clone <repository-url>
cd shazan-backendnpm installcp .env.example .envEdit .env with your configuration. See ENV.md for details.
Ensure PostgreSQL is running and accessible:
# Test connection
psql -h localhost -U bornali -d shazan# Generate Prisma client
npx prisma generate
# Run migrations
npx prisma migrate dev --name init
# View database in Prisma Studio (optional)
npx prisma studionpm run start:devExpected output:
Shazan API running on http://localhost:3000
- Create Account: https://stripe.com
- Get API Keys:
- Go to Developers → API Keys
- Copy
Secret Key(starts withsk_test_) - Copy
Webhook Secret(starts withwhsec_)
- Update .env:
STRIPE_SECRET_KEY=sk_test_51234567890... STRIPE_WEBHOOK_SECRET=whsec_1234567890...
- Create Account: https://cloudinary.com
- Get Credentials:
- Dashboard → Settings
- Copy
Cloud Name,API Key,API Secret
- Update .env:
CLOUDINARY_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret
- Enable 2-Factor Authentication on Gmail account
- Generate App Password:
- Go to https://myaccount.google.com/apppasswords
- Select Mail and Windows Computer
- Copy the generated password
- Update .env:
MAIL_USER=your_email@gmail.com MAIL_PASS=xxxx xxxx xxxx xxxx
All tables are created automatically via Prisma migrations. Key tables include:
Auth- User accounts and authenticationSellerProfile- Seller business informationAd- Marketplace listingsBid- Auction bidsPayment- Transaction recordsMessage- User conversationsComment- Product reviews and commentsCategory- Product categoriesSubCategory- Category subdivisions
See DATABASE.md for complete schema details.
# Start development server
npm run start:dev
# Build for production
npm run build
# Run production server
npm run start:prod
# Run tests
npm run test
# Format code
npm run lint
# Generate Prisma client
npx prisma generate
# View database UI
npx prisma studioError: connect ECONNREFUSED 127.0.0.1:5434
Solution: Ensure PostgreSQL is running on the correct port (5434 in your config).
# Check if PostgreSQL is running
sudo service postgresql status
# Start PostgreSQL
sudo service postgresql startError: database "shazan" does not exist
Solution: Create the database first.
createdb -U bornali shazan
npx prisma migrate devEnsure .env file is in the project root and contains all required variables. See ENV.md.
- Review API.md for endpoint documentation
- Configure external services (Stripe, Cloudinary, Gmail)
- Run development server and test endpoints
- Check DATABASE.md for schema reference
- Read CONTRIBUTING.md before making changes
Before deploying to production:
- Set
NODE_ENV=productionin.env - Update
FRONTEND_URLto production domain - Use production API keys for Stripe, Cloudinary
- Enable HTTPS
- Set up automated backups for PostgreSQL
- Configure monitoring and logging
- Review security best practices
For detailed deployment instructions, see your hosting provider's documentation.