# raghupatik/leasedocumentintelligence architecture

> Architecture diagram of the GitHub repository raghupatik/leasedocumentintelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raghupatik/leasedocumentintelligence
- Repository: https://github.com/raghupatik/leasedocumentintelligence

## Overview

Lease Document Intelligence is an API-backed lease abstraction application. Its main flow accepts lease PDFs, stores documents and metadata, extracts cited fields with confidence scores, and sends low-confidence results to human review. The README also describes field-definition management, search, audit/versioning, amendment awareness, and batch ingestion. The sampled controllers and services support the upload and review links; search and parts of extraction wiring are represented from documented capabilities and repository paths, so uncertain call edges are omitted.

Main entry points: [`LeaseDocumentIntelligence.API/Controllers/LeaseController.cs`](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/LeaseController.cs) (Lease API), [`LeaseDocumentIntelligence.Infrastructure/Data/CosmosDocumentMetadataRepository.cs`](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Data/CosmosDocumentMetadataRepository.cs) (Metadata repository), [`LeaseDocumentIntelligence.Infrastructure/Services/AzureAISearchService.cs`](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/AzureAISearchService.cs) (Vector search), [`LeaseDocumentIntelligence.Infrastructure/Services/ReviewQueueService.cs`](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/ReviewQueueService.cs) (Review queue service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Document intake"]
  node_validation["Document validation"]
  node_blob_service["Blob storage service"]
  node_blob_store[("Azure Blob Storage")]
end

subgraph group_extract["AI abstraction"]
  node_processing["Document processing"]
  node_extractor["Field extraction"]
  node_foundry["Foundry AI"]
  node_vector_search["Vector search"]
  node_embedding["Embedding service"]
end

subgraph group_review["Quality review"]
  node_review_service["Review queue service"]
end

subgraph group_data["Lease data"]
  node_metadata_repo["Metadata repository"]
  node_metadata_store[("Cosmos DB metadata")]
  node_definitions_repo["Field definitions repository"]
  node_definition_store[("Field definition store")]
  node_lease_repo["Lease document repository"]
  node_lease_store[("Lease document state")]
  node_search_store[("Azure AI Search")]
end

subgraph group_api["API and configuration"]
  node_lease_api["Lease API<br/>[LeaseController.cs]"]
  node_definitions_api["Field definitions API"]
  node_review_api["Review API"]
  node_search_api["Search API"]
  node_startup["Application startup<br/>[Program.cs]"]
  node_registration["Service registration"]
end

node_user(("Lease analyst"))
node_reviewer(("Human reviewer"))
node_azure_openai["Azure OpenAI"]

node_user -->|"uploads lease"| node_lease_api
node_lease_api -->|"validates file"| node_validation
node_lease_api -->|"uploads document"| node_blob_service
node_blob_service -->|"writes blob"| node_blob_store
node_lease_api -->|"creates metadata"| node_metadata_repo
node_metadata_repo -->|"writes metadata"| node_metadata_store
node_lease_api -->|"processes document"| node_processing
node_lease_api -->|"updates extraction"| node_metadata_repo
node_definitions_api -->|"manages definitions"| node_definitions_repo
node_definitions_repo -->|"reads and writes"| node_definition_store
node_processing -->|"extracts fields"| node_extractor
node_extractor -->|"requests extraction"| node_foundry
node_reviewer -->|"reviews fields"| node_review_api
node_review_api -->|"dispatches review"| node_review_service
node_review_service -->|"reads review status"| node_metadata_repo
node_review_service -->|"updates document"| node_lease_repo
node_lease_repo -->|"reads and writes"| node_lease_store
node_search_api -->|"searches leases"| node_vector_search
node_vector_search -->|"requests vectors"| node_embedding
node_embedding -.->|"generates embeddings"| node_azure_openai
node_vector_search -->|"queries index"| node_search_store
node_startup -->|"registers services"| node_registration

click node_lease_api "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/LeaseController.cs"
click node_validation "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/DocumentProcessingService.cs"
click node_blob_service "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/BlobStorageService.cs"
click node_metadata_repo "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Data/CosmosDocumentMetadataRepository.cs"
click node_processing "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/DocumentProcessingService.cs"
click node_extractor "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/ExtractionService.cs"
click node_foundry "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/FoundryAIService.cs"
click node_definitions_api "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/FieldDefinitionsController.cs"
click node_definitions_repo "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Data/CosmosFieldDefinitionRepository.cs"
click node_lease_repo "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Data/LeaseDocumentRepository.cs"
click node_review_api "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/ReviewController.cs"
click node_review_service "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/ReviewQueueService.cs"
click node_search_api "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/SearchController.cs"
click node_vector_search "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/AzureAISearchService.cs"
click node_embedding "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/EmbeddingService.cs"
click node_startup "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence/Program.cs"
click node_registration "https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/DependencyInjection/ServiceCollectionExtensions.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_validation,node_blob_service,node_blob_store,node_reviewer toneBlue
class node_processing,node_extractor,node_foundry,node_vector_search,node_embedding toneAmber
class node_review_service toneMint
class node_metadata_repo,node_metadata_store,node_definitions_repo,node_definition_store,node_lease_repo,node_lease_store,node_search_store toneRose
class node_lease_api,node_definitions_api,node_review_api,node_search_api,node_startup,node_registration,node_user,node_azure_openai toneIndigo
```

## Components

### Document intake

- [Document validation](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/DocumentProcessingService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/DocumentProcessingService.cs`
- [Blob storage service](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/BlobStorageService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/BlobStorageService.cs`
- **Azure Blob Storage**

### AI abstraction

- [Document processing](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/DocumentProcessingService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/DocumentProcessingService.cs`
- [Field extraction](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/ExtractionService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/ExtractionService.cs`
- [Foundry AI](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/FoundryAIService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/FoundryAIService.cs`
- [Vector search](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/AzureAISearchService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/AzureAISearchService.cs`
- [Embedding service](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/EmbeddingService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/EmbeddingService.cs`

### Quality review

- [Review queue service](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Services/ReviewQueueService.cs): `LeaseDocumentIntelligence.Infrastructure/Services/ReviewQueueService.cs`

### Lease data

- [Metadata repository](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Data/CosmosDocumentMetadataRepository.cs): `LeaseDocumentIntelligence.Infrastructure/Data/CosmosDocumentMetadataRepository.cs`
- **Cosmos DB metadata**
- [Field definitions repository](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Data/CosmosFieldDefinitionRepository.cs): `LeaseDocumentIntelligence.Infrastructure/Data/CosmosFieldDefinitionRepository.cs`
- **Field definition store**
- [Lease document repository](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/Data/LeaseDocumentRepository.cs): `LeaseDocumentIntelligence.Infrastructure/Data/LeaseDocumentRepository.cs`
- **Lease document state**
- **Azure AI Search**

### API and configuration

- [Lease API](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/LeaseController.cs): `LeaseDocumentIntelligence.API/Controllers/LeaseController.cs`
- [Field definitions API](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/FieldDefinitionsController.cs): `LeaseDocumentIntelligence.API/Controllers/FieldDefinitionsController.cs`
- [Review API](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/ReviewController.cs): `LeaseDocumentIntelligence.API/Controllers/ReviewController.cs`
- [Search API](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.API/Controllers/SearchController.cs): `LeaseDocumentIntelligence.API/Controllers/SearchController.cs`
- [Application startup](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence/Program.cs): `LeaseDocumentIntelligence/Program.cs`
- [Service registration](https://github.com/raghupatik/leasedocumentintelligence/blob/main/LeaseDocumentIntelligence.Infrastructure/DependencyInjection/ServiceCollectionExtensions.cs): `LeaseDocumentIntelligence.Infrastructure/DependencyInjection/ServiceCollectionExtensions.cs`

### Other components

- **Lease analyst**
- **Human reviewer**
- **Azure OpenAI**

## Connections

- Lease analyst → Lease API: uploads lease
- Lease API → Document validation: validates file
- Lease API → Blob storage service: uploads document
- Blob storage service → Azure Blob Storage: writes blob
- Lease API → Metadata repository: creates metadata
- Metadata repository → Cosmos DB metadata: writes metadata
- Lease API → Document processing: processes document
- Lease API → Metadata repository: updates extraction
- Field definitions API → Field definitions repository: manages definitions
- Field definitions repository → Field definition store: reads and writes
- Document processing → Field extraction: extracts fields
- Field extraction → Foundry AI: requests extraction
- Human reviewer → Review API: reviews fields
- Review API → Review queue service: dispatches review
- Review queue service → Metadata repository: reads review status
- Review queue service → Lease document repository: updates document
- Lease document repository → Lease document state: reads and writes
- Search API → Vector search: searches leases
- Vector search → Embedding service: requests vectors
- Embedding service → Azure OpenAI: generates embeddings
- Vector search → Azure AI Search: queries index
- Application startup → Service registration: registers services
