# linxiv-dev/linxiv architecture

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

- Interactive diagram: https://gitdiagram.com/linxiv-dev/linxiv
- Repository: https://github.com/linxiv-dev/linxiv

## Overview

1. **Overall shape**
   - linXiv is a **local-first research manager** built around a shared Python core.
   - It is delivered in three main runtime forms: a **Tauri desktop app** (React frontend + Rust shell + Python sidecars), a **standalone HTTP API** (FastAPI), and **command-line / MCP interfaces** that reuse the same backend logic.

2. **Primary user-facing frontend**
   - The `src/` tree is the interactive desktop UI: React + TypeScript, built with Vite.
   - Pages are organized by domain: papers, projects, tags, notes, search, graph, settings, and previews.
   - UI state is split between local stores (`src/stores`) and server-backed queries through the typed API client in `src/api`.

3. **Backend API boundary**
   - The `api/` package is the HTTP boundary for the app.
   - It exposes JSON endpoints and also serves the bundled graph frontend under `public/graph`, which is used for the paper-author visualization.
   - This is the boundary the desktop UI talks to in development, and it is also what the CLI/MCP layers ultimately rely on indirectly through shared service code.

4. **Core domain/service layer**
   - The `service/` package is the main application boundary between API/UI and persistence.
   - It is split by domain: papers, authors, tags, projects, notes, content, and files.
   - These services shape data into typed models (`service/models`) and implement higher-level behavior such as paper details, project-scoped notes, graph data assembly, and export/import orchestration.

5. **Persistence layer**
   - The `storage/` package owns SQLite access, schema management, and query construction.
   - It contains the canonical database schema, migrations, versioning, and SQL views/indexes.
   - Important stored concepts include papers, paper versions, authors, tags, projects, notes, search history, search state, and full-text search.
   - A composable query object (`Q`) is used for filtering, especially in project queries.

6. **File and path management**
   - Local files are first-class: PDFs, TeX sources, vault notes, and database files are all managed on disk.
   - `storage/paths.py` and `service/files.py` centralize filesystem layout and file resolution.
   - This is part of the local-first design: metadata lives in SQLite, while binary assets and generated notes live in local directories.

7. **Metadata acquisition and document ingestion**
   - The `sources/` package handles all external paper discovery and enrichment.
   - It talks to arXiv, Crossref, OpenAlex, DOI resolution services, and PDF metadata extraction.
   - The ingestion flow is: search or resolve an identifier, fetch metadata, optionally download PDF/TeX, then persist through the service/storage layers.
   - `sources/fetch_paper_metadata.py` is the orchestration point for that pipeline.

8. **Graph visualization subsystem**
   - The graph feature is a dedicated frontend bundle in `public/graph` using D3/Cytoscape layout helpers.
   - It renders a paper-author network, fed from backend graph data queries.
   - The repo also documents a `postMessage` protocol for iframe communication, so the graph viewer is intentionally treated as a separate embedded subsystem rather than a normal page.

9. **Optional AI and integrations**
   - `AI_tools.py` wraps Gemini-based features for tagging, summarization, and semantic similarity.
   - Obsidian integration is supported through markdown/frontmatter templates in `formats/`.
   - These are optional augmentation paths: they consume paper content from abstract/full text/PDF and write results back into local files or tags, rather than becoming a separate service.

10. **Desktop packaging and sidecars**
   - `src-tauri/` is the desktop shell that bundles the web frontend and ships Python backend executables as sidecars.
   - The Python API, CLI, and MCP server are built from separate PyInstaller specs and staged into Tauri’s binary directory.
   - In production, the desktop app depends on these bundled binaries; in development, the UI talks to a locally running API on port 8000.

11. **External interfaces**
   - The repository exposes the same core capability through multiple entry points:
     - GUI for interactive management
     - HTTP API for programmatic access
     - CLI for scripting and automation
     - MCP server for Claude integration
   - All of them converge on the same underlying service/storage logic, which is the main architectural invariant.

12. **Schema evolution and operational concerns**
   - The database schema is actively evolving, with migrations tracked under `storage/migrations` and architecture notes in `docs/adr`.
   - The repo treats identifier normalization and storage compatibility as a first-class concern, which is why paper identity, versioning, and search persistence are modeled explicitly in the database.
   - CI and tests cover API, DB, sources, export/import, and CLI behavior, reflecting the repo’s emphasis on keeping the backend contract stable across multiple frontends.

