Backend

Every generated project includes a production-ready Node.js backend built with Fastify and Prisma ORM. The backend provides REST API endpoints for authentication, session management, and more.

Architecture

The backend follows a clean architecture pattern with the following layers:

backend/
├── controllers/
│   ├── rest-api/          # Fastify server and routes
│   │   ├── server.ts      # Server initialization
│   │   ├── plugins/       # Fastify plugins (auth, error-handler)
│   │   └── routes/        # API route handlers
│   └── event-queue/       # BullMQ workers (if enabled)
├── domain/                # Business logic layer
│   ├── auth/              # Authentication logic
│   ├── user/              # User management
│   └── session/           # Session management
├── prisma/
│   └── schema.prisma      # Database schema
└── utils/                 # Shared utilities

Database

The backend uses PostgreSQL as the database, managed through Prisma ORM. The database schema is defined in backend/prisma/schema.prisma.

PostgreSQL Only

PostgreSQL is the only supported database option. This ensures consistent behavior and allows the use of PostgreSQL-specific features.

Database Setup

Configure your database connection in the .env file:

DATABASE_URL="postgresql://user:password@localhost:5432/myapp?schema=public"

Migrations

Run Prisma migrations to set up your database schema:

cd backend
npx prisma migrate dev

Event Queue

For asynchronous job processing, the backend includes an optional event queue powered by BullMQ and Redis.

Preset Availability

The Event Queue is enabled by default in the Full-Featured and Analytics-Focused presets. It is disabled in the Minimal preset.

When to Use

The event queue is ideal for:

  • Sending emails asynchronously
  • Processing webhooks
  • Background data synchronization
  • Scheduled tasks and cron jobs

Configuration

Configure Redis connection in your .env file:

REDIS_URL="redis://localhost:6379"

Docker

Docker Compose files are included for both development and production environments.

Development

Start the development environment with PostgreSQL and Redis:

docker-compose up -d

This starts:

  • PostgreSQL database on port 5432
  • Redis (if event queue enabled) on port 6379

Production

Use the production Docker Compose file for deployment:

docker-compose -f docker-compose.prod.yml up -d

Running Locally

To run the backend locally:

# Start Docker services
docker-compose up -d

# Install dependencies
cd backend
npm install

# Run migrations
npx prisma migrate dev

# Start the server
npm run dev

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