Django REST API for a contract document platform for creating, managing, generating, editing, and tracking contract records, files, notifications, users, and document outputs.
This is a production-oriented business backend. It models real operational workflows, authenticated staff access, API filtering, document/report generation, realtime notification plumbing, and testable domain behavior.
- Backend ownership for a complete internal business application.
- Django REST API design across related business modules.
- PostgreSQL data modeling for operational records and audit/history needs.
- Auth, permissions, SSO subject handling, filters, dashboards, exports, and realtime events.
- Testable backend code with pytest tooling instead of only manual checks.
- account
- contract
- core
- notification
- ws
- Django REST API for contracts, accounts, files, document generation, notifications, users, and websocket events.
- Document-generation stack with ReportLab, WeasyPrint, python-docx, OpenPyXL, num2words, and reusable core document helpers.
- JWT/session auth, SSO subject support, django-filter, django-axes, and permission-aware API views.
- PDF/DOCX-oriented business workflow support for contract lifecycle screens.
- pytest coverage around contract creation, document behavior, auth, and websocket middleware.
The chat_ai adapter provides company-scoped contract/project search, authorized document downloads, approved workflow help and persistent conversations. Supported edits/deletes require exact-target confirmation and retain the requesting user's native history and audit identity. It reuses existing permissions and the shared self-hosted model.
The feature defaults to disabled pending shared-model acceptance. Configuration and migration instructions are in the assistant guide. Training data contains synthetic English/French scenarios only.
- Python, Django 6, Django REST Framework
- PostgreSQL, django-filter, django-simple-history
- SimpleJWT, dj-rest-auth, django-axes, CORS
- Redis, Channels, channels-redis, Daphne, Celery-ready runtime
- Gunicorn, WhiteNoise, Pillow/OpenCV where media handling is needed
- pytest, pytest-django, pytest-cov, pytest-asyncio, pytest-xdist
- Frontend: Altroo/contracts_frontend
Redacted production UI screens powered by this API. Sensitive names, amounts, dates, and records are blurred.
Create local-only environment variables for Django settings, database, Redis, media/static storage, CORS, and allowed hosts. Do not commit .env files or production credentials.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver 8001On Windows, activate with .venv\Scripts\activate.
python -m pytest
python -m pytest --covThe repository is public for portfolio review. Screenshots are redacted, and sensitive production values are intentionally hidden.
Translation, grammar correction and professional rewriting use the signed private Groq gateway when this service is enabled there. Provider credentials remain in the gateway environment. This does not enable the separate chat assistant.
Contract saves prepare durable translation rows without calling the model. Celery processes them asynchronously, preserving source text, JSON structure, names, amounts, references, units and list formatting. All contract PDF variants read the same prepared values. Requests promote pending text ahead of historical work; quota waits are deferred without consuming failure attempts.
Run python manage.py translate_pdf_content after deployment to prepare existing
contracts. Inspect progress using --status. Large refreshes resume under the
shared free allowance and may take days. The pdf-beat service schedules only PDF
translations; it does not activate unrelated notification schedules.

