Fairly was inspired by the recognition that over 2 million domestic workers in the United States face significant barriers to understanding their legal rights complex legal language scattered across federal, state, and local laws, language barriers, and fear of retaliation for asking questions. We built a solution using Retrieval-Augmented Generation (RAG) technology, processing 45 legal PDF documents around 2000 semantically-chunked data points with automatic jurisdiction and topic detection. The system uses a 3-layer architecture: query processing with jurisdiction detection, vector similarity search in Pinecone, and response generation with the help of the Google Gemini. Throughout development, we learned the importance of semantic chunking (optimal 300-800 character sizes), robust PDF processing for various document formats, and building production-ready error handling. Key challenges included handling corrupted and scanned PDFs, fine-tuning RAG parameters for accuracy, and integrating multiple cloud services (MongoDB, Pinecone, Gemini) with proper async handling. The result is a full-stack application with a Next.js frontend and FastAPI backend that provides instant, accurate answers to legal questions in plain language, helping workers understand their rights without needing legal expertise.
Built With
- and-mongodb-atlas-api.-the-application-follows-rest-api-architecture
- and-react-context-api-for-state-management
- and-shadcn/ui-components-for-the-ui.-*backend*-is-built-with-fastapi-(python-3.8+)
- gcp
- gemini
- integrated-through-a-custom-3-layer-rag-architecture.-*data-processing*-uses-python-with-pdfplumber-for-pdf-extraction-and-custom-semantic-chunking-algorithms.-*apis-&-services*-include-google-gemini-api
- messages
- metadata)-and-pinecone-as-the-vector-database-for-similarity-search.-*ai/ml*-leverages-google-gemini-2.0-flash-for-text-generation-and-gemini-embedding-exp-03-07-for-creating-3072-dimensional-embeddings
- mongodb
- nextjs
- pinecone
- pinecone-api
- production-ready-technology-stack:-*frontend*-uses-next.js-14-with-react-18
- python
- service-layer-patterns
- tailwind-css-for-styling
- typescript-for-type-safety
- using-pydantic-for-data-validation-and-uvicorn-as-the-asgi-server.-*data-storage*-includes-mongodb-atlas-for-document-storage-(chats
Log in or sign up for Devpost to join the conversation.