Skip to content

Nasairwhite/lawyer-practice-optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Lawyer Practice Optimization Diagnostic An AI-powered diagnostic tool that helps litigation attorneys identify opportunities to save 5-10+ hours per week through automation and workflow optimization. ## Features - **AI-Guided Assessment**: Moonshot AI (Kimi model) provides intelligent guidance for each diagnostic question - **20 Targeted Questions**: Comprehensive diagnostic covering intake, documents, case management, billing, and administration - **Multi-Choice Format**: Easy-to-answer questions with 4 options (including custom input) - **Personalized Analysis**: AI-generated reports tailored to litigation practices with minimal tech use - **Time Savings Calculator**: Quantified estimates of hours saved per week - **Prioritized Recommendations**: Clear action roadmap ranked by impact and ease of implementation - **Downloadable Report**: PDF-style report for offline review and sharing ## Architecture ``` lawyer_practice_optimizer/ � app.py # Flask web application � moonshot_client.py # Moonshot AI API integration � diagnostic_questions.py # Question library (20 questions) � email_sender.py # Email delivery system � analyzer.py # Response analysis and scoring � requirements.txt # Python dependencies � .env.template # Environment configuration template � templates/ # HTML templates � � base.html # Master template � � index.html # Landing page � � question.html # Question page � � complete.html # Completion page � � report.html # Report display � � 404.html # Not found error � � 500.html # Server error � README.md # This file ``` ## Quick Start ### 1. Prerequisites - Python 3.9 or higher - Moonshot AI API key (get from https://platform.moonshot.cn) - SMTP email credentials (for sending invitations) ### 2. Installation ```bash # Clone or download the project cd lawyer_practice_optimizer # Create virtual environment (recommended) python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt # Configure environment cp .env.template .env # Edit .env and add your: # - MOONSHOT_API_KEY # - SMTP credentials # - FLASK_SECRET_KEY # Use a secure text editor to fill in your .env file ``` ### 3. Configuration Edit `.env` file with your settings: ```bash # Required: Moonshot AI API MOONSHOT_API_KEY=your_api_key_here # Required: Flask secret key # Generate with: python -c "import secrets; print(secrets.token_hex(32))" FLASK_SECRET_KEY=your_secret_key_here # Required: Email SMTP settings # For Gmail, use an App Password if you have 2FA enabled SMTP_HOST=smtp.gmail.com SMTP_PORT=587 [email protected] SMTP_PASSWORD=your_app_password [email protected] # Optional: Base URL (for production) BASE_URL=http://localhost:5000 # Change to your domain ``` ### 4. Run the Application ```bash # Run the Flask app python app.py # Or with environment variables: FLASK_ENV=development python app.py # Server will start at http://localhost:5000 ``` ### 5. Test the Diagnostic 1. Open browser to http://localhost:5000 2. Enter your name and start the assessment 3. Answer the 20 diagnostic questions 4. Receive your personalized report ### 6. Email Integration To email the diagnostic to your lawyer: ```python from email_sender import send_diagnostic_to_lawyer # Send invitation success = send_diagnostic_to_lawyer( lawyer_name="John Smith", lawyer_email="[email protected]", sender_name="Your Name" ) if success: print("Email sent successfully!") else: print("Failed to send email.") ``` ## Using the Diagnostic ### For the Lawyer (Recipient) 1. **Receive Email**: Gets an email with a secure, one-time link 2. **Click Link**: Opens the diagnostic in their browser 3. **Complete Assessment**: 20 questions with AI guidance 4. **Get Report**: Personalized optimization report ### For the Consultant/Sender 1. **Send Invitation**: Use the email function or manual link generation 2. **Track Progress**: Monitor completion (sessions stored in memory) 3. **Review Results**: Discuss report with lawyer 4. **Implement Recommendations**: Help execute the action plan ## Question Categories The diagnostic covers 6 key areas: 1. **Client Intake & Management** (4 questions) - Inquiry handling, conflict checking, communication tracking 2. **Document Drafting & Templates** (4 questions) - Motion drafting, clause libraries, formatting, document assembly 3. **Case & Deadline Management** (4 questions) - Court deadline tracking, scheduling, task management 4. **Billing & Time Tracking** (3 questions) - Time capture, invoicing, billable hour recovery 5. **Administrative Tasks** (3 questions) - Admin time, delegation, after-hours work 6. **Pain Points & Bottlenecks** (4 questions) - Biggest frustrations, deadline misses, automation priorities ## Report Output The final report includes: - **Optimization Grade**: A-F rating with overall percentage score - **Category Breakdown**: Scores for each practice area - **Time Savings Analysis**: Estimated hours saved per week - **Quick Wins**: Easy-to-implement changes (this week) - **Short-term Improvements**: 30-60 day implementation - **Long-term Projects**: 90+ day strategic changes - **Specific Action Steps**: Detailed implementation guidance - **Cost Estimates**: Budget ranges for each recommendation ## Technical Details ### Scoring System - **4-point scale**: Each question scored 1 (inefficient) to 4 (optimized) - **Category scores**: Average of questions in each category - **Overall grade**: Calculated from total possible points - **Time savings**: Algorithm estimates based on response patterns ### AI Integration The Moonshot AI client: - Provides contextual guidance for each question - Analyzes response patterns for optimization opportunities - Generates personalized recommendations - Creates narrative reports with specific action steps ### Security Features - **Secure tokens**: One-time use diagnostic links - **Link expiration**: Links expire after 7 days (configurable) - **Session management**: 24-hour session lifetime - **No data retention**: Responses stored in memory only (by default) ## Customization ### Adding Questions Edit `diagnostic_questions.py`: ```python DiagnosticQuestion( id="your_question_id", category="category_name", question_text="Your question here", options=[ QuestionOption("id_a", "Option A text", 1), QuestionOption("id_b", "Option B text", 2), QuestionOption("id_c", "Option C text", 3), QuestionOption("id_d", "", 4, custom_input=True) # Custom input option ] ) ``` ### Modifying AI Prompts Edit prompts in `moonshot_client.py`: - `_build_guidance_system_prompt()`: Question guidance - `_build_analysis_system_prompt()`: Response analysis - `_build_report_system_prompt()`: Final report generation ### Styling Changes Modify CSS in `templates/base.html` or add custom CSS in `static/css/` ## Deployment ### Production Checklist - [ ] Set `FLASK_ENV=production` - [ ] Use a production WSGI server (Gunicorn, uWSGI) - [ ] Set strong `FLASK_SECRET_KEY` - [ ] Configure production SMTP credentials - [ ] Set `BASE_URL` to your domain - [ ] Use a proper database (PostgreSQL, MySQL) for session storage - [ ] Enable HTTPS with SSL certificate - [ ] Set up log rotation and monitoring - [ ] Configure firewall and security groups ### Docker Deployment ```dockerfile FROM python:3.9-slim WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . EXPOSE 5000 CMD ["python", "app.py"] ``` ### Environment Variables for Production ```bash # Production .env FLASK_ENV=production FLASK_SECRET_KEY=your_very_long_secure_random_key_here MOONSHOT_API_KEY=your_production_api_key BASE_URL=https://yourdomain.com [email protected] SMTP_PASSWORD=secure_password [email protected] FROM_NAME="Practice Optimization Diagnostic" ``` ## Troubleshooting ### Moonshot API Issues **Problem**: "API key not found" error **Solution**: Ensure MOONSHOT_API_KEY is set in .env file **Problem**: API calls are slow **Solution**: Consider using Kimi-8k model for faster responses ### Email Delivery Problems **Problem**: "Failed to send email" **Solution**: - Verify SMTP credentials in .env - For Gmail: Use App Password (not regular password) - Check firewall settings for port 587 - Review error logs for specific SMTP errors ### Application Errors **Problem**: "Session not found" when accessing questions **Solution**: Ensure cookies are enabled in browser **Problem**: Template errors **Solution**: Check that all template files are in the templates/ directory ### Link Expiration **Problem**: "Invalid or expired link" error **Solution**: Links expire after 7 days. Generate a new invitation. ## License This project is created for professional consultation purposes. ## Support For technical issues: 1. Check the troubleshooting section above 2. Review application logs 3. Verify all environment variables are set correctly 4. Test with development settings first ## Roadmap Future enhancements: - [ ] Database storage (PostgreSQL) - [ ] User authentication - [ ] Multiple practice area support - [ ] Report PDF generation - [ ] Email reminder system - [ ] Dashboard for tracking multiple lawyers - [ ] Integration with practice management APIs - [ ] Mobile app version ## Contributing This is a specialized tool for legal practice consultation. Customization is encouraged to match specific workflows and client needs. --- **Note**: This tool uses AI analysis to provide recommendations. Always review AI-generated suggestions with professional judgment and consider the unique needs of each practice before implementation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published