Privacy-aware, local-first AI assistant with React frontend and FastAPI backend. Runs on consumer hardware with verifiable dual-model reasoning.
User (React UI)
↓
Frontend (React + TypeScript)
↓
Backend (FastAPI + Ollama)
↓
Local LLM (Qwen 2.5 7B / Mistral 7B)
persAssis/
├── backend/ # FastAPI backend with agent orchestration
│ ├── app/
│ │ ├── main.py
│ │ ├── config.py
│ │ ├── agents/
│ │ ├── graph/
│ │ └── llm/
│ ├── pyproject.toml
│ ├── setup.py
│ └── Readme.md
│
├── frontend/ # React + TypeScript frontend
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── services/
│ │ ├── hooks/
│ │ ├── types/
│ │ └── App.tsx
│ ├── public/
│ ├── package.json
│ ├── tsconfig.json
│ └── Readme.md
│
├── .github/ # Shared GitHub config
│ └── copilot-instructions.md (monorepo-level overview)
│
├── .gitignore # Root gitignore
└── Readme.md # This file
- Backend: Python 3.10+, Ollama, 16GB RAM, NVIDIA RTX 4050+ GPU (recommended)
- Frontend: Node.js 18+, npm or yarn
# Pull models (one-time)
ollama pull qwen2.5:7b-instruct
ollama pull mistral:7b-instruct
# Start Ollama server
ollama serve
# Runs on localhost:11434cd backend
pip install -e . # Install dependencies
python -m uvicorn app.main:app --reload
# Runs on http://localhost:8000
# API Docs: http://localhost:8000/docsIn another terminal:
cd frontend
npm install
npm start
# Runs on http://localhost:3000Open http://localhost:3000 in your browser.
- Local Reasoning: Qwen 2.5 7B for conversational, coding-aware responses
- Verification: Mistral 7B fact-checks all outputs (verifiability > blind generation)
- Correction Loop: Up to 1 iteration of self-correction based on feedback
- FastAPI: Single
/promptendpoint, latency tracking, health checks - WIP: RAG (retrieval-augmented generation), tool routing, hybrid mode
- React 18 + TypeScript: Type-safe component architecture
- Tailwind CSS: Responsive, modern UI
- Query History: Persists queries with responses and metadata
- Backend Health: Real-time status indicator
- Axios API Client: Strongly typed backend communication
cd backend
# Install in dev mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black app/
ruff check app/
# Type check
mypy app/See backend/Readme.md for detailed instructions.
cd frontend
# Install dependencies
npm install
# Run dev server with hot reload
npm start
# Build for production
npm run build
# Run tests
npm testSee frontend/Readme.md for detailed instructions.
Edit backend/app/config.py:
LOCAL_MODEL = "qwen2.5:7b-instruct" # Reasoning model
VERIFIER_MODEL = "mistral:7b-instruct" # Verification model
MAX_LOCAL_TOKENS = 2048
APP_MODE = Mode.LOCAL # or HYBRID (planned)Edit frontend/.env (optional):
REACT_APP_API_URL=http://localhost:8000
Send a query to the AI assistant.
Request:
{
"query": "Write a Python function to merge two sorted lists"
}Response:
{
"answer": "Here's a Python function...",
"mode": "local",
"latency_seconds": 2.34
}Health check endpoint.
Response:
{
"status": "ok",
"mode": "local"
}- Hardware: Models optimized for RTX 4050 (6GB VRAM). Use smaller models (3B-7B quantized) for 8GB.
- Sequential Execution: Agents run one at a time, not in parallel
- Single Correction Loop: Verifier feedback triggers max 1 re-reasoning attempt
- Local LLM Only: Cloud models planned but not yet implemented
Planned:
- RAG (Retrieval-Augmented Generation) over documents
- Tool routing (code search, job discovery, image generation)
- Hybrid routing (local vs. cloud per query type)
- Image generation (Stable Diffusion 1.5)
- Job discovery and ranking
Out of Scope (for now):
- Parallel multi-agent execution
- Video generation
- Voice assistant
- Real-time streaming
Verifiability over blind generation - Every answer is fact-checked by an independent model.
Modularity over monoliths - Agents, tools, and models are swappable.
Local execution by default - Privacy and latency > cloud dependency.
Explicit constraints - Hardware limits and token budgets are non-negotiable design decisions.
- Ollama connection fails: Ensure
ollama serveis running onlocalhost:11434 - Model not found: Run
ollama pull <model>first - High latency: Monitor GPU usage; consider smaller models if VRAM is exhausted
- Backend unreachable: Verify backend is running on
localhost:8000 - Slow responses: Check network latency and backend GPU utilization
- TypeScript errors: Ensure all types are properly imported and defined
- Backend: PEP 8, type hints via Pydantic, explicit error handling
- Frontend: React.FC type annotations, Tailwind utilities, TypeScript strict mode
- Backend: backend/.github/copilot-instructions.md
- Frontend: frontend/.github/copilot-instructions.md
These documents guide AI coding agents on architecture, patterns, and best practices specific to each layer.
- Create a feature branch
- Make changes in
backend/and/orfrontend/as needed - Test thoroughly (see Development section)
- Submit a pull request
MIT
For issues or questions:
- Check the backend Readme or frontend Readme
- Review copilot instructions for architecture details
- Check existing GitHub issues
Built with: React, FastAPI, Ollama, Tailwind CSS, TypeScript
High-Level Flow
User Input
↓
Intent Classifier
↓
Primary Reasoner (Local LLM)
↓
Verifier Agent (Independent LLM)
↓
Pass → Final Response
Fail → Correction Loop → Reasoner
Tool Routing (Optional)
Reasoner
↓
Tool Router
├── Job Scraper
├── Code Analyzer
└── Image Generator
Key Design Rule
A model that generates an answer must never be the same model that verifies it.
local-ai-assistant/
│
├── README.md
├── pyproject.toml
├── .env.example
│
├── app/
│ ├── main.py # FastAPI entrypoint
│ ├── config.py # Global configuration
│ │
│ ├── agents/
│ │ ├── base.py
│ │ ├── reasoner.py
│ │ ├── verifier.py
│ │ └── tool_router.py
│ │
│ ├── graph/
│ │ ├── agent_graph.py
│ │ └── state.py
│ │
│ ├── llm/
│ │ ├── local_llm.py
│ │ ├── cloud_llm.py
│ │ └── hybrid_router.py
│ │
│ ├── tools/
│ │ ├── jobs.py
│ │ ├── code.py
│ │ └── images.py
│ │
│ ├── memory/
│ │ ├── vector_store.py
│ │ └── embeddings.py
│ │
│ └── ui/
│ └── api.py
│
├── data/
│ ├── documents/ # PDFs, notes, docs
│ ├── vectors/ # Embedding storage
│ └── job_cache/ # Scraped job data
│
└── scripts/
├── ingest_docs.py
└── scrape_jobs.py
Language Models (Local) Primary Reasoner
- Qwen2.5 7B Instruct (Q4_K_M)
- DeepSeek-Coder 6.7B (Q4)
- Verifier
- Mistral 7B Instruct
- Phi-3 Medium (CPU-friendly)
Embeddings
- bge-small-en
- e5-small
Image Generation
- Stable Diffusion 1.5
- ComfyUI or AUTOMATIC1111 (external process)
6.1 Python Environment python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -U pip
6.2 Install Dependencies pip install fastapi uvicorn pydantic python-dotenv pip install sentence-transformers qdrant-client
(LLM backends such as llama.cpp or ollama are run separately.)
.env.example APP_MODE=HYBRID
OPENAI_API_KEY= ANTHROPIC_API_KEY=
CLOUD_TOKEN_BUDGET=20000
config.py (Excerpt) from enum import Enum
class Mode(str, Enum): LOCAL = "local" CLOUD = "cloud" HYBRID = "hybrid"
APP_MODE = Mode.HYBRID
LOCAL_MODEL = "qwen2.5-7b-instruct-q4" VERIFIER_MODEL = "mistral-7b-instruct"
MAX_LOCAL_TOKENS = 2048 CLOUD_TOKEN_BUDGET = 20_000
Run your LLM via ollama or llama.cpp before starting the API.
Example (Ollama):
ollama run qwen2.5:7b-instruct
uvicorn app.main:app --reload
Server will start at:
API Docs (Swagger): http://localhost:8000/docs
POST /ask { "query": "Review this React hook for performance issues" }
Response Flow
Intent classification
Local reasoning
Verification
Final response (or correction loop)
Routing Rules (Default) Task Type Execution Coding Local Reasoning Local Verification Local Large context (>8k tokens) Cloud Video Cloud Image Local
Cloud usage:
Is explicit
Is rate-limited
Never triggers silently
Video generation locally
Voice interfaces
Autonomous agents
Parallel agent execution
These features add complexity without proportional value on limited hardware.
The repository is designed so you can:
Add new agents without touching existing ones
Swap LLM backends (local ↔ cloud)
Add new tools (video, voice, search)
Upgrade hardware without architectural changes
Your advantage is architecture and discipline, not model size.
This project is intentionally conservative, debuggable, and extensible.