# 5423456-dotcom/contrct_analyser architecture

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

- Interactive diagram: https://gitdiagram.com/5423456-dotcom/contrct_analyser
- Repository: https://github.com/5423456-dotcom/contrct_analyser

## Overview

ContractAI is a student-focused contract-analysis web application. A student uploads a PDF or pastes contract text (or selects a demo); the backend extracts text with page references, analyzes student-relevant clauses, and presents obligations and plain-English findings. Students can revisit saved analyses and download formatted PDF reports. The README documents these capabilities and a proposed file layout, but the supplied file tree contains only the README and launcher scripts, with no source excerpts; component paths and relationships below therefore reflect README documentation, not inspected implementation.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Student interface"]
  node_analyzer["Upload and analysis"]
  node_upload["Upload controls"]
  node_results["Results dashboard"]
  node_obligations["Obligations view"]
  node_findings["Clause comparisons"]
  node_historyui["Analysis history"]
  node_api_client["API client"]
end

subgraph group_api["Backend API"]
  node_contracts_api["Contract endpoints"]
  node_analysis_api["Analysis endpoints"]
  node_report_api["Report endpoint"]
end

subgraph group_analysis["Contract analysis"]
  node_pdf_extract["PDF extraction"]
  node_ai_engine["Clause analysis"]
end

subgraph group_persistence["Identity and history"]
  node_history[("Analysis storage")]
  node_auth_api["Authentication"]
  node_security["Password and tokens"]
end

subgraph group_reporting["Reports"]
  node_report_gen["PDF generation"]
end

node_student(("Student"))
node_gemini{{"Gemini API"}}

node_student -->|"submits contract"| node_analyzer
node_analyzer -->|"offers upload"| node_upload
node_analyzer -.->|"requests analysis"| node_api_client
node_api_client -->|"uploads contract"| node_contracts_api
node_contracts_api -->|"extracts PDF text"| node_pdf_extract
node_contracts_api -.->|"provides contract"| node_analysis_api
node_analysis_api -->|"triggers analysis"| node_ai_engine
node_ai_engine -.->|"uses when configured"| node_gemini
node_analysis_api -->|"stores findings"| node_history
node_api_client -.->|"loads results"| node_results
node_results -->|"shows obligations"| node_obligations
node_results -->|"shows comparisons"| node_findings
node_student -->|"reopens analyses"| node_historyui
node_historyui -.->|"requests history"| node_api_client
node_api_client -->|"gets history"| node_analysis_api
node_student -->|"downloads report"| node_report_api
node_report_api -->|"generates PDF"| node_report_gen
node_student -->|"registers or logs in"| node_auth_api
node_auth_api -->|"hashes and issues tokens"| node_security

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_analyzer,node_upload,node_results,node_obligations,node_findings,node_historyui,node_api_client toneBlue
class node_contracts_api,node_analysis_api,node_report_api toneAmber
class node_pdf_extract,node_ai_engine,node_gemini toneMint
class node_history,node_auth_api,node_security toneRose
class node_report_gen,node_student toneIndigo
```

## Components

### Student interface

- **Upload and analysis**
- **Upload controls**
- **Results dashboard**
- **Obligations view**
- **Clause comparisons**
- **Analysis history**
- **API client**

### Backend API

- **Contract endpoints**
- **Analysis endpoints**
- **Report endpoint**

### Contract analysis

- **PDF extraction**
- **Clause analysis**

### Identity and history

- **Analysis storage**
- **Authentication**
- **Password and tokens**

### Reports

- **PDF generation**

### Other components

- **Student**
- **Gemini API**

## Connections

- Student → Upload and analysis: submits contract (evidence: `README.md`)
- Upload and analysis → Upload controls: offers upload (evidence: `README.md`)
- Upload and analysis → API client: requests analysis
- API client → Contract endpoints: uploads contract (evidence: `README.md`)
- Contract endpoints → PDF extraction: extracts PDF text (evidence: `README.md`)
- Contract endpoints → Analysis endpoints: provides contract
- Analysis endpoints → Clause analysis: triggers analysis (evidence: `README.md`)
- Clause analysis → Gemini API: uses when configured (evidence: `README.md`)
- Analysis endpoints → Analysis storage: stores findings (evidence: `README.md`)
- API client → Results dashboard: loads results
- Results dashboard → Obligations view: shows obligations (evidence: `README.md`)
- Results dashboard → Clause comparisons: shows comparisons (evidence: `README.md`)
- Student → Analysis history: reopens analyses (evidence: `README.md`)
- Analysis history → API client: requests history
- API client → Analysis endpoints: gets history (evidence: `README.md`)
- Student → Report endpoint: downloads report (evidence: `README.md`)
- Report endpoint → PDF generation: generates PDF (evidence: `README.md`)
- Student → Authentication: registers or logs in (evidence: `README.md`)
- Authentication → Password and tokens: hashes and issues tokens (evidence: `README.md`)
