Generate common legal communications from templates with intelligent variable insertion. Supports 7 communication types with a web interface, API, and optional AI-powered text enhancement.
Communication types: Breach/Cure Notices, Privacy Incident Notifications, Contract Award/Rejection Letters, Vendor Termination Letters, Legal Hold Notices, Regulatory Inquiry Responses, Board/Executive Legal Updates.
git clone https://github.com/lquantprojects/legal-comms-engine.git
cd legal-comms-engine
./start.sh # macOS/Linux
start.bat # WindowsThis installs dependencies, starts the API and frontend, and opens your browser.
- Frontend: http://localhost:8501
- API Docs: http://localhost:8000/docs
docker compose up- Frontend: http://localhost:8501
- API Docs: http://localhost:8000/docs
python3 -m venv .venv
source .venv/bin/activate # macOS/Linux
pip install -e .
python scripts/create_templates.py
# Terminal 1: Start API
uvicorn api.main:app --reload --port 8000
# Terminal 2: Start frontend
streamlit run lce_lce_frontend/app.py --server.port 8501- 7 communication types with structured input forms and Word (.docx) output
- Template-driven: .docx templates with Jinja2 placeholders — easy to customize
- Communication log with search, filter, and status tracking (draft/sent/final)
- AI enhancement (optional): Bring your own Anthropic API key to refine tone and adapt for jurisdiction
- API-first: Full REST API with Swagger docs — usable from curl, scripts, or integrations
- Extensible: Add a new communication type in 3 steps (schema + registry entry + template file)
To enable Claude-powered text enhancement:
- Go to Settings in the sidebar
- Enter your Anthropic API key (starts with
sk-ant-) - When generating a communication, check "Enhance with Claude"
- Choose a tone (formal, firm, conciliatory, neutral, urgent) and/or jurisdiction
- Review the enhanced text before generating
Your API key is stored only in your browser session and is never saved to disk.
The API is documented at http://localhost:8000/docs (Swagger UI).
Key endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | /templates |
List available communication types |
| GET | /templates/{type}/schema |
Get JSON Schema for a type's fields |
| POST | /communications/generate |
Generate a communication |
| GET | /communications/{id}/download |
Download generated .docx |
| GET | /communications |
List/search/filter communication log |
| PATCH | /communications/{id}/status |
Update status (draft/sent/final) |
| POST | /claude/enhance |
Enhance text with Claude (requires API key header) |
curl -X POST http://localhost:8000/communications/generate \
-H "Content-Type: application/json" \
-d '{
"communication_type": "breach_cure_notice",
"fields": {
"counterparty": "Acme Corp",
"breach_description": "Failure to deliver under Section 4.2",
"cure_period": "30 days",
"remediation_steps": ["Deliver outstanding items", "Provide status report"]
},
"author": "Jane Smith"
}'api/ FastAPI backend
routers/ API endpoints
schemas/ Pydantic models (including communication type registry)
services/ Business logic (generator, template engine, Claude service)
models/ SQLAlchemy ORM models
lce_frontend/ Streamlit web interface
pages/ Generate, Log, Settings pages
templates/ .docx template files with Jinja2 placeholders
data/sample/ Synthetic example data
tests/ pytest test suite
- Add a Pydantic schema class in
api/schemas/communication_types.py - Add a registry entry in
COMMUNICATION_TYPE_REGISTRYin the same file - Create a
.docxtemplate file intemplates/with matching placeholders
No router, frontend, or database changes required.
- Backend: Python 3.11+, FastAPI, SQLAlchemy, Pydantic v2
- Document generation: docxtpl (Jinja2 templates in Word)
- Frontend: Streamlit
- Database: SQLite (designed for PostgreSQL migration)
- AI: Anthropic API (Claude) — optional, BYOK
- Deployment: Docker, Railway
MIT