Managing contracts is traditionally a manual, error-prone, and legally tedious process. But from an engineering perspective, itβs a fascinating challenge: How do you build a system that is flexible enough for complex business logic, strict enough for legal compliance, and structured enough for AI to actually understand it?
Meet Ladnost, a scalable, AI-ready Contract Lifecycle Management (CLM) platform designed to automate the creation, approval, signing, and storage of contracts.
Hereβs a deep dive into the architecture and engineering decisions behind it.
π The Tech Stack
-
Frontend: Next.js (App Router),
next-intlfor centralized i18n, Tailwind CSS. - Backend: FastAPI (Python), PostgreSQL, SQLAlchemy.
-
Document Engine: Tiptap (headless WYSIWYG),
markitdownfor format conversion. - Infrastructure: Docker, Docker Compose, Nginx, pgAdmin.
π§ 1. AI-First Architecture (Not Just a Buzzword)
Most CLMs treat documents as opaque blobs of text. Ladnost treats them as structured data.
-
Dual Storage: Every document is saved as both
tiptap-JSON(for AI parsing and engine operations) and the original file (for exact layout preservation and archiving). - YAML-Driven Templates: Form filling and template configuration can be driven entirely via YAML. This makes the platform natively compatible with LLMs, allowing AI agents to generate template structures and populate data without human intervention.
- Computed Fields & Logic: Support for custom formulas, conditional visibility (AND/OR logic), and automatic recalculation across unlimited tables.
π 2. Full-Stack Modular Plugin System
We wanted businesses to customize the platform without forking the core codebase.
-
Backend: The FastAPI loader automatically scans the
./pluginsdirectory on startup. Each plugin registers its own API endpoints and hooks into a common Event Bus. -
Frontend: During the Next.js build, a custom script scans the plugins folder and dynamically generates App Router routes (
app/(plugins)) and component registries (lib/generatedPlugins.ts). - Monetization Ready: The architecture natively supports multi-tenancy and tariff/subscription systems, with payment gateways (like YooKassa) pluggable via modules.
π 3. Advanced Document Editor & Universal Format Support
We built the editor on Tiptap to provide a familiar, MS Word-like UX while keeping it headless and extensible.
- Version Control: Full history with rollback capabilities and clear diff-view highlighting.
-
Seamless Import/Export: Recognizes and converts DOCX, PDF, and RTF using
markitdown, and exports ready-to-sign DOCX/PDF files. - Developer Quality of Life: Automatic Markdown recognition and conversion when pasting from the clipboard.
π€ 4. Enterprise Collaboration & Workflow
- Routing: Supports both parallel and sequential approval workflows with automatic task generation.
-
Collaboration: Track Changes mode (visual highlighting), threaded comments with
@mentions, and granular Role-Based Access Control (RBAC), including anonymous access links for external counterparties. - Notifications: Multi-channel system (email, in-app, webhooks).
π Developer Experience: Up and Running in Minutes
We prioritized a frictionless local development experience. The entire stack spins up via Docker Compose:
# 1. Configure environment variables
.env
.env.docker
fastapi/.env.docker
# 2. Build and start
docker-compose up --build -d
Access the frontend at http://localhost, pgAdmin at http://localhost:5050, and the FastAPI Swagger UI internally via Nginx.
π‘ Why This Matters
- Reduced Time-to-Contract: Smart templates and automated routing eliminate legal routine.
- Low TCO: The plugin system allows deep customization without modifying the core.
- True AI Readiness: Centralized localization (JSON-based) and structured data storage mean you can plug in an AI assistant for risk checking, auto-filling, and contract analysis on day one.
π Get Involved!
We are actively looking for feedback, contributors, and plugin developers.
- π Star the repo: https://github.com/azexo/ladnost
- π Report issues: https://github.com/azexo/ladnost/issues
- π¬ Join the discussion: Drop a comment below if youβve worked on document-generation engines or AI-driven workflows. What challenges did you face?
Top comments (0)