A Django-based web application that provides intelligent contract analysis and risk assessment using OpenAI's API.
- Secure contract upload and management
- Automated risk analysis using OpenAI
- Risk scoring and categorization
- Clause-level risk identification
- User authentication and authorization
- Modern responsive UI with Bootstrap
- File versioning and audit trail
- Python 3.8+
- pip (Python package manager)
- Node.js (for frontend dependencies)
- PostgreSQL (recommended) or SQLite
- OpenAI API key
This project uses Docker for deployment. Follow these steps to set up the environment:
- Clone the repository:
git clone https://github.com/DAMunene/LegalMind.git
cd LegalMind- Set up environment variables:
Create a
.envfile in the project root with the following content:
DEBUG=True
SECRET_KEY=your-secret-key-here
DATABASE_URL=postgres://postgres:postgres@db:5432/contract_db
OPENAI_API_KEY=your-openai-api-key
- Build and run the Docker containers:
docker-compose build
docker-compose up -d-
After starting the containers with
docker-compose up -d, the application will be available at:- Web interface: http://localhost:8080
- API: http://localhost:8080/api/
- Admin interface: http://localhost:8080/admin/
-
To create a superuser:
docker-compose exec web python manage.py createsuperuser- To run database migrations:
docker-compose exec web python manage.py makemigrations
docker-compose exec web python manage.py migrate- Start containers:
docker-compose up -d - Stop containers:
docker-compose down - View logs:
docker-compose logs -f - Execute commands in web container:
docker-compose exec web <command> - Execute commands in database container:
docker-compose exec db <command>
For local development without Docker:
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Python dependencies:
pip install django django-crispy-forms django-simple-jwt django-filter
django-environ djangorestframework psycopg2-binary- Run the development server:
python manage.py runserverNote: The Docker setup is recommended for production and consistent development environments.
contract-analysis-platform/
├── api/ # Django app containing main application logic
│ ├── models.py # Database models
│ ├── views.py # API views
│ ├── template_views.py # Template-based views
│ ├── urls.py # URL routing
│ ├── serializers.py # Django REST framework serializers
│ └── services.py # Business logic and OpenAI integration
├── core/ # Project configuration
│ ├── settings.py # Django settings
│ ├── urls.py # Root URL configuration
│ └── wsgi.py # WSGI configuration
└── templates/ # HTML templates
The application provides RESTful endpoints for contract management:
- POST
/api/auth/register/- Register a new user - POST
/api/auth/login/- Login and get JWT tokens - POST
/api/auth/logout/- Logout and blacklist refresh token
- POST
/api/contracts/- Upload and analyze a new contract - GET
/api/contracts/- List all user's contracts - GET
/api/contracts/{id}/- Get contract details - PUT
/api/contracts/{id}/- Update contract - DELETE
/api/contracts/{id}/- Delete contract
- JWT-based authentication
- User-based authorization
- File upload validation
- Rate limiting
- Secure password hashing
- CSRF protection
- XSS prevention
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository or contact [email protected]