System Requirements
Required Software
Node.js
Version 18 or higherDownload from nodejs.org
PostgreSQL
Version 12 or higherDownload from postgresql.org
pnpm
Latest versionInstall:
npm install -g pnpmGit
Version 2.0 or higherDownload from git-scm.com
Installation Steps
1. Clone the Repository
2. Install Dependencies
The project uses pnpm for package management. Install all dependencies:@nestjs/core- NestJS framework@nestjs/common- Common utilities and decorators@nestjs/platform-express- Express adapter
@prisma/client- Prisma ORM client@prisma/adapter-pg- PostgreSQL adapterpg- PostgreSQL driver
@nestjs/jwt- JWT authentication@nestjs/passport- Passport integrationpassport-jwt- JWT strategybcrypt- Password hashing
class-validator- DTO validationclass-transformer- Object transformation
3. Configure Environment Variables
Create a.env file in the project root:
.env
Environment Variable Reference
Environment Variable Reference
DATABASE_URLPostgreSQL connection string format:PORTPort number for the HTTP server (default: 3000)NODE_ENVEnvironment mode:
user- Database usernamepassword- Database passwordhost- Database host (localhost for local development)port- Database port (default: 5432)database- Database name
- At least 32 characters long
- Random and unpredictable
- Different for each environment
development, production, or test4. Database Setup
Create the Database
If the database doesn’t exist, create it:Generate Prisma Client
Generate the Prisma Client based on your schema:prisma/schema.prisma and generates TypeScript types and client methods.
Run Migrations
Apply database migrations to create all tables:Admin Table
Admin Table
Stores administrator accounts for backend management.
Category Table
Category Table
Product categories for organizing the menu.
Product Table
Product Table
Tea and beverage products available for order.
Order & OrderItem Tables
Order & OrderItem Tables
Customer orders and their line items.
NewsletterSubscriber Table
NewsletterSubscriber Table
Running the Application
Development Mode
Start the server with hot-reload:Production Mode
First, build the application:Debug Mode
Start with debugging enabled:Verification
After installation, verify everything is working:Verify database connection
Additional Configuration
Global Validation
The application uses global validation pipes configured insrc/main.ts:
src/main.ts
class-validator.
Available Scripts
The following npm scripts are available:| Script | Description |
|---|---|
pnpm run start | Start the server |
pnpm run start:dev | Start with hot-reload |
pnpm run start:prod | Start production build |
pnpm run start:debug | Start with debugger |
pnpm run build | Build for production |
pnpm run prisma:generate | Generate Prisma Client |
pnpm run prisma:migrate | Run database migrations |
pnpm run test | Run unit tests |
pnpm run test:e2e | Run end-to-end tests |
pnpm run test:cov | Run tests with coverage |
pnpm run format | Format code with Prettier |
pnpm run lint | Lint code with ESLint |
Troubleshooting
Common Installation Issues
pnpm command not found
pnpm command not found
Install pnpm globally:
PostgreSQL connection refused
PostgreSQL connection refused
Ensure PostgreSQL is running:
Prisma Client not found
Prisma Client not found
Regenerate the Prisma Client:
Migration errors
Migration errors
Reset the database and migrations (WARNING: deletes all data):
Port already in use
Port already in use
Change the port in Or kill the process using port 3000:
.env:Next Steps
Quickstart Guide
Follow the quickstart to make your first API request
Authentication Setup
Create admin users and secure your endpoints
API Reference
Explore all available API endpoints
Database Schema
Deep dive into the database structure