A FastAPI Monolith Runs an Enterprise Knowledge Base with RAG, KAG, and 9 MySQL Databases
A single Python process runs the same enterprise knowledge platform that Java microservices serve, at identical API paths over shared databases, so any team weighing FastAPI against Spring Cloud gets a concrete cost and complexity comparison. The four-tier LLM fallback, the hybrid RRF search, and the PDF-to-Markdown pipeline are directly reusable, and the twin-backend setup shows Python can coexist with Java on one schema rather than replace it.
An enterprise knowledge base backend packs ten business modules into one FastAPI process. A gateway middleware handles auth, CORS, and logging; document, file, search, statistics, graph, foundation, user auth, and AI apps each own their own MySQL database, and common infrastructure manages connection pools across nine MySQL databases, Redis, Elasticsearch, MongoDB, and Neo4j. Every external call runs through async/await drivers, so a single uvicorn process carries the workload the Java counterpart spreads across eight microservices.
Document management runs the full lifecycle from creation through review, approval, publish, and archive, with version snapshots, inline comments, and an audit workflow. Uploaded PDF, DOCX, and XLSX files convert to Markdown automatically, and Markdown exports to a styled PDF. Search merges Elasticsearch BM25 full-text with semantic vector retrieval via Reciprocal Rank Fusion. The AI layer answers questions with a RAG pipeline backed by a four-tier model fallback, and KAG augments generation with entity relations from the Neo4j knowledge graph; responses stream over SSE. A 4-tier degradation chain runs primary model to retry to backup to a fallback response.
The same system also ships as a Java Spring Cloud backend. The two share one schema and expose API-identical endpoints, so the front end switches between them by changing the API address. Python wins on deployment simplicity, sub-5-second cold start, and 200-500MB memory against 30s+ and 4GB+ for Java, while video transcoding and PPTX parsing remain on the Python roadmap.
The striking choice is twin backend implementations: Python and Java share one database schema and identical API paths, so a front end swaps runtimes just by changing an address.
The four-tier model fallback treats LLM calls as best-effort dependencies with retry and a canned answer, a pragmatic production stance rather than assuming model providers stay reliable.
The monolith-versus-microservices tradeoff gets quantified instead of asserted: sub-5-second start and 200-500MB memory against 30s+ and 4GB+, with the Python side candidly listing video and PPTX as missing.