Skip to content

Restart easyRAG: Medical RAG system using RAG-Anything, PowerSync, TanStack, Bun & Biome#2

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/restart-anything-project
Draft

Restart easyRAG: Medical RAG system using RAG-Anything, PowerSync, TanStack, Bun & Biome#2
Copilot wants to merge 4 commits intomainfrom
copilot/restart-anything-project

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

Replaces the empty scaffold with a full implementation of a multimodal medical RAG system, using RAG-Anything as the core pipeline instead of building retrieval primitives from scratch.

Backend (apps/api/) — FastAPI + RAG-Anything

  • services/rag_service.py — Singleton wrapping RAGAnything; handles document ingestion via process_document_complete(), querying via aquery(question, mode=mode), and JSON-backed document metadata (list/soft-delete)
  • services/powersync.py — PyJWT-signed tokens for PowerSync client auth
  • routers/documents.py — Multipart upload → RAG-Anything pipeline; list + soft-delete
  • routers/query.py — POST /api/query with specialist role injection as system prompt prefix; supports naive | local | global | hybrid modes
  • routers/specialists.py — 10 medical specialist personas (GP, Cardiologist, Neurologist, Radiologist, Pharmacist, Surgeon, Oncologist, Pediatrician, Psychiatrist, Emergency)
  • config.py — Pydantic Settings; all config from env vars
# Specialist framing injected at query time
if specialist_role:
    full_question = f"[System: You are a {specialist_role} medical specialist. Answer based on the documents provided, always citing sources.]\n\n{question}"
result = await self._rag.aquery(full_question, mode=mode)

Frontend (apps/web/) — React 19 + Vite + TanStack Router + PowerSync

  • powersync/schema.ts — PowerSync schema: documents, messages, specialists tables
  • powersync/PowerSyncProvider.tsxPowerSyncDatabase singleton; connector fetches JWT from /api/powersync/token
  • components/ChatInterface.tsx — Streaming-style chat UI with typing indicator and inline source citations
  • components/SpecialistSelector.tsx — Card grid for specialist selection; selection passed to chat as specialist_role
  • components/DocumentUpload.tsx — Drag & drop; validates extensions before upload; per-file status feedback
  • lib/api.ts — Typed fetch wrapper; detects FormData to omit Content-Type (lets browser set multipart boundary)

Config & Tooling

  • Root .env.example covering both API and frontend env vars (OPENAI_API_KEY, POWERSYNC_URL, POWERSYNC_SECRET, VITE_POWERSYNC_URL)
  • apps/web/biome.json — Biome linting + formatting; bun run lint wired in package.json
  • apps/api/pyproject.tomlraganything, lightrag-hku, fastapi, uvicorn, pyjwt, pydantic-settings

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits March 12, 2026 16:40
- Python FastAPI backend (apps/api):
  - config.py: Pydantic Settings with all env vars
  - main.py: FastAPI app with CORS, routers, startup hooks
  - services/rag_service.py: RAGAnything singleton with process/query/list/delete
  - services/powersync.py: PyJWT token generation for PowerSync
  - routers/documents.py: upload, list, soft-delete
  - routers/query.py: RAG query endpoint + modes listing
  - routers/specialists.py: 10 medical specialist roles
  - routers/powersync.py: JWT token endpoint
  - pyproject.toml: hatchling build, all dependencies
  - .python-version: 3.10

- React + Vite frontend (apps/web):
  - TanStack Router (code-based routing)
  - PowerSync integration with custom React context
  - SpecialistSelector: grid of 10 specialist cards
  - ChatInterface: message list, typing indicator, source citations
  - DocumentUpload: drag & drop, multi-file, progress feedback
  - DocumentList: table with status, delete action, refresh
  - lib/api.ts: typed fetch wrapper
  - index.css: medical white/blue theme with CSS variables
  - biome.json: linting/formatting config

- Root files: .gitignore, .env.example, README.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- main.py: replace deprecated @app.on_event with lifespan context manager
- rag_service.py: remove duplicate openai_complete_if_cache import in vision_model_func
- routers/query.py: fix return type hint dict[str, list[dict[str, str]]]
- router.tsx: use exported Route from __root.tsx instead of creating duplicate rootRoute
- DocumentUpload.tsx: wrap processFile and handleFiles in useCallback with proper deps

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nStack, Bun & Biome

Co-authored-by: HarryBMa <163435833+HarryBMa@users.noreply.github.com>
Copilot AI changed the title [WIP] Restart RAG-Anything project Restart easyRAG: Medical RAG system using RAG-Anything, PowerSync, TanStack, Bun & Biome Mar 12, 2026
Copilot AI requested a review from HarryBMa March 12, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants