Inspiration

Most AI assistants can answer questions, but when the answer matters, a more important question is: "Where did that answer come from?"

We wanted to build a Q&A system that answers questions from a user's own documents while making the evidence behind every answer visible. Instead of treating the LLM as the source of truth, our project uses document retrieval first and then asks Gemini to generate an answer grounded in the retrieved content.

The goal was simple: ask a question, get an answer, and immediately see the source that supports it.

What We Built

We built a document-grounded, citation-aware Q&A engine.

Users can upload plain-text documents and ask questions about them. The system:

  1. Ingests and splits documents into searchable chunks.
  2. Uses a hand-rolled BM25 retrieval algorithm to find the most relevant chunks.
  3. Sends the retrieved context to Gemini for answer generation.
  4. Verifies the generated answer against the retrieved document content.
  5. Returns the answer together with its supporting citations and retrieved chunk IDs.
  6. Explicitly indicates when an answer cannot be found in the provided documents.

This makes the system more transparent than a conventional chatbot because the user can trace an answer back to the exact document content that supports it.

How We Built It

The backend was developed with Spring Boot and Java. We implemented document processing and BM25-based retrieval without relying on an external vector database or embedding pipeline.

For generation and verification, we integrated the Gemini API through the backend. The frontend communicates only with our REST API; API credentials and LLM communication remain server-side.

The application exposes endpoints for document upload, document retrieval, and question answering. The React frontend provides the user-facing workflow for uploading documents, selecting documents, asking questions, and inspecting citations.

A key design decision was to keep the architecture lightweight and understandable. Rather than adding unnecessary frameworks or infrastructure, we focused on making the core retrieval → generation → verification pipeline reliable.

What We Learned

One of our biggest lessons was that building an AI application is not simply about connecting an LLM to a prompt.

The quality of the final system depends heavily on:

  • Retrieving the right context before generation.
  • Preventing unsupported information from being presented as fact.
  • Making citations meaningful and traceable.
  • Handling API failures and model availability.
  • Keeping secrets such as API keys out of the frontend and source code.
  • Testing both questions that can be answered and questions that cannot be answered from the documents.

We also learned how important it is to design AI systems around evidence and verification, rather than assuming that a fluent LLM response is automatically correct.

Challenges

One of our biggest challenges was migrating the LLM integration during development. We initially worked with a Featherless/OpenAI-compatible approach before moving to Gemini. This required adapting the HTTP integration, configuration, model handling, and response parsing while keeping the existing QA pipeline intact.

We also encountered API-key configuration issues and model availability errors. Debugging these issues taught us the importance of separating application configuration from source code and validating the actual capabilities available to an API key.

Another challenge was designing the grounding and citation flow. It wasn't enough to generate an answer—we needed to connect the answer back to retrieved document chunks and distinguish supported information from unsupported claims.

Why It Matters

We believe useful AI should not only be intelligent, but also traceable.

Our project explores a simple principle:

If an AI gives you an answer, you should be able to see the evidence behind it.

By combining traditional information retrieval, LLM generation, and citation verification, we created a lightweight foundation for more trustworthy document-based AI assistants.

Built With

Share this project:

Updates

Submission history