Skip to content

Heman10x-NGU/PhronAi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎀 PHRONAI: Voice-Powered AI Diagramming

Transform voice commands into professional diagrams in real-time with zero-hallucination AI.

Python 3.12 Django React License: MIT


🎯 What It Does

Speak naturally, get professional diagrams instantly. PHRONAI is a voice-controlled AI agent that:

  • Listens to your voice commands
  • Understands complex architectural descriptions
  • Renders beautiful system diagrams in real-time
  • Never hallucinates thanks to Pydantic schema validation

Example Voice Commands

You Say PHRONAI Does
"Add a database connected to the API server" Creates database node + arrow
"Create a microservices architecture with user service, auth, and gateway" Full 3-node system with connections
"Change all nodes to green" Updates all node colors
"Delete the cache and connect database directly to server" Removes node, rewires edges

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           PHRONAI FLOW                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                     β”‚
β”‚   🎀 Voice Input          🧠 AI Processing          πŸ“Š Diagram      β”‚
β”‚   ─────────────          ─────────────────         ──────────       β”‚
β”‚                                                                     β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚   β”‚ Browser │───▢│   Deepgram    │───▢│   Groq LLaMA 3.3     β”‚     β”‚
β”‚   β”‚ (Audio) β”‚    β”‚   Nova-2 STT  β”‚    β”‚   + Instructor       β”‚     β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚   + Pydantic         β”‚     β”‚
β”‚        β–²                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚        β”‚                                         β”‚                  β”‚
β”‚        β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚                  β”‚
β”‚        └─────────│   tldraw +      β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β”‚                  β”‚   ELK.js Layout β”‚   Validated JSON Actions       β”‚
β”‚                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                β”‚
β”‚                                                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Zero-Hallucination Guarantee

Unlike standard LLM integrations, PHRONAI never produces invalid output:

  1. Pydantic Schemas - Every LLM response is validated against strict schemas
  2. Instructor Library - Automatic retry with error context if validation fails
  3. Self-Correction Loop - LLM sees its mistakes and fixes them

⚑ Tech Stack

Layer Technology Why
Backend Django 5.2 + Channels Async WebSocket handling
LLM Groq (LLaMA 3.3 70B) Fast inference, free tier
Validation Instructor + Pydantic Zero hallucination
Speech-to-Text Deepgram Nova-2 95%+ accuracy on tech terms
Frontend React 18 + tldraw Infinite canvas rendering
Layout ELK.js Automatic graph layout
Auth Supabase Magic links, OAuth

πŸš€ Quick Start

Prerequisites

1. Backend Setup

cd phronai/server

# Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # Mac/Linux

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your API keys

# Run server
python manage.py runserver 8000

2. Frontend Setup

cd phronai/client

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Add Supabase keys

# Run development server
npm run dev

3. Open in Browser

Navigate to http://localhost:5173, sign in, and start speaking! 🎀


πŸ“ Project Structure

phronai/
β”œβ”€β”€ server/                     # Django Backend
β”‚   β”œβ”€β”€ agent/
β”‚   β”‚   β”œβ”€β”€ consumers.py        # WebSocket handler
β”‚   β”‚   β”œβ”€β”€ schemas.py          # Pydantic validation (23 colors!)
β”‚   β”‚   β”œβ”€β”€ reasoning.py        # LLM integration with Instructor
β”‚   β”‚   └── state.py            # Thread-safe session management
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── rate_limit.py       # 10 req/min per user
β”‚   β”œβ”€β”€ integrations/
β”‚   β”‚   └── deepgram.py         # STT client with retry
β”‚   β”œβ”€β”€ prompts/
β”‚   β”‚   └── sketch_protocol.md  # System prompt
β”‚   └── Dockerfile              # Production build
β”‚
β”œβ”€β”€ client/                     # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/AgentCanvas.tsx    # Main canvas with voice UI
β”‚   β”‚   β”œβ”€β”€ lib/graphLayout.ts       # ELK.js integration
β”‚   β”‚   β”œβ”€β”€ lib/tldrawShapes.ts      # Custom node rendering
β”‚   β”‚   └── lib/DiagramNodeShape.tsx # Semantic node types
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ docker-compose.yml          # Full stack deployment
β”œβ”€β”€ docker-compose.dev.yml      # Local dev (PostgreSQL + Redis)
└── railway.toml                # Railway deployment config

πŸ”’ Security Features

  • Rate Limiting: 10 requests/minute per user (sliding window)
  • JWT Auth: Supabase tokens validated on WebSocket connect
  • Input Validation: All LLM outputs schema-validated before execution
  • CORS Protection: Configured for production domains

πŸ“Š Performance

Metric Value
End-to-end latency ~4 seconds
Transcription accuracy 95%+
LLM schema compliance 100%
Concurrent sessions Thread-safe with asyncio locks

Environment Variables

# Required
DEEPGRAM_API_KEY=your_key
GROQ_API_KEY=your_key
DJANGO_SECRET_KEY=generate_a_secure_key
ALLOWED_HOSTS=your-domain.railway.app

# Optional (auto-provided by Railway)
DATABASE_URL=postgres://...
REDIS_URL=redis://...

πŸ“ API Reference

WebSocket: ws://host/ws/agent/?token=<jwt>

Direction Type Payload
Client β†’ Server Binary Audio (WebM/Opus)
Server β†’ Client transcript { text: "..." }
Server β†’ Client actions { actions: [...] }
Client β†’ Server canvas_sync { graph: {...}, snapshot: "..." }

HTTP Endpoints

Endpoint Method Purpose
/health/ GET Health check
/health/ready/ GET Kubernetes readiness

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing)
  5. Open a Pull Request

οΏ½ Author

Hemant – Full Stack Developer

LinkedIn

πŸ“© Interested in this project or want to collaborate? Contact me on LinkedIn


πŸ“„ License

MIT License - See LICENSE for details.

About

AI SPEECH TO WHITEBOARD 🎀 Voice-powered AI diagramming platform. Speak naturally, get professional system diagrams instantly. Built with Django, React, Groq LLaMA 3.3, and Deepgram.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors