Back to all systems

Completed and defended at the final viva

Smart Query Routing

Reads incoming web and email queries, sends each one to the right department, and drafts a reply for staff to send.

Queries are classified, routed and drafted without anyone sorting the inbox by hand.

Where
Final year project, Virtual University of Pakistan
My role
Sole developer, AI and full stack
When
2026
Stack
  • Python
  • FastAPI
  • React
  • Tailwind CSS
  • Supabase (PostgreSQL)
  • LangChain
  • Google Gemini
  • Anthropic Claude
  • n8n
  • Google OAuth2
  • Chart.js

The problem

Questions from students and the public arrive through web forms and email. Someone has to read each one, decide which department owns it, and write a reply, and urgent queries can sit unanswered.

How it works

6 steps, from input to result. They light up as you scroll.

  1. A query arrives

    From the web form, or from the Gmail inbox through an n8n workflow.

  2. Intent is classified

    Google Gemini, orchestrated with LangChain, reads the query and decides what it is about.

  3. It is routed

    The query is assigned to the department that owns it.

  4. A reply is drafted

    Gemini drafts a contextual reply, with Anthropic Claude as a fallback and keyword matching as a last resort, so routing keeps working when the AI services are down.

  5. Staff review and send

    Staff edit the draft in the dashboard and send it.

  6. Nothing is forgotten

    n8n escalates any query left open for 24 hours and sends a daily analytics summary.

What I built

  • A FastAPI backend on Supabase with passwordless Google OAuth2 sign-in and role-based access for 5 user roles.
  • A normalized (3NF) database with row-level security and an append-only audit log of every change.
  • A React and Tailwind CSS dashboard with status timelines, editable AI drafts and Chart.js analytics.
  • Self-hosted n8n workflows for Gmail ingestion, SLA escalation and daily summaries.

Results

  • Every query is classified and routed automatically, with a drafted reply waiting for staff.
  • Routing keeps working even when both AI providers are unavailable.
  • Completed as a solo project and defended at the final viva.