Skip to content
Arjit Kulkarni
04Backend & Retrieval

NyayMitra

Semantic clause retrieval over a contract corpus
Role
Backend — schema, retrieval path, API surface
Context
Project
Stack
PythonFastAPIPostgreSQLVector searchLoad testing
Source
Private
01  The problem

An authenticated FastAPI service that ingests contracts, stores structured metadata in PostgreSQL, and retrieves clauses by meaning across a 200+ document corpus.

Finding the right clause in a contract is a meaning problem, not a keyword problem. Serving that as an API means designing a schema and a retrieval path that stay fast when the corpus grows and several people query it at once.
02  Approach
  1. 01

    Built authenticated REST APIs over Python, FastAPI and PostgreSQL, designing the schema and the retrieval path together rather than bolting search onto an existing model.

  2. 02

    Implemented document ingestion with structured metadata storage, so every retrieved clause carries the context needed to act on it.

  3. 03

    Added semantic retrieval via vector search for clause lookup across the corpus, backed by indexed database queries.

  4. 04

    Load-tested the read path end to end instead of trusting single-request timings.

03  Outcome
  • Clause retrieval across a 200+ document corpus.

  • Sustained 50+ concurrent users during load testing.

  • p95 latency held below 2 seconds across the combined PostgreSQL and vector-search read path.

Documents in corpus
0+Documents in corpus
Concurrent users sustained
0+Concurrent users sustained
p95 read-path latency
<0sp95 read-path latency

Concepts applied

  • Schema design
  • Semantic retrieval
  • API authentication
  • Indexing
  • Load testing