Skip to content

Getting Started

This guide will help you set up the API backend for local development.

Prerequisites

  • Node.js 22+
  • pnpm 10+
  • Docker and Docker Compose
  • PostgreSQL client (optional, for debugging)

Installation

  1. Clone the repository and install dependencies:

    bash
    git clone <api-repo-url>
    cd api
    pnpm install
  2. Set up environment variables:

    bash
    cp .env.example .env
  3. Configure your .env file with required values (see below)

Environment Variables

Key environment variables:

VariableDescription
DATABASE_URLPostgreSQL connection string
REDIS_URLRedis connection string
NEO4J_URINeo4j bolt URI
JWT_SECRETSecret for JWT signing
STRIPE_SECRET_KEYStripe API key
SENDGRID_API_KEYSendGrid API key

Starting the Database

Start PostgreSQL, Redis, and Neo4j with Docker:

bash
pnpm services:up   # from the repo root

Running Migrations

Apply database migrations:

bash
pnpm db:migrate

Starting the Server

Start the development server with hot reload:

bash
pnpm dev

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

Verifying the Setup

  1. Check the health endpoint:

    bash
    curl http://localhost:8080/health
  2. View the API documentation at http://localhost:8080/reference

Running Tests

bash
pnpm test           # Run all tests
pnpm test:watch     # Watch mode
pnpm test src/path/to/test.ts  # Single file

Troubleshooting

Database Connection Issues

Ensure Docker containers are running:

bash
docker compose ps

Port Already in Use

Check what's using port 8080:

bash
lsof -i :8080

Migration Errors

Try reverting and re-running:

bash
pnpm db:revert
pnpm db:migrate

Built with VitePress