Smart contract management system with AI-powered risk analysis and automated procurement workflows.
- Contract Management: Complete contract lifecycle management
- AI Risk Analysis: Automated contract risk assessment using AI
- Role-based Access Control: Different views for Legal, Management, and Procurement teams
- Document Processing: OCR and intelligent document parsing
- Dashboard Analytics: Real-time KPIs and contract insights
- Python 3.11+ with FastAPI
- Supabase for database and authentication
- Groq API for AI processing
- PyPDF2 for document processing
- Tesseract OCR for text extraction
- React 18 with TypeScript
- Vite for build tooling
- Tailwind CSS for styling
- React Router for navigation
- Lucide React for icons
Before you begin, ensure you have the following installed:
- Node.js (version 20.19+ or 22.12+)
- Python (version 3.11+)
- npm or yarn
- Git
git clone https://github.com/gitaufar/optimind.git
cd optimindcd backend# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtCopy the example environment file and configure your credentials:
cp .env.example .envEdit the .env file with your actual credentials:
# AI/ML API Keys (REQUIRED)
GROQ_API_KEY=your_groq_api_key_here
HUGGINGFACE_API_TOKEN=your_huggingface_token_here
OPENAI_API_KEY=your_openai_api_key_here
# Security Settings (IMPORTANT: Change in production!)
SECRET_KEY=your_very_secure_random_secret_key_here
# Database Settings
DATABASE_URL=sqlite:///./contracts.db
# Application Settings
APP_ENV=development
DEBUG=True
HOST=0.0.0.0
PORT=8000
# File Upload Settings
UPLOAD_DIR=./data/uploads
MAX_FILE_SIZE=10485760
# CORS Settings (comma-separated)
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173.env file to version control. Always use .env.example as a template.
- Create a new project on Supabase
- Run the SQL scripts in
frontend/supabase/directory:-- Execute these files in order: 1. complete_schema.sql 2. contracts.sql 3. contract_extractions.sql 4. procurement_kpi.sql 5. auth_roles.sql 6. create_pdf_storage_bucket.sql 7. seed.sql
python main.pyThe backend will be available at http://localhost:8000
cd ../frontendnpm installCreate a .env file in the frontend directory:
# Supabase Configuration
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
# API Configuration
VITE_API_BASE_URL=http://localhost:8000npm run devThe frontend will be available at http://localhost:5173
# Activate virtual environment
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
# Start development server
python main.py
# Run with auto-reload
uvicorn main:app --reload --host 0.0.0.0 --port 8000# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lint
# Type checking
npm run type-checkifest/
βββ backend/
β βββ main.py # FastAPI application entry point
β βββ requirements.txt # Python dependencies
β βββ config/
β β βββ settings.py # Application configuration
β βββ models/ # Data models
β β βββ contract.py
β β βββ risk.py
β βββ routes/ # API endpoints
β β βββ analyze.py
β β βββ lifecycle.py
β β βββ risk.py
β βββ services/ # Business logic
β β βββ groq_services.py
β β βββ ocr_services.py
β β βββ risk_services.py
β βββ utils/ # Utilities
β βββ pdf_parser.py
β βββ preprocess.py
βββ frontend/
β βββ package.json # Node.js dependencies
β βββ vite.config.ts # Vite configuration
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ src/
β β βββ components/ # Reusable React components
β β βββ routes/ # Page components
β β β βββ auth/ # Authentication pages
β β β βββ legal/ # Legal team pages
β β β βββ management/ # Management pages
β β β βββ procurement/ # Procurement pages
β β βββ hooks/ # Custom React hooks
β β βββ services/ # API service functions
β β βββ types/ # TypeScript type definitions
β β βββ utils/ # Utility functions
β βββ supabase/ # Database schema and migrations
βββ README.md
The system supports role-based access control with three main roles:
- Legal: Can view and review submitted contracts
- Management: Can view reviewed contracts and analytics
- Procurement: Can upload and manage contract submissions
After running the seed script, you can use these test accounts:
Legal User:
- Email: admin@gmail.com
- Password: admin123
Management User:
- Email: andikger@gmail.com
- Password: 12345678
Procurement User:
- Email: adnika@gmail..com
- Password: 12345678
cd backend
python -m pytest tests/cd frontend
npm run test- Set production environment variables
- Use a production WSGI server like Gunicorn:
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker
- Build the production bundle:
npm run build
- Serve the
distfolder using a web server like Nginx or deploy to services like Vercel, Netlify.
- Import Error: Make sure virtual environment is activated
- Database Connection: Verify Supabase credentials in
.env - Port Already in Use: Change port in
main.pyor kill existing process
- Node Version: Ensure Node.js version is 20.19+ or 22.12+
- Build Errors: Run
npm run type-checkto identify TypeScript issues - API Connection: Verify backend is running and
VITE_API_BASE_URLis correct
- Backend logs: Check console output or
logs/directory - Frontend logs: Open browser developer console
- Database logs: Check Supabase dashboard
Once the backend is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please contact:
- Email: zhafiraufar123@gmail.com
- GitHub Issues: Create an issue
Made with β€οΈ by the ZAS Team