# sultanshahdev/localcode-intelligence architecture

> Architecture diagram of the GitHub repository sultanshahdev/localcode-intelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sultanshahdev/localcode-intelligence
- Repository: https://github.com/sultanshahdev/localcode-intelligence

## Overview

LocalCode Intelligence is a local-first code exploration and search application. A user prepares a local or GitHub repository, checks its supported-source coverage, then searches semantically or by exact text; results can be opened in a bounded source viewer. Semantic search prepares source regions, combines local embeddings with lexical retrieval, and assesses relevance before returning candidates. Separate capabilities provide symbol exploration, file navigation, and a repository map. The graph follows documented API routes and sampled calls; some server handlers and language-adapter internals were not fully shown.

Main entry points: [`src/server.ts`](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/server.ts) (HTTP server), [`src/source.ts`](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/source.ts) (Source discovery), [`src/search.ts`](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/search.ts) (Semantic search), [`web/src/App.tsx`](https://github.com/sultanshahdev/localcode-intelligence/blob/main/web/src/App.tsx) (Web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interfaces"]
  node_web["Web UI<br/>[App.tsx]"]
  node_webapi["Web API client<br/>[api.ts]"]
  node_cli["CLI<br/>[cli.ts]"]
end

subgraph group_api["API orchestration"]
  node_server["HTTP server<br/>[server.ts]"]
  node_execution["Search queue"]
end

subgraph group_source["Repository understanding"]
  node_source["Source discovery<br/>[source.ts]"]
  node_languages["Language adapters"]
  node_status["Coverage status<br/>[status.ts]"]
  node_symbols["Symbol explorer<br/>[symbols.ts]"]
  node_map["Repository map<br/>[repository-map.ts]"]
end

subgraph group_search["Search and ranking"]
  node_exact["Exact text search<br/>[exact-search.ts]"]
  node_search["Semantic search<br/>[search.ts]"]
  node_retrieval["Hybrid retrieval<br/>[retrieval.ts]"]
  node_cache[("Embedding cache")]
  node_relevance["Relevance assessment<br/>[relevance.ts]"]
end

subgraph group_inputs["Repository inputs"]
  node_repository["Path validation<br/>[repository.ts]"]
  node_github["GitHub acquisition"]
end

node_user(("Engineer"))

node_user -->|"uses"| node_web
node_web -->|"requests"| node_webapi
node_webapi -->|"calls API"| node_server
node_user -->|"runs commands"| node_cli
node_cli -->|"validates paths"| node_repository
node_cli -->|"runs search"| node_search
node_server -->|"validates paths"| node_repository
node_server -->|"acquires checkout"| node_github
node_server -->|"checks coverage"| node_status
node_server -->|"queues searches"| node_execution
node_server -->|"dispatches semantic"| node_search
node_server -->|"dispatches exact"| node_exact
node_server -->|"dispatches symbols"| node_symbols
node_server -->|"builds map"| node_map
node_server -->|"reads source"| node_source
node_status -->|"inspects scope"| node_source
node_source -->|"resolves adapters"| node_languages
node_map -->|"uses exclusions"| node_source
node_search -->|"prepares scope"| node_source
node_search -->|"retrieves candidates"| node_retrieval
node_search -->|"creates embedder"| node_cache
node_search -->|"assesses candidates"| node_relevance
node_retrieval -->|"uses regions"| node_source
node_exact -->|"scans source"| node_source
node_symbols -->|"discovers files"| node_source
node_web -->|"prepares repository"| node_server
node_web -->|"opens source"| node_server

click node_web "https://github.com/sultanshahdev/localcode-intelligence/blob/main/web/src/App.tsx"
click node_webapi "https://github.com/sultanshahdev/localcode-intelligence/blob/main/web/src/api.ts"
click node_cli "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/cli.ts"
click node_server "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/server.ts"
click node_execution "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/search-execution.ts"
click node_repository "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/repository.ts"
click node_github "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/github-repository.ts"
click node_source "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/source.ts"
click node_languages "https://github.com/sultanshahdev/localcode-intelligence/tree/main/src/languages"
click node_status "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/status.ts"
click node_symbols "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/symbols.ts"
click node_exact "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/exact-search.ts"
click node_map "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/repository-map.ts"
click node_search "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/search.ts"
click node_retrieval "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/retrieval.ts"
click node_cache "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/persistent-embedding-cache.ts"
click node_relevance "https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/relevance.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_webapi,node_cli toneBlue
class node_server,node_execution toneAmber
class node_source,node_languages,node_status,node_symbols,node_map toneMint
class node_exact,node_search,node_retrieval,node_cache,node_relevance toneRose
class node_repository,node_github,node_user toneIndigo
```

## Components

### User interfaces

- [Web UI](https://github.com/sultanshahdev/localcode-intelligence/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Web API client](https://github.com/sultanshahdev/localcode-intelligence/blob/main/web/src/api.ts): `web/src/api.ts`
- [CLI](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/cli.ts): `src/cli.ts`

### API orchestration

- [HTTP server](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/server.ts): `src/server.ts`
- [Search queue](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/search-execution.ts): `src/search-execution.ts`

### Repository understanding

- [Source discovery](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/source.ts): `src/source.ts`
- [Language adapters](https://github.com/sultanshahdev/localcode-intelligence/tree/main/src/languages): `src/languages`
- [Coverage status](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/status.ts): `src/status.ts`
- [Symbol explorer](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/symbols.ts): `src/symbols.ts`
- [Repository map](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/repository-map.ts): `src/repository-map.ts`

### Search and ranking

- [Exact text search](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/exact-search.ts): `src/exact-search.ts`
- [Semantic search](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/search.ts): `src/search.ts`
- [Hybrid retrieval](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/retrieval.ts): `src/retrieval.ts`
- [Embedding cache](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/persistent-embedding-cache.ts): `src/persistent-embedding-cache.ts`
- [Relevance assessment](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/relevance.ts): `src/relevance.ts`

### Repository inputs

- [Path validation](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/repository.ts): `src/repository.ts`
- [GitHub acquisition](https://github.com/sultanshahdev/localcode-intelligence/blob/main/src/github-repository.ts): `src/github-repository.ts`

### Other components

- **Engineer**

## Connections

- Engineer → Web UI: uses (evidence: `README.md`)
- Web UI → Web API client: requests (evidence: `web/src/App.tsx`)
- Web API client → HTTP server: calls API (evidence: `README.md`)
- Engineer → CLI: runs commands (evidence: `README.md`)
- CLI → Path validation: validates paths (evidence: `src/cli.ts`)
- CLI → Semantic search: runs search (evidence: `src/cli.ts`)
- HTTP server → Path validation: validates paths (evidence: `src/server.ts`)
- HTTP server → GitHub acquisition: acquires checkout (evidence: `README.md`)
- HTTP server → Coverage status: checks coverage (evidence: `src/server.ts`)
- HTTP server → Search queue: queues searches (evidence: `src/server.ts`)
- HTTP server → Semantic search: dispatches semantic (evidence: `README.md`)
- HTTP server → Exact text search: dispatches exact (evidence: `src/server.ts`)
- HTTP server → Symbol explorer: dispatches symbols (evidence: `README.md`)
- HTTP server → Repository map: builds map (evidence: `README.md`)
- HTTP server → Source discovery: reads source (evidence: `README.md`)
- Coverage status → Source discovery: inspects scope (evidence: `src/status.ts`)
- Source discovery → Language adapters: resolves adapters (evidence: `src/source.ts`)
- Repository map → Source discovery: uses exclusions (evidence: `src/repository-map.ts`)
- Semantic search → Source discovery: prepares scope (evidence: `src/search.ts`)
- Semantic search → Hybrid retrieval: retrieves candidates (evidence: `src/search.ts`)
- Semantic search → Embedding cache: creates embedder (evidence: `src/search.ts`)
- Semantic search → Relevance assessment: assesses candidates (evidence: `src/search.ts`)
- Hybrid retrieval → Source discovery: uses regions (evidence: `src/retrieval.ts`)
- Exact text search → Source discovery: scans source (evidence: `src/exact-search.ts`)
- Symbol explorer → Source discovery: discovers files (evidence: `src/symbols.ts`)
- Web UI → HTTP server: prepares repository (evidence: `README.md`)
- Web UI → HTTP server: opens source (evidence: `web/src/App.tsx`)
