Legal research needs an inspectable trail
This Italian legal-research application was built around one constraint: the answer could not be the end of the research process. A user needed to search relevant material, ask a question in ordinary language, and inspect the sources behind the response.
That made it a product-design problem as much as a language-model problem. A chat box can make legal information feel authoritative without showing where it came from. I made retrieval and citation visible in the interaction.
Search first, then ask follow-up questions
The React and TypeScript interface supported two closely related workflows. Direct search looked across both source libraries and returned relevant articles for someone who wanted to read first. The chat experience let a user turn that research into a question and continue the thread with follow-ups. Conversation history kept that work available rather than treating every question as an isolated request.
Both paths drew from Italian legal content from La Legge per Tutti and Brocardi.it. The application kept the sources distinct, so results could include a title, link, and passage.
Keeping sources in the chat
The chat treated source lookup as part of answering. A first GPT-4 pass could decide whether to call a legal-search tool and, when it did, whether the question belonged in La Legge per Tutti or Brocardi.it. The selected material then fed a second answer-generation pass with numbered citations, keeping the response connected to the article or legal reference behind it.
I used OpenAI query embeddings with Zilliz/Milvus to find relevant source chunks. Related chunks from the same article were brought back together before they were shown or used as context. Legal points often span adjacent passages, and a lone sentence can mislead. Direct search queried both libraries, while chat used the tool choice to focus a question’s research path.
The chat API sent a separate search state before streaming answer text, so the interface could distinguish “looking for sources” from “writing an answer.” Once complete, the conversation stored the message and its cited references together. The source trail stayed with the work instead of disappearing with a transient result.
Building the complete experience
The product joined the React interface to FastAPI services for search, streamed chat, conversations, feedback, and onboarding. Auth0 JWT verification identified active users. MongoDB persisted users, message threads, citations, saved searches, and feedback. Docker packaged the service for repeatable deployment.
Building that end-to-end flow changed how I thought about RAG. Retrieval quality matters, as do the details around it: whether a citation is easy to open, whether a conversation preserves its sources, and whether the product leaves room for a user to check a fluent answer.
Conclusion
The AI Legal Research Platform combined source search, cited chat, and persistent conversations in one application. It was an end-to-end RAG product in which retrieved legal content remained visible and inspectable throughout the user experience.