Project Setup
1. Clone the Repository
2. Install Dependencies
The project uses pnpm workspaces to manage the monorepo:@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:packages/api/.env with your local PostgreSQL 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):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:- 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:http://localhost:5555.
Create a New Migration:
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:- Access the frontend at
http://localhost:3000 - API health check at
http://localhost:3001/api/health - Review Environment Variables for AWS service configuration
- Deploy to AWS using the infrastructure deployment guides