Back to Build Log
Building6 min readNovember 14, 2025

How I Built an AI Assistant for Italian Driving Theory

What problem I discovered, how I engineered the explanation vector loop, and lessons from 5,000+ quizzes.

#AI Assistant#Flutter#Next.js#GPT-4o#Case Study

The Problem Nobody Talked About

If you ask anyone who took the Italian driving licence exam (Patente B) in recent years, they will tell you the same thing: *it is not a driving test—it is an Italian grammar trap test*.

The official quiz bank contains thousands of ministerial questions specifically phrased with archaic legal terminology, tricky double negatives, and subtle word swaps (like confusing *carreggiata* with *corsia*).

Existing quiz apps give you a green checkmark or a red cross. But when you get a question wrong at 11 PM while studying in your room, **no app tells you WHY**.

---

The Engineering Approach

I wanted to build an assistant that acts like a private instructor sitting right next to you:

1. **High-Density Vectorization**: We parsed and structured the official Italian *Codice della Strada* articles and ministerial circulars into dense vector embeddings. 2. **Trap Detection Heuristics**: Before calling the LLM, a fast rule-engine flags grammatical traps like *"sempre"*, *"solo se"*, *"in ogni caso"*, and *"non è vietato"*. 3. **Structured Explanation Synthesis**: The prompt instructs the LLM to deliver a 2-sentence legal reason in plain Italian, followed by an immediate multilingual bridge for non-native test takers.

Official Question ↓ Trap Detector (Rule Engine) ↓ Law Vector Retrieval (PostgreSQL pgvector) ↓ AI Reasoning (GPT-4o & Gemini Flash) ↓ Plain-Language Explanation & Visual Clarification

---

What Worked and What Didn't

**What failed initially**: Relying solely on raw prompt engineering without grounding. Early prototypes occasionally hallucinated explanations for rare tramway rules.

**What fixed it**: Strict retrieval grounding where the model is legally bound to quote the relevant article paragraph number.

---

The Takeaway for AI Builders

Don't build generic AI chatbots that try to do everything. Build **hyper-specialized assistants** that solve a single, painful, well-defined problem 10x better than existing software.

Written byObaidul

Founder & Product Builder @ ObaidulLabs

About the author →