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

# Quickstart

> Get oriented with Pcnaid Legal Hub — what it is, how to sign in locally, and where to find the API reference.

# Quickstart

## What the app does

Pcnaid Legal Hub is a full-stack, multi-tenant legal operations application. It provides law-firm back-office workflows (clients, matters, documents, billing, communications), a client portal, AI-assisted knowledge workflows, and Pcnaid staff administration tools.

**Stack:** Cloudflare Workers (Hono API + React 19 SPA), Azure Postgres via Cloudflare Hyperdrive, Auth0 authentication, Resend (email), Twilio (SMS), Stripe (billing), Cal.com (scheduling), OpenAI (AI), Cloudflare R2 (documents).

## Sign-in model

Authentication uses **Auth0 Universal Login with PKCE**. After sign-in, the Worker mints an HS256 app-session JWT stored in an HttpOnly, Secure, SameSite=Lax `pcnaid_access_token` cookie. No Auth0 refresh token is stored on the client.

* **Firm staff** see the firm dashboard after sign-in.
* **Client-only users** are routed to the client portal at `/portal/*`.
* **Pcnaid staff** see `/admin/*`.

Multi-organization users must set their active organization in **Settings** and send `X-Organization-Id` with API requests.

## Local development setup

**Prerequisites:** Node.js 22.12.0+ (use `.nvmrc`), npm 10+, Cloudflare account with Wrangler, Azure Postgres database, Auth0 tenant.

```bash theme={null}
npm ci
cp .env.example .dev.vars
```

Configure `DATABASE_URL` in `.dev.vars` with your Azure Postgres connection string (`sslmode=require`). Run the migration and seed:

```bash theme={null}
npm run db:create-indexes
SEED_AUTH0_USER_ID="auth0|YOUR_USER_ID" SEED_OWNER_EMAIL="you@example.com" npm run db:seed
```

Start the local Worker and SPA:

```bash theme={null}
npm run dev
```

## Available commands

| Command | Purpose |
| - | - |
| `npm run dev` | Start local Wrangler development server |
| `npm run build` | Build SPA and dry-run Worker deployment |
| `npm run deploy` | Build and deploy to Cloudflare Workers |
| `npm run typecheck` | Run TypeScript type checking |
| `npm run lint` | Run ESLint |
| `npm run test` | Run Vitest |
| `npm run db:create-indexes` | Apply Postgres migration and indexes |
| `npm run db:seed` | Seed demo organization data |

## Public integration points

The API is served under `/api/`. Public endpoints include health check (`GET /api/health`), contact form (`POST /api/contact`), Auth0 callback (`POST /api/auth/callback`), and brand resolution (`GET /api/brand-for-host`). Provider webhooks are mounted at `/api/webhooks/stripe`, `/api/webhooks/twilio`, `/api/webhooks/cal`, and `/api/webhooks/auth0`. Authenticated resource routes are listed in the [API Reference](https://docs.pcnaid.com/nodes/web-apps/legalhub/developer/api/index.md).

## Next steps

* Review the [Architecture Overview](https://docs.pcnaid.com/nodes/web-apps/legalhub/developer/architecture-overview.md) for the full system design.
* Browse the [API Reference](https://docs.pcnaid.com/nodes/web-apps/legalhub/developer/api/index.md) for implemented route contracts.


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