JackWang666666/my-rag
AI EngineeringA dual-backend RAG knowledge-base system letting teams compare Python/LangChain and Java/Spring AI over one shared data set.
This project is a retrieval-augmented generation knowledge base with one Next.js frontend and two functionally equivalent backends: a Python/FastAPI + LangChain service and a Java/Spring Boot + Spring AI service. Both run against the same SQLite metadata file, Milvus vector collection, Neo4j graph, upload directory and JWT secret, so users can switch backends in the settings page and ask the same knowledge base the same question to compare the two stacks. The cross-backend field, route and SSE conventions are documented in the contract file, which should be read before changing either side cross-end contract.
What it does
Users can create knowledge bases, upload PDF, Word, Markdown, text, tables or source code, import an entire project directory (respecting .gitignore), preview chunks and search full text. Conversations support multiple sessions, history, streamed answers, citations with a confidence score, and thumbs-up/down feedback with comments. Documents can also be mined into entities and relations stored in Neo4j for graph browsing and entity-neighbour retrieval.
How retrieval works
The pipeline is identical on both backends. One LLM call combines routing and query rewriting, producing a route (rag, graph, hybrid or direct) plus rewritten sub-queries; the author notes this replaced three serial calls and cut cost and first-token latency to a third. Each sub-query is vector-searched and results are deduplicated by id, then re-ranked according to RERANKER_PROVIDER: a cross-encoder (Python only), LLM scoring, or plain vector order, with fragments below RERANK_THRESHOLD dropped. For graph or hybrid routes, related entities and neighbours from Neo4j are added to context. The answer is then streamed with sources and a confidence value over SSE.
Requirements and path-specific limits
Infrastructure is started with Docker Compose (etcd, MinIO, Milvus, Neo4j, Attu); applications can run fully in containers or locally. Local backends need Python 3.11+ or JDK 17 — the README explicitly says Java 8 and 11 will not compile. JWT_SECRET must be identical across both backends: if left empty each generates its own random key, so a token from one side is rejected by the other and switching backends logs the user out quick start. Deployment notes, reverse-proxy setup and production caveats are kept in a separate deployment document deployment notes.
The two backends are equivalent but not identical. Java's Tika parser additionally handles .pptx, .odt, .rtf and .epub, while the frontend only offers the format intersection so a file behaves the same on either side. Local re-ranking and local embedding with sentence-transformers work only on Python; the Java side warns and falls back. The Volcano Engine client exists only in Python. OPENAI_API_BASE follows different conventions on each side, which is why the environment file separates it from SPRING_OPENAI_API_BASE.
Unit tests on both sides need no Milvus, Neo4j or real LLM; several test groups are deliberately paired so the same input must produce the same routing, table structure or authentication result on both backends. No license is declared in the supplied repository metadata, which matters if you intend to reuse the code.
Written by AI from the project's README, updated October 28, 2026. The project's own docs are the source of truth.