This repository contains the full stack for the CMK Asistanı, a RAG-powered Q&A application for Turkish lawyers specializing in CMK law. It includes a Python/FastAPI backend and a React Native mobile application.
The backend is a high-performance API built with Python and FastAPI that serves the RAG model and provides a secure endpoint for audio transcription.
For setup and usage instructions, see the sections below.
The backend is configured for easy deployment on Render. For a complete step-by-step guide, please see:
Technology Stack:
- Backend: Python, FastAPI
- RAG Framework: LangChain
- LLM: Configurable via OpenRouter (e.g., Google Gemini, OpenAI GPT-4)
- Vector Store: ChromaDB (local)
- PDF Parsing: PyPDF
-
Clone the repository:
git clone <your-repo-url> cd <your-repo-name>
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Copy the example environment file:
cp .env.example .env
- Edit the
.envfile and add your API keys:OPENROUTER_API_KEY: Your OpenRouter API key for the RAG model.OPENAI_API_KEY: Your OpenAI API key for the secure audio transcription endpoint.- Optionally change the
MODEL_NAME.
- Copy the example environment file:
-
Add Knowledge Base Documents:
- Place your PDF files (
.pdf) inside thedata/directory.
- Place your PDF files (
There are two main steps to run the backend application.
You must first process your PDF documents and store them in the vector database. This only needs to be done once, or whenever your source documents change.
python scripts/ingest.pyThis will create a chroma_db directory containing your vector store.
Once the data is ingested, you can start the web server.
uvicorn main:app --reloadThe API will be available at http://127.0.0.1:8000. You can access the auto-generated documentation at http://127.0.0.1:8000/docs.
Send a POST request to the /api/chat endpoint with a JSON body like this:
{
"question": "17 yaşındaki bir sanık için müdafi zorunlu mu?"
}The API will return a response with the answer and the sources it used.
A cross-platform mobile application built with React Native (Expo) that provides a voice-first chat interface to interact with the backend.
For setup and usage instructions, see the mobile app's README.