A RAG-powered tax guidance assistant for small businesses in Tanzania, accessible via Telegram. Built entirely with local, open-source tools zero API costs, zero cloud dependency.
# TRA Assist
A RAG-powered tax guidance assistant for small businesses in Tanzania, accessible via Telegram. Built entirely with local, open-source tools zero API costs, zero cloud dependency.
---
## What It Does
TRA Assist answers tax questions by retrieving relevant information from official TRA (Tanzania Revenue Authority) documents and generating structured, plain-language responses using a local LLM. Every answer includes:
- A direct answer
- A plain-language explanation
- Step-by-step action items
- A confidence indicator (HIGH / MEDIUM / LOW)
- A mandatory disclaimer directing users to verify with TRA
---
## Tech Stack
| Component | Technology |
|---|---|
| Backend | Spring Boot 3.2.5, Java 21 |
| RAG Framework | LangChain4j 0.31.0 |
| Embedding Model | nomic-embed-text (via Ollama) |
| LLM | Mistral 7B (via Ollama) |
| Vector DB | PostgreSQL 16 + pgvector |
| PDF Extraction | Apache PDFBox 3.0.2 |
| Messaging | Telegram Bot API |
| Containerization | Docker + docker-compose |
---
## Prerequisites
- Java 21
- Maven
- Docker + docker-compose
- Ollama with `nomic-embed-text` and `mistral` pulled
- A Telegram bot token from @BotFather
---
## Setup
**1. Clone the repository**
```bash
git clone
github.com
cd tra-assist
```
**2. Start PostgreSQL with pgvector**
```bash
docker-compose up -d
```
**3. Add the vector column (first run only)**
```bash
docker exec -it tra-postgres psql -U trauser -d traassist \
-c "ALTER TABLE document_chunks ADD COLUMN IF NOT EXISTS embedding vector(768);"
```
**4. Add TRA documents**
Drop TRA PDF files into `src/main/resources/documents/`. The ingestion pipeline runs automatically on startup.
**5. Start Ollama**
```bash
ollama serve
```
**6. Set environment variables**
```bash
export BOT_TOKEN=your_telegram_bot_token
export BOT_USERNAME=your_bot_username
```
**7. Run the application**
```bash
mvn spring-boot:run
```
**8. Verify everything is running**
```bash
curl
local …