Skip to content

Toite-app/backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

300 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Toite Logo

Restaurant Management Backend API

A modern, scalable backend for restaurant management built with NestJS and Fastify

License Last Commit Security Rating Maintainability Rating Bugs Docker Pulls


πŸ₯” Live Demo

See live demo with seed data on https://demo.toite.ee/. Use Credentials:

  • Username: admin
  • Password: 123456
Swagger API Documentation

All data are shared across everyone but don't worry, I will integrate something better in future.


⭐ Features

  • 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

πŸ”§ Tech Stack

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

Getting Started

Prerequisites

  • Node.js 22+ (see .nvmrc)
  • Yarn package manager
  • Docker (for databases)
  • PostgreSQL, MongoDB, and Redis instances

Installation

  1. Clone the repository
git clone https://github.com/Toite-app/backend.git
cd backend
  1. Install dependencies
yarn install
  1. Configure environment
cp .example.env .env

Edit .env with your configuration (see Environment Variables).

  1. Run database migrations
yarn db:migrate
  1. Start the development server
yarn start:dev

The API will be available at http://localhost:3000 with Swagger docs at http://localhost:3000/docs.


Environment Variables

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

Available Scripts

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

Docker

Using Pre-built Image

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:latest

Building Locally

docker build -t toite-backend .
docker run -d --name toite-backend -p 3000:3000 --env-file .env toite-backend

API Documentation

Interactive API documentation is available via Swagger UI:

The API is organized into the following main sections:

  • auth - Authentication endpoints
  • workers - Staff management
  • restaurants - Restaurant operations
  • guests - Customer management
  • orders - Order processing
  • dishes - Menu items
  • workshifts - Shift management

Project Structure

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

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code:

  • Passes all tests (yarn test)
  • Follows the existing code style (yarn lint)
  • Includes appropriate documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.


Made by Yefrosynii Kolenko

About

A modern, scalable backend for restaurant management

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages