Skip to content

Architecture

Yiğit ERDOĞAN edited this page Jan 11, 2026 · 1 revision

🏗️ Architecture

CodeScope is built with a modern local-first RAG (Retrieval-Augmented Generation) architecture.

System Overview

The system consists of three main components:

  1. Frontend: Next.js 14 web interface
  2. Backend: FastAPI server orchestrating the RAG pipeline
  3. Local Infrastructure: Ollama (LLM) and ChromaDB (Vector DB)

The RAG Pipeline

CodeScope follows a standard RAG workflow:

  1. Ingestion Phase:

    • Files are loaded from the local filesystem.
    • Code is split into meaningful chunks using LangChain's RecursiveCharacterTextSplitter.
    • Chunks are converted into vector embeddings using sentence-transformers.
    • Embeddings and metadata are stored in ChromaDB.
  2. Retrieval Phase:

    • User query is embedded using the same embedding model.
    • A similarity search is performed against ChromaDB to find relevant code snippets.
    • Context is filtered and ranked for relevance.
  3. Generation Phase:

    • The user query and retrieved snippets are formatted into a prompt.
    • The prompt is sent to the local LLM via Ollama.
    • The response is streamed back to the user in real-time.

Tech Stack

Backend

  • FastAPI: High-performance asynchronous web framework.
  • LangChain: Framework for developing LLM-powered applications.
  • ChromaDB: AI-native open-source vector database.
  • Sentence-Transformers: Multi-lingual text embeddings.

Frontend

  • Next.js 14: React framework with App Router.
  • React 19: Modern UI library.
  • Tailwind CSS: Utility-first CSS framework.
  • Lucide React: Beautifully simple icons.

Data Flow Diagram

graph TD
    User((User)) -->|Query| Frontend[Next.js Frontend]
    Frontend -->|API Request| Backend[FastAPI Backend]
    Backend -->|Search| Chroma[ChromaDB]
    Chroma -->|Relevant Snippets| Backend
    Backend -->|Prompt + Context| Ollama[Ollama LLM]
    Ollama -->|Streaming Response| Backend
    Backend -->|SSE Stream| Frontend
    Frontend -->|Display| User
Loading

Security & Privacy

CodeScope is designed with a "local-only" philosophy:

  • No External APIs: All processing happens on the host machine.
  • No Data Telemetry: Your code and queries are never sent to external servers.
  • Isolated Environment: Runs completely offline if desired.

Next Steps

Clone this wiki locally