๐Ÿ‡บ๐Ÿ‡ธ English | ๐Ÿ‡ฎ๐Ÿ‡ณ เคนเคฟเค‚เคฆเฅ€ | ๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž | ๐Ÿ‡จ๐Ÿ‡ณ ็ฎ€ไฝ“ไธญๆ–‡ | ๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol | ๐Ÿ‡ง๐Ÿ‡ท Portuguรชs (Brasil) | ๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด | ๐Ÿ‡ฉ๐Ÿ‡ช Deutsch | ๐Ÿ‡ซ๐Ÿ‡ท Franรงais

Note: ์ด ๋ฌธ์„œ๋Š” ๋ฒˆ์—ญ๋ณธ์ž…๋‹ˆ๋‹ค. ์˜์–ด README.md๊ฐ€ ๊ธฐ์ค€ ๋ฌธ์„œ์ž…๋‹ˆ๋‹ค.

RAG Container Template

License OS Python CI Python Lint CodeQL Advanced pages-build-deployment

Python Pytest FastAPI React Native TypeScript Jest Expo

"UI"

์ด ์ €์žฅ์†Œ๋Š” ๋กœ์ปฌ Retrieval-Augmented Generation (RAG) ์‹œ์Šคํ…œ์„ ๊ตฌ์ถ•ํ•˜๊ธฐ ์œ„ํ•œ ํ’€์Šคํƒ ์ƒŒ๋“œ๋ฐ•์Šค์ž…๋‹ˆ๋‹ค.
๋ฐฑ์—”๋“œ๋Š” ์ธ์ฆ๊ณผ RAG API๋ฅผ ์ œ๊ณตํ•˜๋Š” FastAPI ์„œ๋น„์Šค์ด๋ฉฐ, ์˜๊ตฌ ๋ฒกํ„ฐ ์ €์žฅ์†Œ๋กœ ChromaDB๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์ž„๋ฒ ๋”ฉ๊ณผ ์ฑ„ํŒ… ๋ชจ๋‘์— Ollama๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํ”„๋ก ํŠธ์—”๋“œ๋Š” ๋ฐฑ์—”๋“œ์™€ ํ†ต์‹ ํ•˜๋Š” Expo / React Native ์•ฑ์ž…๋‹ˆ๋‹ค.


Features

  • Backend
    • FastAPI
  • Frontend
    • Expo / React-Native
  • DataBase
    • PostgreSQL
  • RAG (Retrieval-Augmented Generation)
    • Ollama๋ฅผ ์‚ฌ์šฉํ•œ Embeddings
    • ChromaDB๋ฅผ ์‚ฌ์šฉํ•œ Vector store
    • Chat / Answer generation
  • DevOps
    • Docker Compose
    • GitHub Actions workflows

Architecture

+-----------------------------+
|        Frontend (Expo)      |
|  - React Native app         |
|  - Calls backend /auth,     |
|    /items, /rag endpoints   |
+--------------+--------------+
               |
               v
+-----------------------------+
|       Backend (FastAPI)     |
|  - Auth & Items routers     |
|  - RAG router (/rag/...)    |
|  - SQLAlchemy + Postgres    |
+--------------+--------------+
               |
       +-------+----------+
       |                  |
       v                  v
+-------------+   +------------------+
|  ChromaDB   |   |   Ollama (LLM)   |
|  Vector DB  |   |  /api/chat       |
|  /chroma_db |   |  /api/embeddings |
+-------------+   +------------------+

๐Ÿš€ Getting Started

1. Prerequisites

2. Build and start all services:

# set environment variables:
export REACT_NATIVE_PACKAGER_HOSTNAME=${YOUR_HOST}

# Build the image
docker compose build

# Run the container
docker compose up

3. Test:

# Backend pytest
docker compose \
  -f docker-compose.test.yml run \
  --rm \
  --entrypoint /bin/sh backend_test \
  -lc 'pytest -q'

# Backend Lint
docker compose \
  -f docker-compose.test.yml run \
  --rm \
  --entrypoint /bin/sh backend_test \
  -lc 'ruff check /app /tests'

# Frontend Test
docker compose \
  -f docker-compose.test.yml run \
  --rm frontend_test

Visit the services:

  • Backend API: http://localhost:8000/docs "backend"

  • Frontend UI (WEB): http://localhost:8081
  • Frontend UI (mobile): exp://${YOUR_HOST}:8081: Expo์—์„œ ์ œ๊ณตํ•˜๋Š” QR๋กœ ์ ‘์†ํ•ฉ๋‹ˆ๋‹ค. "expo"

RAG API

Ingest documents

POST /rag/ingest

curl -X POST http://localhost:8000/rag/ingest \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [
      {
        "id": "miura_intro_001",
        "text": "Miura Peninsula is located in Kanagawa, south of Yokohama. It is famous for its coastline, fresh seafood, and views of Mount Fuji on clear days.",
        "source": "local-notes"
      }
    ]
  }'

Response:

{
  "total_chunks": 1
}

Ask a question

POST /rag/query

curl -X POST http://localhost:8000/rag/query \
  -H "Content-Type: application/json" \
  -d '{
    "question": "Where is the Miura Peninsula and what is it famous for?",
    "top_k": 5
  }'

Example response:

{
  "answer": "The Miura Peninsula is in Kanagawa, south of Yokohama. It is known for its coastline, fresh seafood, and views of Mount Fuji on clear days.",
  "chunks": [
    {
      "id": "miura_intro_001_0",
      "text": "...",
      "source": "local-notes",
      "chunk_index": 0,
      "distance": 0.01
    }
  ]
}

License

  • Apache License 2.0