Files · Buyer-Rep Compliance Agent for Small Brokerages
71 (1 binary, 611.1 kB total)attempt 1
README.md·3897 B·markdown
markdown
# Buyer-Rep Compliance Agent for Small Brokerages
> Automate buyer-rep agreement paper trails and compliance checks.
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
## Problem Statement
Small real-estate brokerages struggle to maintain compliance with buyer-rep agreement regulations. Disclosures must be signed within strict timeframes, lead-based paint disclosures are required for pre-1978 properties, and agents often miss renewal deadlines. Without automated oversight, brokerages risk regulatory fines and legal exposure.
This reference solution demonstrates how to build a production-grade compliance agent that monitors buyer-rep agreements, runs compliance checks, surfaces findings via a RAG-powered Q&A interface, and generates structured compliance reports — all built with the `@reaatech/*` package family.
## Architecture
```
Next.js Dashboard → Hono API → Services Layer (Agreement, Compliance, RAG, Eval, Memory) → REAA Packages + Langfuse
```
- **Next.js App Router** — server-rendered dashboard with API routes proxied to a Hono handler
- **Hono API** — lightweight HTTP router with typed endpoints for agreements, compliance, RAG, and evaluation
- **Services Layer** — domain logic in `AgreementService`, `ComplianceService`, `ComplianceRagPipeline`, `MemoryService`, and `EvalService`
- **REAA Packages** — agent memory, context injection, and RAG evaluation
- **Langfuse** — observability for LLM calls and compliance checks
## REAA Packages
| Package | Description |
|---------|-------------|
| `@reaatech/agent-memory` | Core agent memory with LLM-powered fact extraction, retrieval, and maintenance |
| `@reaatech/agent-memory-retrieval` | Context injection pipeline that formats retrieved memories into LLM prompts |
| `@reaatech/agent-memory-storage` | In-memory storage backend for agent memories |
| `@reaatech/rag-eval-core` | Core evaluation framework for RAG pipelines with scoring and metrics |
| `@reaatech/rag-eval-dataset` | Dataset loading utilities for RAG evaluation |
| `@reaatech/rag-eval-gate` | Evaluation gates for CI/CD integration |
## API Reference
| Method | Path | Purpose |
|--------|------|---------|
| GET | `/api/agreements` | List all agreements (with optional `status` and `agentName` filters) |
| GET | `/api/agreements/expiring` | List agreements expiring within a given number of days |
| GET | `/api/agreements/:id` | Get a single agreement by ID |
| POST | `/api/agreements` | Create a new agreement |
| PATCH | `/api/agreements/:id` | Update an existing agreement |
| DELETE | `/api/agreements/:id` | Archive an agreement |
| POST | `/api/agreements/:id/sign` | Mark an agreement as signed |
| POST | `/api/compliance/check/:id` | Run compliance checks on a single agreement |
| POST | `/api/compliance/check-all` | Run compliance checks on all agreements |
| GET | `/api/compliance/summary` | Get aggregated compliance summary metrics |
| POST | `/api/compliance/query` | Ask a compliance question via RAG |
| POST | `/api/compliance/report/:id` | Generate a structured compliance report for an agreement |
| POST | `/api/eval/run` | Run a RAG evaluation against a dataset |
| POST | `/api/eval/validate` | Validate evaluation samples |
| GET | `/api/eval/gates` | List configured evaluation gates |
## Running locally
```bash
pnpm install
pnpm test # vitest run with coverage
pnpm dev # next dev
```
## Project layout
```
app/ Next.js App Router pages + API routes
src/ services, lib, adapters
tests/ vitest suite (mirrors src/)
packages/ API references for every dependency (read these first)
DEV_PLAN.md build plan for this recipe
```
## License
MIT — see [LICENSE](./LICENSE).