Main entry points: [`service`](https://github.com/linxiv-dev/linxiv/tree/main/service) (Services), [`src-tauri`](https://github.com/linxiv-dev/linxiv/tree/main/src-tauri) (Tauri shell), [`sources/fetch_paper_metadata.py`](https://github.com/linxiv-dev/linxiv/blob/main/sources/fetch_paper_metadata.py) (Fetch metadata), [`api`](https://github.com/linxiv-dev/linxiv/tree/main/api) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop app"]
  node_ui["UI<br/>React/Vite frontend"]
  node_ui_api["API client<br/>typed client"]
  node_ui_state["UI state<br/>client stores"]
end

subgraph group_backend["Backend stack"]
  node_http_api["HTTP API<br/>FastAPI boundary"]
  node_service_core["Services"]
  node_service_models["Models"]
  node_storage_core[("Storage<br/>SQLite persistence")]
  node_storage_schema["Schema<br/>tables/views/migrations"]
  node_storage_queries["Queries<br/>query layer<br/>[queries.py]"]
  node_files["Files<br/>path management<br/>[paths.py]"]
end

subgraph group_ingestion["Ingestion"]
  node_sources["Sources<br/>ingestion pipeline"]
  node_metadata_fetch["Fetch metadata<br/>orchestrator"]
  node_external_sources["Providers<br/>arXiv/Crossref/OpenAlex/DOI"]
end

subgraph group_infra["Delivery"]
  node_desktop_shell["Tauri shell<br/>desktop runtime"]
  node_graph_view["Graph view<br/>embedded visualization"]
  node_ai_tools["AI tools<br/>Gemini helpers<br/>[AI_tools.py]"]
  node_formats["Formats<br/>export/interop"]
  node_cli["CLI<br/>command interface<br/>[linxiv_cli.py]"]
  node_mcp["MCP server<br/>model context server<br/>[linxiv_mcp.py]"]
end

node_ui -->|"requests"| node_ui_api
node_ui -->|"uses"| node_ui_state
node_ui_api -->|"calls"| node_http_api
node_desktop_shell -->|"hosts"| node_ui
node_desktop_shell -->|"bundles"| node_http_api
node_http_api -->|"delegates"| node_service_core
node_service_core -->|"returns"| node_service_models
node_service_core -->|"reads/writes"| node_storage_core
node_storage_core -->|"uses"| node_storage_schema
node_storage_core -->|"filters"| node_storage_queries
node_service_core -->|"resolves"| node_files
node_sources -->|"orchestrates"| node_metadata_fetch
node_metadata_fetch -->|"queries"| node_external_sources
node_metadata_fetch -->|"persists"| node_service_core
node_metadata_fetch -->|"downloads"| node_files
node_http_api -->|"serves"| node_graph_view
node_graph_view -->|"consumes"| node_service_core
node_ai_tools -->|"augments"| node_service_core
node_formats -->|"exports"| node_service_core
node_cli -->|"uses"| node_service_core
node_mcp -->|"uses"| node_service_core
node_desktop_shell -->|"ships"| node_cli
node_desktop_shell -->|"ships"| node_mcp

click node_ui "https://github.com/linxiv-dev/linxiv/tree/main/src"
click node_ui_api "https://github.com/linxiv-dev/linxiv/tree/main/src/api"
click node_ui_state "https://github.com/linxiv-dev/linxiv/tree/main/src/stores"
click node_desktop_shell "https://github.com/linxiv-dev/linxiv/tree/main/src-tauri"
click node_http_api "https://github.com/linxiv-dev/linxiv/tree/main/api"
click node_service_core "https://github.com/linxiv-dev/linxiv/tree/main/service"
click node_service_models "https://github.com/linxiv-dev/linxiv/tree/main/service/models"
click node_storage_core "https://github.com/linxiv-dev/linxiv/tree/main/storage"
click node_storage_schema "https://github.com/linxiv-dev/linxiv/tree/main/storage/config/sql"
click node_storage_queries "https://github.com/linxiv-dev/linxiv/blob/main/storage/config/queries.py"
click node_files "https://github.com/linxiv-dev/linxiv/blob/main/storage/paths.py"
click node_graph_view "https://github.com/linxiv-dev/linxiv/tree/main/public/graph"
click node_sources "https://github.com/linxiv-dev/linxiv/tree/main/sources"
click node_metadata_fetch "https://github.com/linxiv-dev/linxiv/blob/main/sources/fetch_paper_metadata.py"
click node_external_sources "https://github.com/linxiv-dev/linxiv/tree/main/sources"
click node_ai_tools "https://github.com/linxiv-dev/linxiv/blob/main/AI_tools.py"
click node_formats "https://github.com/linxiv-dev/linxiv/tree/main/formats"
click node_cli "https://github.com/linxiv-dev/linxiv/blob/main/linxiv_cli.py"
click node_mcp "https://github.com/linxiv-dev/linxiv/blob/main/linxiv_mcp.py"

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_ui,node_ui_api,node_ui_state toneBlue
class node_http_api,node_service_core,node_service_models,node_storage_core,node_storage_schema,node_storage_queries,node_files toneAmber
class node_sources,node_metadata_fetch,node_external_sources toneMint
class node_desktop_shell,node_graph_view,node_ai_tools,node_formats,node_cli,node_mcp toneRose
```

## Components

### Desktop app

Tauri shell and React UI for interactive local-first use

- [UI](https://github.com/linxiv-dev/linxiv/tree/main/src): React/Vite frontend · Desktop user interface and page-level workflows · `src`
- [API client](https://github.com/linxiv-dev/linxiv/tree/main/src/api): typed client · Frontend request layer for server-backed data · `src/api`
- [UI state](https://github.com/linxiv-dev/linxiv/tree/main/src/stores): client stores · Local selection, theme, and import job state · `src/stores`

### Backend stack

HTTP API, shared services, and persistence

- [HTTP API](https://github.com/linxiv-dev/linxiv/tree/main/api): FastAPI boundary · JSON endpoints and embedded graph asset hosting · `api`
- [Services](https://github.com/linxiv-dev/linxiv/tree/main/service): domain services · Application boundary for papers, authors, tags, projects, notes, and files · `service`
- [Models](https://github.com/linxiv-dev/linxiv/tree/main/service/models): typed domain models · Shared response and domain shapes used across the service boundary · `service/models`
- [Storage](https://github.com/linxiv-dev/linxiv/tree/main/storage): SQLite persistence · Database access, schema management, and query construction · `storage`
- [Schema](https://github.com/linxiv-dev/linxiv/tree/main/storage/config/sql): tables/views/migrations · Canonical database tables, views, and migration history · `storage/config/sql`
- [Queries](https://github.com/linxiv-dev/linxiv/blob/main/storage/config/queries.py): query layer · Composable filtering and query helpers such as project query objects · `storage/config/queries.py`
- [Files](https://github.com/linxiv-dev/linxiv/blob/main/storage/paths.py): path management · Local filesystem layout for PDFs, notes, and database assets · `storage/paths.py`

### Ingestion

External metadata discovery and document enrichment

- [Sources](https://github.com/linxiv-dev/linxiv/tree/main/sources): ingestion pipeline · Discovery, identifier resolution, metadata enrichment, and PDF/TeX retrieval · `sources`
- [Fetch metadata](https://github.com/linxiv-dev/linxiv/blob/main/sources/fetch_paper_metadata.py): orchestrator · Coordinates search, resolve, download, and persist steps · `sources/fetch_paper_metadata.py`
- [Providers](https://github.com/linxiv-dev/linxiv/tree/main/sources): arXiv/Crossref/OpenAlex/DOI · External discovery and metadata services · `sources`

### Delivery

Packaging, sidecars, and external integration surfaces

- [Tauri shell](https://github.com/linxiv-dev/linxiv/tree/main/src-tauri): desktop runtime · Bundles the web app and launches backend sidecars · `src-tauri`
- [Graph view](https://github.com/linxiv-dev/linxiv/tree/main/public/graph): embedded visualization · Dedicated paper-author network bundle served separately under public/graph · `public/graph`
- [AI tools](https://github.com/linxiv-dev/linxiv/blob/main/AI_tools.py): Gemini helpers · Optional tagging, summarization, and similarity augmentation · `AI_tools.py`
- [Formats](https://github.com/linxiv-dev/linxiv/tree/main/formats): export/interop · Markdown, BibTeX, JSON, CSV, and Obsidian-oriented formatting · `formats`
- [CLI](https://github.com/linxiv-dev/linxiv/blob/main/linxiv_cli.py): command interface · Scriptable interface reusing the shared backend logic · `linxiv_cli.py`
- [MCP server](https://github.com/linxiv-dev/linxiv/blob/main/linxiv_mcp.py): model context server · Claude integration surface backed by the shared application core · `linxiv_mcp.py`

## Connections

- UI → API client: requests · UI pages call typed endpoints for papers, projects, search, notes, and settings
- UI → UI state: uses · Frontend components coordinate selection, theme, and import state
- API client → HTTP API: calls · Development and desktop flows reach the HTTP boundary through the client
- Tauri shell → UI: hosts · Tauri embeds the built React application
- Tauri shell → HTTP API: bundles · Desktop app launches or ships the Python API sidecar
- HTTP API → Services: delegates · API routes forward application logic to the service layer
- Services → Models: returns · Services shape data into shared typed models
- Services → Storage: reads/writes · Domain operations persist through SQLite storage
- Storage → Schema: uses · Storage code is backed by canonical tables, views, and migrations
- Storage → Queries: filters · Query objects drive composable filtering and search behavior
- Services → Files: resolves · Services centralize local file and path handling
- Sources → Fetch metadata: orchestrates · The ingestion package centers around metadata fetching coordination
- Fetch metadata → Providers: queries · Metadata orchestration contacts arXiv, Crossref, OpenAlex, and DOI resolvers
- Fetch metadata → Services: persists · Fetched metadata is normalized and stored through the shared services
- Fetch metadata → Files: downloads · PDF and TeX assets are written to local paths
- HTTP API → Graph view: serves · API hosts the bundled graph visualization assets
- Graph view → Services: consumes · Graph rendering is fed from backend graph data queries
- AI tools → Services: augments · Optional AI features read content and write tags or summaries back through services
- Formats → Services: exports · Formatting modules serialize domain data for interop and notes
- CLI → Services: uses · CLI commands reuse the shared domain services
- MCP server → Services: uses · MCP requests are mapped onto the same backend logic
- Tauri shell → CLI: ships · Desktop packaging stages the CLI binary as a sidecar
- Tauri shell → MCP server: ships · Desktop packaging stages the MCP server as a sidecar
