> ## Documentation Index
> Fetch the complete documentation index at: https://tonic-ai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture Overview

> High-level architecture of CreditNexus

## System Architecture

CreditNexus follows a layered architecture with clear separation of concerns:

### Backend Layer

* **API Layer**: FastAPI with dependency injection and Pydantic validation
* **Service Layer**: Business logic and orchestration
* **Data Layer**: SQLAlchemy 2.0 with PostgreSQL
* **Policy Layer**: Policy-as-code engine for compliance enforcement

### Frontend Layer

* **React 18**: Modern React with hooks and functional components
* **TypeScript**: Type-safe development
* **Tailwind CSS**: Utility-first styling
* **FDC3 Integration**: Desktop interoperability

### AI/ML Layer

* **LLM Abstraction**: Support for multiple providers (OpenAI, vLLM, HuggingFace)
* **Extraction Chains**: Simple and map-reduce extraction strategies
* **Satellite Analysis**: TorchGeo for NDVI verification

## Data Flow

1. **Document Upload**: User uploads credit agreement
2. **Text Extraction**: Document text is extracted
3. **AI Extraction**: LLM extracts structured CDM data
4. **Policy Validation**: Policy engine validates compliance
5. **CDM Event Creation**: Policy decisions stored as CDM events
6. **Storage**: Data persisted in PostgreSQL with audit logging

## Key Principles

* **CDM Compliance**: All data follows FINOS CDM standards
* **Policy-as-Code**: Deterministic policy enforcement
* **Type Safety**: Full TypeScript and Pydantic validation
* **Audit Trail**: Complete audit logging for compliance

## Platform Scale & Capabilities

CreditNexus is built with enterprise-scale architecture and comprehensive feature coverage:

### Component Statistics

* **215+ Prompt Templates** - AI prompts across 16 files covering LMA-compliant clause generation, industry-specific templates, and multi-scenario support
* **11 Specialized Agents** - AI agents for document analysis, satellite verification, classification, research, and workflow automation
* **121 Policy Rules** - Regulatory compliance rules across 21 files covering MiCA, Basel III, FATF, ESG, and green finance
* **94 Tool Modules** - Service modules, utilities, and LangChain integration chains for comprehensive functionality
* **76 Data Models** - Pydantic models ensuring type safety and FINOS CDM compliance across all data structures
* **54 Database Tables** - SQLAlchemy 2.0 models covering users, documents, workflows, deals, payments, and analytics
* **147 API Endpoints** - RESTful endpoints providing comprehensive programmatic access to all platform features
* **100% CDM Compliant** - Full FINOS Common Domain Model compliance ensuring interoperability with financial systems

### Platform Architecture Highlights

**AI & Automation:**

* 215+ prompt templates for consistent AI behavior
* 11 specialized agents for complex workflows
* Multi-provider LLM support (OpenAI, vLLM, HuggingFace)
* 20 LangChain integration chains

**Compliance & Policy:**

* 121 policy rules across 8 categories
* Real-time policy enforcement engine
* CDM-compliant event generation
* Three-tier decision system (ALLOW/BLOCK/FLAG)

**Data & Integration:**

* 76 Pydantic models for type safety
* 54 database tables with SQLAlchemy 2.0
* 147 API endpoints for programmatic access
* Full CDM standardization

For detailed component breakdown and capabilities assessment, see the [Platform Statistics](/architecture/platform-statistics) documentation.
