The Legal Terms Search Helper is a web application designed to assist users in searching and understanding legal documents such as terms of service, NDAs, and other contracts. Users can upload a text file containing legal content, ask questions about it (e.g., "What is the refund policy?"), and receive concise, easy-to-read answers extracted from the document. The application leverages natural language processing (NLP) and stores question-answer pairs in a MySQL database for future reference.
- Upload a
.txtfile containing legal content. - Ask questions about the uploaded document (e.g., "When can a user cancel?").
- Receive simplified answers (e.g., "Users can cancel within 14 days as per section 3.2.").
- Store question-answer history in a MySQL database.
- User-friendly React-based interface with a chat-like experience.
- Python 3.9+ for the backend server.
- Node.js and npm for the frontend.
- MySQL Server for storing Q&A history.
- Required Python libraries (listed in
requirements.txt). - A
.envfile with MySQL credentials and API base URL.
- Clone the repository:
git clone <repository-url> cd client/legal-terms-search-helper/server
- Create a
.envfile in theserverdirectory with the following content:MYSQL_HOST=localhost MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DB=legal_terms_db - Install Python dependencies:
pip install -r requirements.txt
- Set up the MySQL database (the app will create the necessary database and table on first run).
- Run the Flask server:
python app.py
- Navigate to the
client/legal-terms-search-helperdirectory:cd client/legal-terms-search-helper - Install dependencies:
npm install
- Update the
REACT_APP_API_BASE_URLin the.envfile to match your backend URL (e.g.,http://localhost:5000). - Start the React app:
npm start
- Open your browser and navigate to
http://localhost:3000. - Upload a
.txtfile containing legal text using the file uploader. - Once uploaded, type a question in the input field (e.g., "What is the refund policy?").
- View the answer in the chat window and explore previous Q&A history.
client/legal-terms-search-helper/
├── public/
├── src/
│ ├── components/
│ │ ├── ChatWindow.js
│ │ ├── FileUploader.js
│ │ └── QuestionInput.js
│ ├── App.css
│ ├── App.js
│ ├── index.css
│ └── index.js
├── .gitignore
├── package-lock.json
└── package.json
server/
├── env/
├── static/
├── uploads/
├── app.py
├── .gitignore
├── legal_terms.txt
└── requirements.txt
README.md
- Backend: Python, Flask, SentenceTransformers, ChromaDB, Hugging Face Transformers, MySQL.
- Frontend: React, Material-UI, Axios.
- NLP: Embedding generation with
all-MiniLM-L6-v2, Question-answering withdistilbert-base-uncased-distilled-squad.
Contributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure to follow the existing code style and add tests if applicable.
This project is licensed under the MIT License. See the LICENSE file for details.
- Email: kckdeepak29@gmail.com
- GitHub Issues