AcademicRag is a Dockerized Retrieval-Augmented Generation (RAG) system.
It combines:
- A custom LLM served by Ollama (built from a Modelfile)
- Chroma for document embeddings
- MongoDB for logging queries
- A Flask REST API for interaction
- Query the LLM with context from your documents
- Automatic citation extraction (
[Document: ..., Section: ...]) - Persistent query logs with timestamp filters
- Fully containerized with Docker Compose
slava project/
├─ app/ # Flask application
│ ├─ api/ # REST endpoints (e.g. /logs)
│ └─ rag/ # LLM output parser
├─ modelfile/
│ └─ Modelfile # Ollama model definition
├─ Ollama.Dockerfile # Builds custom Ollama model image
├─ docker-compose.yml # Multi-container setup
├─ Dockerfile # Flask service build
├─ requirements.txt # Python deps
└─ .gitignore # Ignored files/folders
- Docker & Docker Compose
- Docker Hub account (optional, for pushing images)
-
Clone the repo
git clone https://github.com/<your-username>/AcademicRag.git cd "slava project"
-
Configure environment
Copy.env.exampleto.envand set:MONGO_DB_NAME=academic_rag LOGS_COLLECTION=query_logs -
Build & run containers
This command also builds the Ollama image usingOllama.Dockerfileto bake in your custom model:docker-compose up --build -d
-
Access services
- Flask API: http://localhost:5000
- Swagger UI (interactive API docs): http://localhost:5000/apidocs
- Mongo-Express: http://localhost:8081
- Ollama LLM: use
ollamaCLI on host or container port11434 - Chroma HTTP API: http://localhost:8000
-
Interactive docs
Browse and test endpoints in Swagger UI: -
POST
/ask{ "query": "Your question here" }Response:
{ "answer": "Generated answer…", "citations": ["[Document: file.pdf, Section: …]"] } -
GET
/logs?start_time=2025-07-01T00:00:00&end_time=2025-07-15T23:59:59
Returns filtered query logs.
- To clear MongoDB data, stop services and delete the volume folder:
docker-compose down Remove-Item -Recurse -Force mongo_data docker-compose up -d
- Similarly remove
chroma_data/orollama_data/to reset embeddings or models.
- Edit
modelfile/Modelfileas needed:FROM llama2 PARAMETER temperature 0.25 - Rebuild and load your custom model image using Docker Compose:
This uses
docker-compose up -d --build ollama
Ollama.Dockerfileto bake yourmodelfile/Modelfileinto theguyyagil/ollama-custom:latestimage.
- Build all images:
docker-compose build
- Push to Docker Hub:
docker login docker push guyyagil/flask_app:latest docker push guyyagil/ollama-custom:latest
- Fork the repo
- Create a feature branch
- Submit a pull request
This project is licensed under the MIT