How ashuradhipathi/ai-contract-assistant works
Project Type and Purpose
• This is a single‑repo, full‑stack Python application built on Streamlit.
• Purpose: ingest uploaded contract files, extract clauses and insights, generate deviations against templates, and present results in a multi‑page UI.
File Structure
• Top level:
• New_Contract.py: entry point (Streamlit app)
• rag.py: functions to generate embeddings and manage vector store (RAG)
• utils.py: text‑extraction and NLP helper functions (extract_clauses, extract_keypoints, find_deviations)
• requirements.txt: dependencies (streamlit, openai, langchain, vector‑db, etc.)
• Documentation.md/README.md: high‑level overview and setup
• pages/ directory:
• Clauses.py, Contract_Insights.py, Deviations.py — each implements a Streamlit page using utility functions.
Extract Insights from the README
• The app uses Streamlit to render a multi‑page interface.
• It relies on helper functions in utils.py and on a retrieval‑augmented generation approach implemented in rag.py.
• Key workflows: file upload → text extraction → embedding / vector‑store build or query → LLM call → render results.
Main Components
a. Frontend/UI Layer
• Streamlit app (New_Contract.py + pages/*.py)
• Pages: Home (upload), Clauses, Contract Insights, Deviations
b. Application/Business‑Logic Layer
• utils.py: text preprocessing, clause/keypoint/deviation extraction
• rag.py: embedding generation, vector‑store creation & querying
c. Data/Storage Layer
• Local file store for uploaded contracts (could be ephemeral)
• Vector database (e.g., Chroma or FAISS instance)
d. External Services
• OpenAI (LLM API for generation & embeddings)
• Any OCR/PDF‑parsing library (if used for text extraction)
Relationships & Data Flows
• User interacts with Streamlit UI → uploads contract file.
• UI calls utils.extract_text() → raw contract text.
• Raw text passed to rag.create_vectorstore() → embeds via OpenAI → stored in vector DB.
• On each page:
• “Clauses” page calls utils.extract_clauses(text) → may query vector store + LLM.
• “Contract Insights” page calls utils.extract_keypoints(text).
• “Deviations” page calls utils.find_deviations(text, template).
• Results returned to UI and displayed.
Architectural Patterns & Design Principles
• Modular separation: UI (pages) vs. business logic (utils, rag).
• RAG pattern: embeddings + vector‑store retrieval + LLM generation.
• Single‑process monolith (Streamlit).
• Utility functions centralized in utils.py for reusability.
Detailed Element Checklist
• Labels: function names (extract_text, create_vectorstore, extract_clauses, etc.)