This project contains the backend API and the frontend web application for the Accorda AI legal assistant.
There are two ways to access the application:
Hosted Version (Recommended):
Local Development Setup:
.env
file in the project root directory (where docker-compose.yml
is located)..env
file, replacing XXXX
with your actual key:GOOGLE_API_KEY=XXXX
docker compose up --build
--build
flag is crucial for the first run or after dependency changes. Subsequent runs can use docker compose up
.The backend exposes the following primary API endpoints under the /api/
prefix:
GET /hello
: Basic health check or root endpoint.POST /generate
: General purpose AI text generation.POST /extract_text
: Extracts text content from uploaded documents (e.g., PDFs).POST /compare
: Compares two contracts and identifies differences.POST /analyze/categorize
: Categorizes the type of contract.POST /analyze/summary
: Generates a summary of a contract.POST /analyze/check-requirements
: Checks a contract against general requirements.POST /analyze/check-category-requirements
: Checks a contract against requirements specific to its category.POST /explain-diff
: Explains the differences found between two contracts.POST /analyze-diff-impact
: Analyzes the potential impact of the differences between two contracts.Note: For detailed request/response schemas and parameters, please refer to the Swagger documentation at /docs
.
This application prioritizes data privacy. Uploaded documents are not stored permanently on our servers. They are processed solely in temporary memory or temporary files during the analysis or comparison task. Once the processing is complete and the results are returned to the user, these temporary files are immediately and securely deleted. This ensures that your sensitive contract data is not retained, aligning with GDPR principles.
The core contract analysis process, typically triggered via the frontend, involves a sequence of calls to the backend API:
/api/analyze/summary
): The AI first generates a concise summary of the entire contract./api/analyze/check-requirements
): The AI then checks the contract against a predefined set of general legal and structural requirements applicable to most contracts./api/analyze/categorize
& /api/analyze/check-category-requirements
):backend/prompts/category_requirements_schemas.json
.Schema File (category_requirements_schemas.json
): This file defines the structured criteria (compliance matrix) for each supported contract category. It includes the specific points the AI should look for during the category-specific check.
Current Status: As a proof of concept, only the "Non-Disclosure Agreement" category is currently defined and implemented within the category_requirements_schemas.json
file. Integration of other categories is very straightforward - just add those to the JSON file following the existing structure.
/backend
directory trigger an automatic reload of the FastAPI server using uvicorn --reload
./frontend/src
directory trigger Vite's Hot Module Replacement (HMR) for instant updates in the browser.Ctrl+C
in the terminal where docker compose up
is running.docker compose down
The frontend application, located in /frontend
, is a Single Page Application (SPA) built with Svelte and TypeScript, using Vite for development and builds, and Tailwind CSS for styling.
Key Directories & Files:
frontend/src/
: Core application code.main.ts
: Application entry point.App.svelte
: Root component orchestrating the UI.app.css
: Global styles.components/
: Contains reusable UI components:Login.svelte
: Handles user authentication.Sidebar.svelte
: Navigation panel, likely for selecting analysis types or managing documents.TopBar.svelte
: Application header, possibly including user info or global actions.Welcome.svelte
: Initial view or dashboard.ContractAnalysis.svelte
, ContractComparison.svelte
, ContractSummary.svelte
: Components dedicated to specific contract interaction features.SettingsView.svelte
: Interface for user/application settings.Modal.svelte
: Reusable modal dialog component.LoadingSpinner.svelte
: Visual indicator for ongoing operations.HelpTutorial.svelte
: Component providing guidance or tutorials.stores/
: Svelte stores for state management.settingsStore.ts
: Manages application-wide settings.frontend/public/
: Static assets.frontend/index.html
: Main HTML entry point.vite.config.ts
, svelte.config.cjs
, tailwind.config.cjs
, tsconfig.json
, etc.frontend/Dockerfile
: Defines the build process for the frontend container.After performing a contract analysis using the ContractAnalysis
component in the frontend, the generated results (including the summary, general requirements check, and category-specific analysis) can be exported to a professionally formatted PDF document. This functionality is handled within the ContractAnalysis.svelte
component itself, using the jsPDF
library. Same applies for the ContractComparison component too.
category_requirements_schemas.json
.