An AI-powered mock trial simulation application for lawyers, law students, and individuals preparing to represent themselves in court.
- AI-Powered Agents: Simulates Judge, Prosecutor, and Defense Attorney roles using advanced AI
- Real-Time Voice Interface: Continuous speech-to-text and text-to-speech for natural conversation
- Legal Context Integration: Integrates with OpenJustice API for jurisdiction-specific legal knowledge
- Visual Agent Representation: Animated circular avatars showing which agent is speaking
- Transcript Recording: Real-time transcript of all trial proceedings
- Document Upload: Support for PDF and image document analysis
- Python 3.10+
- FastAPI (API framework)
- PyAgentSpec 26.1.0 (Oracle Agent Spec)
- Deepgram SDK (Speech services)
- OpenJustice API (Legal data)
- WebSocket support for real-time communication
- Next.js 14 (App Router)
- TypeScript
- Tailwind CSS
- shadcn/ui (Component library)
- Framer Motion (Animations)
- Web Audio API
- Python 3.10 or higher
- Node.js 18 or higher
- Deepgram API key
- OpenJustice API key (optional)
- Navigate to the backend directory:
cd backend- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile from the example:
cp .env.example .env- Edit
.envand add your API keys:
DEEPGRAM_API_KEY=your_deepgram_api_key_here
OPENJUSTICE_API_KEY=your_openjustice_api_key_here
- Run the backend server:
python main.pyThe backend will start at http://localhost:8000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Create a
.env.localfile:
cp .env.local.example .env.local- Run the development server:
npm run devThe frontend will start at http://localhost:3000
-
Configuration Phase:
- Select roles to simulate (Judge, Prosecutor, Defense)
- Choose jurisdiction and legal areas
- Provide case description and upload supporting documents
-
Trial Phase:
- Click the microphone button to unmute
- Speak naturally to interact with AI agents
- Agents will respond in real-time with voice
- View the transcript in the right panel
-
End Trial:
- Click "End Trial" button when finished
- Review the transcript
mockr/
├── backend/
│ ├── main.py # FastAPI application entry
│ ├── config.py # Configuration and environment variables
│ ├── models/ # Pydantic data models
│ ├── services/ # Business logic services
│ │ ├── openjustice.py # OpenJustice API integration
│ │ ├── agent_manager.py # Agent management and responses
│ │ └── speech_service.py # Deepgram integration
│ ├── routers/ # API route handlers
│ │ ├── configuration.py # Configuration endpoints
│ │ └── trial.py # Trial management endpoints
│ └── websockets/ # WebSocket handlers
│ └── trial_session.py # Real-time trial communication
│
├── frontend/
│ ├── app/ # Next.js app directory
│ │ ├── page.tsx # Configuration page
│ │ └── trial/[sessionId]/ # Trial simulation page
│ ├── components/ # React components
│ │ ├── ui/ # shadcn/ui components
│ │ ├── configuration/ # Configuration step components
│ │ └── trial/ # Trial interface components
│ ├── lib/ # Utility functions
│ │ ├── audio.ts # Audio recording and playback
│ │ ├── websocket.ts # WebSocket client
│ │ └── utils.ts # General utilities
│ └── types/ # TypeScript type definitions
│
└── README.md
GET /api/configuration/jurisdictions- Get available jurisdictionsGET /api/configuration/legal-areas/{jurisdiction}- Get legal areas for jurisdictionGET /api/configuration/articles- Search legal articlesPOST /api/trial/create- Create a new trial sessionGET /api/trial/{session_id}- Get trial session detailsPOST /api/trial/{session_id}/context- Upload documents to trialDELETE /api/trial/{session_id}- End a trial session
ws://localhost:8000/ws/trial/{session_id}- Real-time trial communication
- Maintains courtroom order
- Makes legal rulings
- Ensures fair proceedings
- Neutral and authoritative
- Represents the state
- Presents evidence for conviction
- Cross-examines witnesses
- Assertive and methodical
- Represents the defendant
- Challenges prosecution's case
- Protects client's rights
- Strategic and protective
To add new agent behaviors:
- Edit
backend/services/agent_manager.py - Modify agent prompts or response logic
- Test with different case scenarios
To customize the UI:
- Edit components in
frontend/components/ - Modify styles in Tailwind classes
- Adjust animations in Framer Motion
- Check browser permissions for microphone access
- Ensure HTTPS or localhost for getUserMedia API
- Try a different browser (Chrome/Edge recommended)
- Ensure backend is running on port 8000
- Check CORS settings in backend
- Verify
.env.localhas correct WebSocket URL
- Check Deepgram API key is valid
- Ensure proper error handling in browser console
- Verify agent_manager is creating agents correctly
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
- Oracle Agent Spec for agent orchestration
- Deepgram for speech services
- OpenJustice for legal data
- shadcn/ui for beautiful components