Skip to main content
This guide will help you set up Anchor for local development. Anchor is a monorepo containing three main components: server (NestJS), web (Next.js), and mobile (Flutter).

Prerequisites

Before you begin, ensure you have the following installed:
  • Node.js 18+ (for server and web)
  • pnpm (recommended package manager)
  • Docker & Docker Compose (for database)
  • Flutter SDK (only if developing mobile app)
  • Git

Clone the Repository

1

Clone the repo

git clone https://github.com/zhfahim/anchor.git
cd anchor
2

Review the structure

The repository is organized as a monorepo:
anchor/
├── server/          # NestJS backend API
├── web/             # Next.js web application
├── mobile/          # Flutter mobile app
└── docker-compose.dev.yml

Development Setup

The easiest way to get started is using Docker Compose for the entire stack:
1

Start all services

docker compose -f docker-compose.dev.yml up -d
This will start:
  • PostgreSQL database on port 5432
  • Server API on port 3001
  • Web app on port 3000
2

Access the application

Open your browser to http://localhost:3000

Option 2: Manual Setup (More Control)

For more control over individual services, you can run them manually:
1

Start the database

docker compose -f docker-compose.dev.yml up -d db
2

Set up the server

cd server
pnpm install
Create a .env file in the server/ directory:
DATABASE_URL="postgresql://anchor:password@localhost:5432/anchor?schema=public"
JWT_SECRET="supersecretkey"
PORT=3001
APP_URL="http://localhost:3000"
Generate Prisma client and run migrations:
pnpm exec prisma generate
pnpm exec prisma migrate dev
Start the server:
pnpm run start:dev
3

Set up the web app

In a new terminal:
cd web
pnpm install
Create a .env.local file (optional):
SERVER_URL=http://localhost:3001
The SERVER_URL is optional. By default, Next.js rewrites /api/* requests to http://127.0.0.1:3001/api/*.
Start the development server:
pnpm dev
4

Access the application

Open http://localhost:3000 and create your first account!

Mobile Development (Optional)

If you want to develop the mobile app:
1

Ensure server is running

Make sure the server is running on port 3001 (see steps above)
2

Install dependencies

cd mobile
flutter pub get
3

Run code generation

Generate code for Riverpod, Drift, and JSON serialization:
dart run build_runner build --delete-conflicting-outputs
4

Run the app

flutter run
Server URL Configuration:
  • Android Emulator: http://10.0.2.2:3001
  • iOS Simulator: http://localhost:3001
  • Physical device: Use your computer’s IP address

Verify Installation

To verify everything is working:
  1. Server: Visit http://localhost:3001/api/health
  2. Web: Visit http://localhost:3000
  3. Database: Connect with any PostgreSQL client:
    • Host: localhost:5432
    • Database: anchor
    • User: anchor
    • Password: password

Environment Variables

The main environment variables you can configure:
VariableDescriptionDefault
APP_URLBase URL for the applicationhttp://localhost:3000
JWT_SECRETSecret for JWT tokensAuto-generated
PG_HOSTPostgreSQL hostlocalhost
PG_USERPostgreSQL usernameanchor
PG_PASSWORDPostgreSQL passwordpassword
PG_DATABASEDatabase nameanchor
PG_PORTPostgreSQL port5432
USER_SIGNUPSign up mode: disabled, enabled, or review(not set)
See .env.example in the repository root for a complete list.

Next Steps

Now that your environment is set up:

Troubleshooting

Port already in use

If you see errors about ports being in use:
# Stop all Docker services
docker compose -f docker-compose.dev.yml down

# Check what's using the port
lsof -i :3000  # or :3001, :5432

Database connection issues

Ensure the database is healthy:
docker compose -f docker-compose.dev.yml ps
The anchor-db-dev container should show as “healthy”.

Prisma migration errors

Reset the database (⚠️ this will delete all data):
cd server
pnpm exec prisma migrate reset

Build docs developers (and LLMs) love