Skip to main content
This guide walks you through setting up the development environment and running the platform locally.

Project Setup

1. Clone the Repository

2. Install Dependencies

The project uses pnpm workspaces to manage the monorepo:
This installs dependencies for all packages:
  • @alliance-risk/api - NestJS backend
  • @alliance-risk/web - Next.js frontend
  • @alliance-risk/shared - Shared types and constants
  • @alliance-risk/infra - AWS CDK infrastructure
The installation may take a few minutes. pnpm will install dependencies and run postinstall scripts for packages like Prisma and NestJS.

3. Configure Environment Variables

Set up environment variables for local development. See the Environment Variables guide for complete configuration details. For the API package:
Edit packages/api/.env with your local PostgreSQL credentials:
Never commit .env files to version control. They contain sensitive credentials.

4. Set Up the Database

Generate Prisma Client

Run Database Migrations

Apply all Prisma migrations to your local PostgreSQL database:
migrate deploy applies all pending migrations without creating new ones. Use migrate dev when developing new schema changes.

Seed the Database

Populate the database with initial data (admin user and sample prompts):
Or from the project root:
The seed script creates an initial admin user. Check packages/api/prisma/seed.ts for credentials.

5. Build Shared Package

The @alliance-risk/shared package must be built before the API and Web packages can import from it:
You only need to rebuild the shared package when you modify types, enums, or constants in packages/shared/src/.

Running Development Servers

Start All Services

Run both the API and Web development servers concurrently:
This starts:
  • API Server on http://localhost:3001 (NestJS with hot reload)
  • Web Server on http://localhost:3000 (Next.js with Fast Refresh)

Start Services Individually

You can also run each service separately:
The Web app expects the API to be running on http://localhost:3001. You can override this with the NEXT_PUBLIC_API_URL environment variable.

Development Workflow

Database Management

View Database with Prisma Studio:
This opens an interactive database GUI at http://localhost:5555. Create a New Migration:
Reset Database (DESTRUCTIVE):
migrate reset drops the database, recreates it, applies all migrations, and runs seed. All data will be lost.

Testing

Linting

Building

Project Structure

Common Issues

Port Already in Use

If port 3001 or 3000 is already in use:

Prisma Client Out of Sync

If you see “Prisma Client did not initialize yet”:

Database Connection Failed

Verify PostgreSQL is running and credentials are correct:

Module Not Found in Shared Package

Rebuild the shared package:

Next Steps

Now that your local environment is running:
  1. Access the frontend at http://localhost:3000
  2. API health check at http://localhost:3001/api/health
  3. Review Environment Variables for AWS service configuration
  4. Deploy to AWS using the infrastructure deployment guides