Cognosa Component Stack

Runtime processes, the packages inside them, the libraries they are built on, and the stores they talk to

The platform is three runtime pieces plus a set of offline tools. The React single-page app runs in the browser. The app process serves it and the REST API. The rt process executes the RAG pipeline. All Python code shares the common package. LangChain lives only in rt and the ingestion tools: it is the retrieval and chat abstraction, never part of the web API.

React SPA (browser) frontend/src · Vite build → backend/static libraries app · FastAPI process backend/webapp.py → cwa_lib/ libraries rt · task processor backend/run_tasks.py → tasks_lib/ libraries Offline tools backend/*.py · tools/ libraries pages/ React Router QueryDocuments · ManageContexts · HomePage Ga*: ManageUsers · ManageVDBs · ManageDocTasks · GVDBsRetrParams Su*: ManageGroups · ManageUsers · ManageLLMs · ManageVDBs · ManageApiSettings · ManageLogCRUD · ServerStatus guards: GroupAdminRoute · SuperUserRoute QueryDocuments polls doc_tasks until status ≥ 6 stores/ · tables/ · components/ Zustand: useLoggedUserStore · useWebAppOptionsStore · per-page stores (createResettableStore) UniversalTable + TableStoreFactory (CRUD grids) GVDBsRetrParams / GVDBsRetrFilters editors MarkdownRenderer · TopNavBar · ThemeColor api/ axiosClient: JWT bearer, 401 → logout apiURL: /api/v1 prefix · NavigationInjector cwa_lib/app.py · users.py uvicorn webapp:app FastAPI app factory · CORS · static SPA mount fastapi-users JWT (7-day), username-or- email login middleware/last_seen · Depends() auth guards roles: user · group admin · superuser routers/ → pages/ → sql_tables/ /api/v1/* user: doc_tasks · manage_contexts · users · misc · webapp_options ga_*: manage_users · manage_vdbs · manage_doc_tasks · settings (retrieval params) su_*: groups · users · llms · vdbs · api_settings · doc_tasks · log_crud · server_status · change_oneself pages/ = handlers · sql_tables/ = repositories pydantic_schemas/ · validators/ request / response models per router doc_tasks create: snapshots the group_vdbs and group_llms rows into the task alembic/ migrations run_tasks.py · main_iteration.py 1 process poll doc_tasks WHERE status IN (0, 3) FOR UPDATE SKIP LOCKED qd_lib/qd_init → VDB queue · qd_lib/qd_vdb_fetched → LLM thread group_vdbs_tasks: refresh filter select values vdb_lib/ RT_VDB_PROCESS_NUM processes VDBWorker(Process) reads a multiprocessing Queue emb_models: HuggingFaceEmbeddings, preloaded per model name vdb_ops → qdrant_ops | chromadb_ops | pgvector_ops qdrant_filters: payload filter from group retrieval filters retriever: similarity · mmr · similarity_score_threshold (k, fetch_k, lambda_mult, score_threshold) found_documents → doc_tasks.context_json llm_lib/ 1 thread per task LLMWorker(Thread) · llm_ops: prepare_context + chain llm_type_openai: ChatGPT · Qwen · Ollama local / remote llm_type_claude · llm_type_gemini · tiktoken_count chain: {context, question} | PromptTemplate | llm | StrOutputParser, run with .stream() entities/ · vdb_llm_status_worker.py · watchdogs queue messages · VDB / LLM availability checks → api_processes ingestion document_loader_qdrant.py · document_loader_pgvector.py tools/ingest_dev/: casambi_*, furocad_book_loader.py multi-strategy chunking, metadata per document class database init_sql_db.py (.init_sql_data/) create_user.py · alembic upgrade head tools/db: backup / restore checks check_qdrant_server.py · check_pgvector.py · check_chroma_server.py React 19 TypeScript 5.8 Vite 7 react-router-dom 7 React Bootstrap 2.10 Bootstrap Icons Zustand 5 Axios react-markdown rehype-highlight SheetJS xlsx FastAPI 0.116 Uvicorn fastapi-users 14 Pydantic v2 SQLAlchemy 2 async asyncpg Alembic Jinja2 LangChain core 1.0 langchain-huggingface sentence-transformers langchain-qdrant qdrant-client langchain-chroma langchain-community PGVector langchain-openai langchain-anthropic langchain-google-genai tiktoken SQLAlchemy 2 sync psycopg2 multiprocessing threading community loaders text splitters pypdf docx2txt python-pptx openpyxl unstructured pg_dump common/ — shared package: ORM models, enums, retrieval settings, DB session factories, watchdogs sql_models/: api_groups · api_users · group_llms · group_vdbs · group_contexts · doc_tasks · api_settings · api_processes · log_crud · group_vdbs_tasks enums/: TaskStatus 0 → 6 · GLLMsTypes · GVDBsTypes features/: gvdbs_retr_params · gvdbs_retr_filters sql_db_async · sql_db_sync (session factories) · watchdogs/ · async_log · .env config PostgreSQL · cwa_db tenants, users, roles · group LLM / VDB / context configs doc_tasks: question, context_json, sent_to_llm, answer, status log_crud audit · api_processes health Qdrant one collection per group VDB · dense vectors + payload metadata collections today: casambi, furocad ChromaDB / pgvector: same vdb_ops interface HF model cache hf_cache volume all-MiniLM-L6-v2 BAAI/bge-base-en-v1.5 LLM endpoints Ollama local / remote :11434 (OpenAI-compatible /v1) OpenAI · Anthropic · Google · Alibaba DashScope chosen per task from the group_llms snapshot (gllms_json) HTTPS JWT app → Postgres: SQLAlchemy async, asyncpg :5432 rt → Postgres: sync session, poll + write doc_tasks rt → Qdrant: embed + search, langchain-qdrant :6333 rt → model cache rt → LLM: chat completions, streamed ingestion → Qdrant: load, chunk, embed, upsert db tools → Postgres: init, migrate, backup / restore
Columns are the runtime processes; the panels inside each are the repo packages in call order, top to bottom, with the third-party libraries at the foot. The shared common package spans everything Python. Arrows show which process opens a connection to which store or endpoint. Only Qdrant is drawn as the vector store; ChromaDB and pgvector implement the same vdb_ops interface.
Browser app process rt process Offline tools Shared package Data store Third-party libraries

Where LangChain is used

PackageUsed inFor
langchain_coretasks_lib/llm_lib/llm_type_*.pyPromptTemplate, RunnablePassthrough, RunnableLambda, StrOutputParser; the chain is {context, question} | prompt | llm | parser, run with .stream()
langchain_openaillm_type_openai.pyChatOpenAI for OpenAI, Qwen (DashScope), and Ollama local or remote through the OpenAI-compatible endpoint
langchain_anthropic, langchain_google_genaillm_type_claude.py, llm_type_gemini.pyChatAnthropic, ChatGoogleGenerativeAI
langchain_huggingface + sentence-transformersvdb_lib/emb_models.py, loadersHuggingFaceEmbeddings, preloaded per model name from RT_VDB_EMB_MODELS_PRELOAD
langchain_qdrant, langchain_chroma, langchain_community PGVectorvdb_lib/*_ops.pyVector store wrappers; as_retriever(search_type, search_kwargs) with a Qdrant payload filter built from the group's retrieval filters
langchain_community loaders, langchain_text_splittersdocument_loader_*.py, tools/ingest_dev/PDF, DOCX, PPTX, XLSX, TXT loading and chunking at ingestion time

Runtime processes

ProcessEntry pointConcurrencyTalks to
React SPAfrontend/src/main.tsx, built by Vite into backend/staticBrowser; polls GET /api/v1/doc_tasks/{uuid} until the task finishesapp only, over HTTPS with a JWT bearer
appbackend/webapp.py under uvicornAsync; one workerPostgreSQL (async SQLAlchemy); reads VDB and LLM health from api_processes
rtbackend/run_tasks.pyMain loop; RT_VDB_PROCESS_NUM VDB worker processes; one LLM thread per task; watchdog threadsPostgreSQL (sync SQLAlchemy), Qdrant, Ollama hosts, cloud LLM APIs, Hugging Face Hub on first model load
Offline toolsRun by hand from backend/Loaders use a multiprocessing pool per fileQdrant (ingestion), PostgreSQL (init, migrate, backup)