Files · AWS Bedrock Contract Clause Extraction for SMB Legal
73 (1 binary, 568.0 kB total)attempt 1
README.md·1797 B·markdown
markdown
# AWS Bedrock Contract Clause Extraction for SMB Legal
> Automatically extract key clauses, dates, and parties from contracts using AWS Textract and Bedrock, with structured output and cost tracking.
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
## Architecture
```
PDF Upload → unpdf (pdf.js) → Textract (OCR fallback) → Bedrock (Claude Sonnet 4)
→ REAA doc-extraction → structured-repair → PostgreSQL (Drizzle ORM)
```
## Setup
```bash
# Install dependencies
pnpm install
# Copy env vars and fill in your credentials
cp .env.example .env
# Push the database schema
pnpm drizzle-kit push
# Start the dev server
pnpm dev
```
## API
### Extract clauses from a PDF
```bash
curl -X POST http://localhost:3000/api/extract \
-F "file=@contract.pdf"
```
### Extract clauses from plain text
```bash
curl -X POST http://localhost:3000/api/extract \
-H "Content-Type: application/json" \
-d '{"text": "This Agreement is made between..."}'
```
### List contracts
```bash
curl http://localhost:3000/api/contracts?limit=10&offset=0
```
### Get a single contract
```bash
curl http://localhost:3000/api/contracts/<id>
```
### Create a contract manually
```bash
curl -X POST http://localhost:3000/api/contracts \
-H "Content-Type: application/json" \
-d '{"filename": "example.pdf"}'
```
## 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).