How abujubair7/edith works
1. What this repo is
- This is a two-tier TypeScript application: a React/Vite frontend and a Node backend.
- The naming suggests a chat + document-assistant product rather than a general web app: there are PDF processing utilities, retrieval logic, and multiple LLM backends.
2. Frontend boundary
- The frontend lives in frontend/ and is a client-only UI built with React + TypeScript + Vite.
- Its job is presentation and user interaction: ChatPage, LoginPage, message rendering, markdown rendering, chat history, and a typewriter effect.
- src/api.ts is the main boundary to the backend; the browser does not appear to talk directly to AI providers.
3. Frontend UI structure
- pages/ChatPage.tsx is the main interaction surface for conversations.
- components/MessageBubble.tsx and MarkdownRenderer.tsx show that assistant responses are rendered as rich text, not plain strings.
- hooks/useChatHistory.ts and hooks/useTypewriter.ts indicate local UI state management for conversation persistence and streaming-like message display.
4. Backend entry point and API layer
- The backend lives in backend/ and starts from src/app.ts.
- This file is the likely HTTP server and request routing boundary for the frontend.
- The backend appears to expose a single application API that orchestrates AI calls, document extraction, and retrieval rather than exposing those concerns directly to the browser.
5. LLM integration is split by provider
- src/assistant/gemini.ts and src/interfaces/gemini.interface.ts indicate one integration path for Gemini.
- src/localAI/ollama.ts and src/interfaces/ollama.interface.ts indicate a second path for local models via Ollama.
- This is an important architectural boundary: the repo supports both cloud AI and local AI with provider-specific contracts.
6. Assistant orchestration layer
- src/assistant/extractor.ts looks like the high-level orchestration for turning content into structured outputs.
- The naming suggests it coordinates prompts, tool logic, or extraction workflows rather than being a provider wrapper itself.
- This is likely where incoming user requests are translated into the right model call and post-processed into UI-ready responses.
7. Document ingestion and retrieval path
- src/utils/processPdf.ts is the clearest sign of a PDF ingestion pipeline.
- src/localAI/localExtract.ts, src/localAI/rag.ts, and src/utils/cosineSimilarity.ts suggest a local RAG-style retrieval flow: extract text, compare chunks or candidates, and select the most relevant context.
- The architecture likely supports asking questions over uploaded PDFs or extracted document content.
8. Data flow through the backend
- A typical flow is: frontend sends user input and/or document context → backend parses/processes it → PDF text is extracted if needed → relevant chunks are ranked using similarity logic → chosen context is passed to Gemini or Ollama → response is returned to the frontend.
- This keeps document processing and AI orchestration on the server side, away from the browser.
9. Core abstraction boundaries
- The interfaces/ folder shows the project uses explicit provider contracts, which helps isolate the app from vendor-specific request/response shapes.
- The utils/ folder contains shared low-level helpers, while assistant/ and localAI/ contain higher-level workflow logic.
- That separation makes it easier to swap model providers or change the retrieval strategy without rewriting the UI.
10. Tech stack and runtime boundaries
- Frontend runtime: browser, built with React/TypeScript/Vite.
- Backend runtime: Node.js/TypeScript.
- External dependencies that materially affect architecture are Gemini API and Ollama; both are first-class integration points.
11. What is not central here
- The README included in the repo is an MCP notes document, but the file tree does not show an actual MCP server implementation.
- So MCP should be treated as background documentation/context, not a runtime subsystem in this repository.
12. How to draw the architecture
- Draw three main blocks: UI client, backend orchestrator, and model/document services.
- Inside the backend, split into API entrypoint, assistant orchestration, document processing/RAG, and provider adapters.
- Show the backend as the only component that touches Gemini/Ollama and the only component that performs PDF parsing and similarity-based retrieval.
Main entry points: ChatPage.tsx Chat page · extractor.ts Assistant core · rag.ts RAG flow · App.tsx App shell
Components 19
Frontend
React/Vite client UI
- App shell · Top-level client application and routing container.
frontend/src/App.tsx - Chat page · Primary conversation and document-assistant interface.
frontend/src/pages/ChatPage.tsx - Login page · Authentication or entry screen for the client.
frontend/src/pages/LoginPage.tsx - API client · Browser-side boundary for calling backend endpoints.
frontend/src/api.ts - Message UI · Chat message presentation and rich-text rendering.
frontend/src/components/MessageBubble.tsx - Markdown · Formats assistant responses as markdown content.
frontend/src/components/MarkdownRenderer.tsx - Chat history · Client-side conversation persistence and state sync.
frontend/src/hooks/useChatHistory.ts - Typewriter · Streaming-style text reveal for assistant output.
frontend/src/hooks/useTypewriter.ts
Backend
Node orchestration and retrieval
- Server app · Backend entrypoint and request routing boundary.
backend/src/app.ts - Assistant core · Coordinates prompts, extraction, and response shaping.
backend/src/assistant/extractor.ts - Gemini adapter · Cloud-model integration for Gemini.
backend/src/assistant/gemini.ts - Ollama adapter · Local-model integration for Ollama.
backend/src/localAI/ollama.ts - RAG flow · Ranks document chunks and prepares relevant context.
backend/src/localAI/rag.ts - Text extract · Extracts structured text from local content sources.
backend/src/localAI/localExtract.ts - PDF process · Handles PDF parsing and preprocessing.
backend/src/utils/processPdf.ts - Similarity · Computes cosine similarity for retrieval ranking.
backend/src/utils/cosineSimilarity.ts - Shared tools · Common backend utilities used across orchestration paths.
backend/src/utils/tools.ts - Gemini iface · Type contract for Gemini requests and responses.
backend/src/interfaces/gemini.interface.ts - Ollama iface · Type contract for Ollama requests and responses.
backend/src/interfaces/ollama.interface.ts
Connections 18
- App shell → Chat page: renders · The app shell hosts the chat experience.
- App shell → Login page: routes to · The app shell also exposes the login entry screen.
- Chat page → API client: calls · Chat interactions are sent through the API client.
- Chat page → Message UI: uses · Conversation UI is composed from message bubbles.
- Message UI → Markdown: formats · Assistant text is rendered as markdown.
- Chat page → Chat history: stores · Chat page relies on history state management.
- Chat page → Typewriter: animates · Assistant replies can be revealed progressively.
- API client → Server app: requests · Browser requests terminate at the backend server.
- Server app → Assistant core: orchestrates · The server delegates response generation to assistant logic.
- Assistant core → Gemini adapter: cloud path · One execution path targets Gemini.
- Assistant core → Ollama adapter: local path · Another execution path targets Ollama.
- Assistant core → RAG flow: retrieves context · Assistant orchestration can pull relevant document context.
- RAG flow → Text extract: reads text · RAG starts from extracted local content.
- Text extract → PDF process: parses · PDF processing feeds document extraction.
- RAG flow → Similarity: ranks · Similarity scoring selects the most relevant chunks.
- Assistant core → Shared tools: uses · Orchestration shares common backend helpers.
- Gemini adapter → Gemini iface: implements · Gemini adapter follows the Gemini contract.
- Ollama adapter → Ollama iface: implements · Ollama adapter follows the Ollama contract.