VibeLegal is a production-ready AI-powered contract drafting platform that transforms how legal professionals create employment contracts. Built specifically for California employment law, it features conversational AI, advanced customization controls, comprehensive legal compliance, and enterprise-grade admin capabilities.
Status: Production-Ready MVP on admin-dashboard branch
- Focus: California Employment Agreements
- Infrastructure: Complete payment processing, subscription management, admin dashboard
- Market Status: 0 paying customers (ready for launch)
- Recent Work: Admin dashboard with data visualization, revenue analytics, and 4 critical bug fixes
- Master Input Brief System: 50+ parameter extraction patterns for comprehensive legal analysis
- California Employment Law Compliance: 2025-compliant wage, hour, meal/rest period requirements
- Strategic Legal AI: Employment law attorney persona with risk assessment
- Employer Protection Focus: IP assignment, confidentiality, severance, non-compete coverage
- Clause Library: 99 professionally crafted legal variations across 33 categories
- Natural Language Processing: Create contracts through conversation
- Resume Capability: Continue contract creation across sessions
- Parameter Extraction: Automatic identification of legal terms and conditions
- Progress Tracking: Real-time contract building with state management
- Google Gemini Integration: Advanced AI analysis and clause recommendations
- Risk Tolerance Controls: Employer-friendly to employee-favorable spectrum
- Legal Stance Selection: Conservative, balanced, or progressive approaches
- Contract Templates: 5 professional variations for different use cases
- Clause Selection: Granular control over every contract section
- Stripe Integration: Full payment processing with webhook support
- Tiered Access: Basic (5 contracts/month), Pro (unlimited), Enterprise
- Feature Gating: Progressive feature unlocking based on subscription tier
- Usage Tracking: Real-time contract generation monitoring
- Payment History: Complete transaction tracking and billing management
- User Management: Search, filter, view detailed user profiles
- Subscription Management: Manual subscription tier adjustments
- Revenue Analytics: MRR tracking, revenue by tier, growth metrics
- Data Visualization: Interactive charts for users, contracts, and revenue trends
- User Impersonation: Temporary access tokens for debugging (admin-only)
- Audit Logging: Complete tracking of all admin actions
- Recent Activity: Monitor signups, contracts, and payments in real-time
- Local LLM Support: Infrastructure ready for on-premise LLM deployment
- Privacy/Security: Enterprise customers can use local models for sensitive data
- Status: Backend infrastructure complete, activation pending
- Runtime: Node.js 18+ with Express.js framework
- Database: PostgreSQL with comprehensive subscription schema
- Authentication: JWT tokens with bcryptjs password hashing
- AI Integration: Google Gemini AI with custom legal prompting
- Payment Processing: Stripe integration with webhook handling
- Legal Engine: Master Input Brief composer with 60+ parameter mapping
- Security: Helmet, CORS, rate limiting, input validation, webhook signature verification
- Environment Validation: Joi-based schema validation at startup
- Error Handling: Centralized asyncHandler middleware across all routes
- Monitoring: Health check endpoint and Prometheus metrics
- Framework: React 18 with modern hooks and context
- Build Tool: Vite for fast development and optimized production builds
- UI Components: shadcn/ui with Radix UI primitives
- Styling: Tailwind CSS for responsive, professional design
- Charts: Recharts for data visualization (admin dashboard)
- State Management: React Context for authentication and app state
- Routing: React Router v6 with protected routes
- Icons: Lucide React for consistent iconography
- users: Account management with Stripe integration, admin flags
- user_subscriptions: Subscription management with billing cycles
- contracts: Generated contracts with search/filter capabilities
- chat_sessions: Conversation state preservation for resume functionality
- payment_history: Transaction tracking and billing management
- subscription_usage: Feature usage analytics and tier enforcement
- admin_actions: Audit log for all administrative actions
- Node.js: v18 or higher
- npm or pnpm
- PostgreSQL: v12 or higher
- Google Gemini API Key: For AI-powered contract generation
- Stripe Account: For payment processing (optional for development)
git clone <repository-url>
cd VibeLegal
# Backend setup
cd backend
npm install
# Frontend setup
cd ../frontend
npm installCreate .env file in the backend directory (use .env.example as template):
# Server Configuration
PORT=5000
NODE_ENV=development
# Database Configuration
DATABASE_URL=postgresql://username:password@localhost:5432/vibelegal
# Google Gemini AI (primary AI provider)
GOOGLE_AI_API_KEY=your_gemini_api_key
# JWT Secret (minimum 24 characters)
JWT_SECRET=your_secure_jwt_secret_here
# Stripe Configuration (optional for development)
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
STRIPE_PRO_MONTHLY_PRICE_ID=price_pro_monthly_id
STRIPE_PRO_YEARLY_PRICE_ID=price_pro_yearly_id
STRIPE_ENTERPRISE_MONTHLY_PRICE_ID=price_enterprise_monthly_id
STRIPE_ENTERPRISE_YEARLY_PRICE_ID=price_enterprise_yearly_id
FRONTEND_URL=http://localhost:5173Note: Environment variables are validated at startup. Server will fail fast with clear error messages if required variables are missing.
cd backend
# Create database
createdb vibelegal
# Run base schema
psql -d vibelegal -f database.sql
# Run Stripe integration migration
psql -d vibelegal -f stripe-migration.sql
# Grant admin access to a user (optional)
psql -d vibelegal -c "UPDATE users SET is_admin = true WHERE email = 'your_email@example.com';"# Auto-create Stripe products and prices
node setup-stripe.js
# Copy generated price IDs to .env file
# Set up webhook endpoint: /api/user/webhook/stripe in Stripe Dashboard# Backend (Terminal 1)
cd backend
npm run dev
# Frontend (Terminal 2)
cd frontend
npm run devAccess the application at http://localhost:5173
VibeLegal now ships with production-ready Docker images and an Nginx front-end so you can deploy the entire SaaS stack without configuration drift.
- Copy the root
.env.examplefile to.envand update it with your secrets (OpenAI key, JWT secret, Stripe keys, etc.). - Optionally, copy
backend/.env.exampletobackend/.envif you plan to run the backend outside of Docker.
The Compose stack will automatically read values from .env and fall back to sensible defaults for local Postgres credentials.
docker compose up --build -dThis command builds three services:
- postgres – managed PostgreSQL 15 instance with persistent volume storage.
- backend – Node.js API built from
backend/Dockerfilewith health checks and strict env validation. - frontend – Static React build served by Nginx using
frontend/nginx.conf, proxying/apicalls to the backend container.
Once the containers are healthy, the application is available at http://localhost:8080.
Exec into the backend container to run SQL migrations against the bundled Postgres instance:
docker compose exec backend bash -c "psql $DATABASE_URL -f database.sql"
docker compose exec backend bash -c "psql $DATABASE_URL -f stripe-migration.sql"docker compose downAdd -v to remove the Postgres volume as well.
- Contracts: 5 per month
- Features: Basic contract generation
- Target: Individual lawyers testing the platform
- Contracts: Unlimited
- Features: Conversational AI, advanced customization, risk controls, clause selection
- Target: Solo practitioners and small firms
- Savings: 17% with annual billing
- Contracts: Unlimited
- Features: Everything in Pro plus admin dashboard, analytics, audit logging, LLM switch
- Target: Law firms and legal departments
- Savings: 17% with annual billing
The admin dashboard provides comprehensive platform management for administrators.
URL: http://localhost:5173/admin
Access: Requires is_admin=true in users table
- Key Metrics: Total users, contracts, active subscriptions, MRR
- Growth Trends: Interactive line chart tracking users, contracts, and revenue over time
- Subscription Distribution: Pie chart showing tier breakdown (Basic/Pro/Enterprise)
- Revenue by Tier: MRR breakdown with growth rates
- Recent Activity: Latest contracts, signups, and payments
- User Listing: Paginated table with search and filtering
- Search: Find users by email or name
- Filter: By subscription tier (basic/pro/enterprise)
- Sort: By date or email (ascending/descending)
- User Details: Complete profile with contracts and payment history
- Subscription Editor: Manually adjust user subscription tiers
- User Impersonation: Generate 1-hour temporary access tokens for debugging
- Admin-Only Routes: All endpoints protected by admin middleware
- Audit Logging: Every admin action logged to database
- Confirmation Dialogs: Required for destructive actions
- Impersonation Limits: Cannot impersonate other admins, 1-hour token expiry
All require authentication and admin privileges:
GET /api/admin/metrics/overview- System-wide metrics with MRRGET /api/admin/metrics/recent-activity- Recent platform activityGET /api/admin/users- List all users with search/filterGET /api/admin/users/:userId- Detailed user profilePOST /api/admin/users/:userId/subscription- Update subscription tierPOST /api/admin/users/:userId/impersonate- Generate impersonation tokenGET /api/admin/audit-log- View admin action history
Run admin integration tests:
cd backend
node tests/admin-integration-test.jsAll deployment blockers have been resolved:
- Environment validation with Joi schema
- Centralized error handling with asyncHandler middleware
- Frontend security audit clean (0 vulnerabilities)
- Comprehensive API test suite passing
- Admin dashboard complete with revenue tracking
- 4 critical code quality bugs fixed
-
Backend Deployment (Railway, Render, or similar)
- Set all required environment variables
- Deploy from
admin-dashboardbranch - Configure database connection
- Set up Stripe webhooks
-
Frontend Deployment (Vercel, Netlify, or similar)
- Build with
npm run build - Deploy from
admin-dashboardbranch - Configure
VITE_API_BASE_URLenvironment variable
- Build with
-
Post-Deployment Verification
- Test health endpoint:
GET /api/health - Test authentication flow
- Verify payment processing
- Test contract generation
- Verify admin dashboard access
- Test health endpoint:
Required:
DATABASE_URL- PostgreSQL connection stringGOOGLE_AI_API_KEY- Google Gemini API keyJWT_SECRET- Secure random string (min 24 chars)
Optional (for payments):
STRIPE_SECRET_KEY- Stripe secret keySTRIPE_WEBHOOK_SECRET- Stripe webhook secretSTRIPE_PRO_MONTHLY_PRICE_ID- Pro monthly price IDSTRIPE_PRO_YEARLY_PRICE_ID- Pro yearly price IDSTRIPE_ENTERPRISE_MONTHLY_PRICE_ID- Enterprise monthly price IDSTRIPE_ENTERPRISE_YEARLY_PRICE_ID- Enterprise yearly price IDFRONTEND_URL- Frontend URL for redirects
# Backend
cd backend
npm start # Production mode
npm run dev # Development with nodemon
npm run setup-db # Initialize database
node setup-stripe.js # Setup Stripe products
# Frontend
cd frontend
npm run dev # Development server (port 5173)
npm run build # Production build
npm run preview # Preview production build
# Testing
cd backend
node tests/api-test.js # API integration tests
node tests/admin-integration-test.js # Admin dashboard tests- Email: test2@vibelegal.com
- Password: (set locally — do not commit credentials)
- Status: 28+ contracts (Pro tier)
Password Requirements:
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- At least one special character (!@#$%^&*...)
- User registration and authentication
- Contract generation through conversational AI
- Advanced customization controls
- Subscription upgrade flow
- Contract search and management
- Payment processing (test mode)
- Admin dashboard metrics and charts
- User impersonation (admin only)
- Mobile responsive design
- Goal: Find paying customers
- Focus: California employment contracts
- Metrics: User acquisition, conversion rates, MRR growth
- NDAs: Non-disclosure agreements
- Service Agreements: Independent contractor agreements
- Purchase Agreements: Basic commercial contracts
- New York: Employment law compliance
- Texas: State-specific regulations
- Florida: Regional legal requirements
- United Kingdom: UK employment law
- Canada: Provincial regulations
- European Union: GDPR compliance
- Australia: Fair Work Act compliance
- 50+ parameter extraction patterns
- Comprehensive legal analysis
- Strategic protection recommendations
- State management and resume functionality
- 60+ parameter mapping
- AI-powered clause selection
- Risk tolerance and legal stance controls
- Hybrid fallback system (enhanced + original clauses)
- Stripe webhook integration
- Automated tier enforcement
- Usage tracking and analytics
- Payment history and billing cycles
- Comprehensive metrics and analytics
- MRR tracking and revenue forecasting
- User and subscription management
- Complete audit trail
- Interactive data visualization with Recharts
- MRR tracking and revenue by tier
- Growth rate calculations (users, contracts, revenue)
- User impersonation for debugging
- Enhanced audit logging
- Fixed duplicate aiProvider declaration (ai-interpreter.js)
- Fixed duplicate conversationState key
- Consolidated duplicate /chat/recent route
- Eliminated inefficient internal API calls (replaced with direct function calls)
- Joi-based environment validation
- Centralized asyncHandler middleware
- Removed 133 lines of redundant try-catch blocks
- Fixed req.user.userId consistency
- Comprehensive API test suite
- JWT authentication with secure token handling
- bcryptjs password hashing (10 salt rounds)
- Stripe webhook signature verification
- Input validation and sanitization
- Rate limiting and abuse prevention
- Helmet security headers
- CORS configuration
- SQL injection protection (parameterized queries)
- Admin-only route protection
All generated contracts include appropriate legal disclaimers and should be reviewed by qualified attorneys before use. VibeLegal provides tools to assist in contract creation but does not provide legal advice.
- Documentation: Comprehensive setup and API documentation
- Code Comments: Detailed implementation explanations
- Error Handling: Clear error messages and logging
- Code Style: Follow existing patterns and conventions
- Testing: Run integration tests before submitting changes
- Documentation: Update docs for new features
- Git Workflow: Feature branches with detailed commit messages
VibeLegal - Production-ready AI-powered legal contract generation for the modern legal practice.
Current Branch: admin-dashboard
Status: Ready for production deployment
Last Updated: October 10, 2025
© 2025 VibeLegal. All rights reserved. This source code is made available for portfolio and reference purposes only. No license is granted to use, copy, modify, or distribute this code without explicit written permission.