A modern, scalable backend for restaurant management built with NestJS and Fastify
See live demo with seed data on https://demo.toite.ee/. Use Credentials:
- Username:
admin - Password:
123456
All data are shared across everyone but don't worry, I will integrate something better in future.
- Restaurant Management - Create and manage multiple restaurants with customizable settings
- Worker/Staff Management - Handle employees, roles, and permissions
- Order Management - Real-time order processing with WebSocket support
- Menu & Dish Management - Flexible menu system with categories, modifiers, and pricing
- Guest Management - Track and manage customer information
- Workshift Management - Schedule and track employee shifts and payments
- Discount System - Configurable discounts and promotions
- Multi-language Support - Internationalization (i18n) ready
- File Storage - S3-compatible file uploads and management
| Category | Technology |
|---|---|
| Framework | NestJS + Fastify |
| Databases | PostgreSQL (Drizzle ORM), MongoDB (Mongoose), Redis |
| Authentication | JWT + Cookie-based sessions |
| Queue | BullMQ |
| Storage | S3-compatible (AWS S3, MinIO, etc.) |
| Real-time | Socket.io |
| Validation | Zod + class-validator |
| Documentation | Swagger/OpenAPI |
- Node.js 22+ (see
.nvmrc) - Yarn package manager
- Docker (for databases)
- PostgreSQL, MongoDB, and Redis instances
- Clone the repository
git clone https://github.com/Toite-app/backend.git
cd backend- Install dependencies
yarn install- Configure environment
cp .example.env .envEdit .env with your configuration (see Environment Variables).
- Run database migrations
yarn db:migrate- Start the development server
yarn start:devThe API will be available at http://localhost:3000 with Swagger docs at http://localhost:3000/docs.
Create a .env file based on .example.env:
| Variable | Description | Example |
|---|---|---|
NODE_ENV |
Environment mode | development |
PORT |
Server port | 3000 |
| Security | ||
JWT_SECRET |
Secret key for JWT tokens | (generate a secure string) |
JWT_GRACE_PERIOD |
Token grace period in seconds | 60 |
JWT_REFRESH_INTERVAL |
Token refresh interval in seconds | 900 |
JWT_EXPIRES_IN |
Token expiration in seconds | 2678400 |
CSRF_SECRET |
CSRF protection secret | (generate a secure string) |
COOKIES_SECRET |
Cookie signing secret | (generate a secure string) |
INITIAL_ADMIN_PASSWORD |
Initial admin password | (secure password) |
| Databases | ||
POSTGRESQL_URL |
PostgreSQL connection string | postgresql://user:pass@localhost:5432/toite |
MONGO_URL |
MongoDB connection string | mongodb://user:pass@localhost:27017/toite?authSource=admin |
REDIS_URL |
Redis connection string | redis://:password@localhost:6379 |
| External APIs | ||
DADATA_API_TOKEN |
DaData API token | (your token) |
GOOGLE_MAPS_API_KEY |
Google Maps API key | (your key) |
| S3 Storage | ||
S3_ACCESS_KEY_ID |
S3 access key | minioadmin |
S3_SECRET_ACCESS_KEY |
S3 secret key | minioadmin |
S3_BUCKET_NAME |
S3 bucket name | toite |
S3_ENDPOINT |
S3 endpoint URL | http://localhost:9000 |
S3_REGION |
S3 region | us-east-1 |
| Command | Description |
|---|---|
yarn start:dev |
Start development server with hot reload |
yarn start:debug |
Start with debugger attached |
yarn build |
Build for production |
yarn start:prod |
Start production server |
yarn lint |
Lint and fix code |
yarn format |
Format code with Prettier |
yarn test |
Run unit tests |
yarn test:e2e |
Run end-to-end tests |
yarn test:cov |
Run tests with coverage |
yarn db:generate |
Generate database migrations |
yarn db:migrate |
Run database migrations |
yarn db:push |
Push schema changes to database |
yarn db:studio |
Open Drizzle Studio |
yarn bench |
Run k6 benchmarks |
Pull and run the official Docker image from Docker Hub:
docker pull toite/backend:latest
docker run -d \
--name toite-backend \
-p 3000:3000 \
-e POSTGRESQL_URL="postgresql://..." \
-e MONGO_URL="mongodb://..." \
-e REDIS_URL="redis://..." \
-e JWT_SECRET="your-secret" \
-e CSRF_SECRET="your-csrf-secret" \
-e COOKIES_SECRET="your-cookies-secret" \
-e INITIAL_ADMIN_PASSWORD="your-admin-password" \
-e DADATA_API_TOKEN="your-token" \
-e GOOGLE_MAPS_API_KEY="your-key" \
-e S3_ACCESS_KEY_ID="your-key" \
-e S3_SECRET_ACCESS_KEY="your-secret" \
-e S3_BUCKET_NAME="toite" \
-e S3_ENDPOINT="http://minio:9000" \
-e S3_REGION="us-east-1" \
toite/backend:latestdocker build -t toite-backend .
docker run -d --name toite-backend -p 3000:3000 --env-file .env toite-backendInteractive API documentation is available via Swagger UI:
- Development:
http://localhost:3000/docs - Live Demo: demo.toite.ee/api/docs
The API is organized into the following main sections:
auth- Authentication endpointsworkers- Staff managementrestaurants- Restaurant operationsguests- Customer managementorders- Order processingdishes- Menu itemsworkshifts- Shift management
src/
βββ @base/ # Base infrastructure modules
β βββ audit-logs/ # Activity logging
β βββ cache/ # Caching layer
β βββ drizzle/ # Database ORM & migrations
β βββ encryption/ # Encryption utilities
β βββ redis/ # Redis utilities
β βββ redlock/ # Distributed locking
β βββ s3/ # File storage
β βββ snapshots/ # Data snapshots
βββ @core/ # Core utilities & config
βββ @socket/ # WebSocket gateway
βββ auth/ # Authentication module
βββ dishes/ # Dish management
βββ dish-categories/ # Dish categories
βββ dishes-menus/ # Menu management
βββ discounts/ # Discount system
βββ files/ # File handling
βββ guests/ # Guest management
βββ orders/ # Order processing
βββ payment-methods/ # Payment methods
βββ restaurants/ # Restaurant management
βββ timezones/ # Timezone utilities
βββ workers/ # Staff management
βββ workshifts/ # Workshift management
βββ i18n/ # Internationalization
βββ app.module.ts # Root module
βββ main.ts # Application entry
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code:
- Passes all tests (
yarn test) - Follows the existing code style (
yarn lint) - Includes appropriate documentation
This project is licensed under the MIT License - see the LICENSE file for details.
Made by Yefrosynii Kolenko