# Soi96 Legal

Purpose-built legal practice management platform for civil law firms.

**Tenant 1:** GPS Legal (design partner)  
**Jurisdiction:** Thai civil practice  
**Stack:** NestJS microservices · gRPC · PostgreSQL · Anthropic AI

---

## Architecture

```
api-gateway          :3000   HTTP — routes to internal gRPC services
  ├── auth-service        :5010   Auth + RBAC (shared core)
  ├── contacts-service    :5011   Contacts + relationships (shared core)
  ├── activity-logger     :5012   Immutable activity log (shared core)
  ├── matters-service     :5001   Case records — the core legal entity
  ├── time-entry-service  :5002   6-min increment time logging
  ├── trust-service       :5003   Client fund isolation + retainer ledger
  ├── conflict-service    :5004   Cross-reference new parties vs all records
  └── hearings-service    :5005   Court dates, deadlines, escalating alerts

ai/
  ├── prompt-analyst       Executive Secretary — only attorney UI connection
  ├── case-analyst         Senior Associate — coordinates all case work
  ├── client-manager       File Handler — one per client, lifetime scope
  ├── comms-agent          Receptionist — email/LINE/calendar parallel track
  ├── onboarding-agent     Intake Coordinator — new data in
  ├── rag-agent            Law Library — statute lookup only
  ├── document-classifier  Records — Thai doc classification
  ├── billing-agent        Accounts — deterministic rules
  └── intelligence-agent   Investigator — judge/counsel career profiles
```

See `docs/agent-architecture.md` for full hierarchy and communication rules.

---

## Development

```bash
cp .env.example .env
docker compose up postgres redis
npm install
npm run dev
```

## Docs

| File | Contents |
|---|---|
| `docs/agent-architecture.md` | 9-agent hierarchy, communication rules, schemas |
| `docs/product-strategy.md` | Product identity, shared core, build sequence |
| `docs/build-phases.md` | Phase 0–5 task checklist |
| `docs/competitive-advantage.md` | Moat analysis, Intelligence Agent value |
| `docs/strategy.md` | Practice profile, data architecture |
