> ## Documentation Index
> Fetch the complete documentation index at: https://abacuslabs.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Local Development

> A guide on how to run Abacus locally.

## Introduction

Abacus is set up as a monorepo via [Turborepo](https://turbo.build/repo) and is [open-source on GitHub](https://github.com/Suphian/abacus).

### Monorepo Structure

```
apps/
├── api          # Backend API (Hono + tRPC)
├── dashboard    # Main application (app.abacuslabs.co)
├── docs         # Documentation site (Mintlify)
├── engine       # Bank connection engine (Plaid)
├── website      # Marketing site (abacuslabs.co)

packages/
├── ach          # ACH payment processing
├── ai-outreach  # AI voice calls and SMS for collections
├── categories   # Transaction category definitions
├── db           # Database schema and queries (Drizzle ORM)
├── deal         # Deal management logic
├── disclosures  # State-specific disclosure letter generation
├── documents    # Document parsing and management
├── email        # Email templates and sending (Resend)
├── events       # Analytics library
├── goach        # GoACH payment integration
├── import       # CSV importer
├── inbox        # Inbox utilities
├── jobs         # Background jobs (BullMQ)
├── merchants    # Merchant management logic
├── notification # Notification client
├── plans        # Subscription plan definitions
├── sheets       # Google Sheets AI import
├── supabase     # Database types and migrations
├── tsconfig     # Shared TypeScript configuration
├── ucc          # UCC filing lifecycle management
├── ui           # Shared UI component library (Radix + Tailwind)
├── underwriting # Underwriting scoring and analysis
├── utils        # Shared utility functions
```

## Prerequisites

* [Bun](https://bun.sh/) (package manager and runtime)
* [Docker](https://www.docker.com/) (for local Supabase and Redis)
* A [Supabase](https://supabase.com/) account

## Getting Started

**1. Clone the repo**

```bash theme={null}
git clone https://github.com/Suphian/abacus.git
cd abacus
```

**2. Install dependencies**

```bash theme={null}
bun i
```

**3. Set up environment variables**

Copy the example environment files and fill in your API keys:

```bash theme={null}
cp apps/dashboard/.env.example apps/dashboard/.env.local
cp apps/api/.env.example apps/api/.env.local
```

**4. Start local services**

Start Supabase (PostgreSQL + Auth + Storage) and Redis via Docker:

```bash theme={null}
bash scripts/startup.sh
```

This starts Supabase on ports 54321-54324 and Redis on port 6379.

**5. Run the development server**

```bash theme={null}
bun dev
```

This starts all apps:

* **Dashboard**: [http://localhost:3001](http://localhost:3001)
* **Engine**: [http://localhost:3002](http://localhost:3002)
* **API**: [http://localhost:3003](http://localhost:3003)

## Database

### Seeding

The seed file (`supabase/seed.sql`) populates your local database with sample data including merchants, deals, transactions, and categories.

```bash theme={null}
# Full reseed (truncate + re-seed)
bash scripts/reseed.sh

# Run custom SQL directly
bash scripts/run-sql.sh "INSERT INTO public.merchants ..."

# Or via Docker
docker exec -i supabase_db_abacus psql -U postgres -d postgres -c "YOUR SQL"
```

### Migrations

```bash theme={null}
# Create a new migration
supabase migration new your_migration_name

# Generate migration from schema diff
supabase db diff -f your_migration_name

# Push migrations to local database
supabase db push

# Generate TypeScript types
supabase gen types
```

## Common Commands

```bash theme={null}
# Development
bun dev          # Start all development servers
bun build        # Build for production
bun test         # Run tests
bun lint         # Run ESLint
bun format       # Run Prettier
```

## Ports Reference

| Service | Port |
| - | - |
| Dashboard | 3001 |
| Engine | 3002 |
| API | 3003 |
| Supabase Studio | 54321 |
| Supabase API | 54322 |
| Supabase Auth | 54323 |
| Supabase Storage | 54324 |
| Redis | 6379 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.