# jarvesusaram99/portable-ai-usb architecture

> Architecture diagram of the GitHub repository jarvesusaram99/portable-ai-usb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jarvesusaram99/portable-ai-usb
- Repository: https://github.com/jarvesusaram99/portable-ai-usb

## Overview

1. **What this repo is**
   - This repository is not a full AI application codebase; it is a **portable deployment and orchestration layer** for an offline AI assistant that lives on a USB drive.
   - The architecture centers on bundling a local model runtime, model files, and the AnythingLLM interface so the whole system can move between computers.

2. **Primary runtime components**
   - **AnythingLLM** is the user-facing chat/UI layer.
   - **Ollama** is the local model-serving engine.
   - **GGUF model files** are stored locally in the `models/` directory.
   - The user talks to AnythingLLM, which routes requests to the local runtime rather than a cloud service.

3. **Portable storage boundary**
   - The key architectural boundary is the **USB drive itself**.
   - Persistent application state is meant to stay on the USB:
     - `anythingllm_data/` for chats and settings
     - `models/` for downloaded weights and model metadata
     - `anythingllm/` for the installed interface
     - `ollama/` for the local engine
   - This keeps state off the host machine and is the main portability guarantee.

4. **Install-time flow**
   - Installation is driven by platform wrapper scripts:
     - `install.bat` and `install-core.ps1` on Windows
     - `linux/install.sh` and `linux/install-core.sh` for Linux-side setup logic
   - The installer downloads selected models, sets up the local engine, and prepares AnythingLLM in a USB-relative location.
   - Initial downloads require internet access; after that, the system is intended to run offline.

5. **Model acquisition and management**
   - The repo supports curated model downloads plus a “custom GGUF” path.
   - Model selection happens during install, and files are placed in `models/`.
   - The installer is idempotent in practice: if a model already exists, it is skipped on rerun.
   - The README references HuggingFace as the source for model downloads, which is the main external dependency for acquiring weights.

6. **Startup/runtime flow**
   - Launchers are OS-specific entrypoints:
     - `start-windows.bat`
     - `start-mac.command`
     - `linux/start-linux.sh`
   - At runtime, the launcher starts the local AI stack and opens the AnythingLLM window.
   - The black terminal window is intentionally kept open because it acts as the control process for the local services and safe shutdown.

7. **Windows-specific portability behavior**
   - `start-windows.bat` includes cache-clearing behavior to handle moving the USB between different PCs.
   - This is important because AnythingLLM may otherwise retain host-specific path/cache data and fail on a new machine.
   - The launcher therefore acts as a portability repair layer, not just a process starter.

8. **Linux-specific preflight**
   - Linux has an explicit `preflight-check.sh` before installation/startup.
   - This suggests a validation boundary for environment readiness before the install scripts run.
   - In architecture terms, Linux adds a small health-check stage ahead of the shared install/runtime flow.

9. **Data flow at runtime**
   - User prompt enters **AnythingLLM**.
   - AnythingLLM sends the request to the **local model engine**.
   - The engine loads the chosen **GGUF model** from `models/`.
   - The response returns back to AnythingLLM and is shown in the UI.
   - No cloud API is required in the steady state.

10. **External dependencies that matter architecturally**
    - **AnythingLLM**: UI/orchestration layer the user interacts with.
    - **Ollama**: local inference backend.
    - **HuggingFace**: model distribution source.
    - These are not optional implementation details; they define the system’s major boundaries and startup sequence.

11. **Repository structure as deployment layout**
    - The repo mainly contains:
      - installer wrappers
      - startup wrappers
      - shared install logic
      - platform-specific scripts
    - There is no application source tree here; the repo is effectively a **portable packaging and bootstrap system**.

12. **Operational characteristics**
    - The system is designed for **offline use after setup**, **CPU-based inference**, and **local persistence**.
    - Performance and RAM requirements depend on model size, which affects the practical deployment target but not the software architecture itself.
    - The architecture is best diagrammed as a USB-contained stack: launcher scripts → local engine → local model store → AnythingLLM UI → persistent USB data.

Main entry points: [`install-core.ps1`](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/install-core.ps1) (Core install), [`linux/install-core.sh`](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/install-core.sh) (Linux core), [`start-windows.bat`](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/start-windows.bat) (Windows start), [`linux/install.sh`](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/install.sh) (Linux install)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_usb["USB-contained stack"]
  node_usb[("USB drive<br/>portable boundary")]
  node_anythingllm["AnythingLLM<br/>ui/orchestrator"]
  node_ollama["Ollama<br/>local engine"]
  node_models[("Models<br/>gguf store")]
  node_data[("App data<br/>persistent state")]
  node_anythingllm_install["AnythingLLM install<br/>installed app"]
  node_ollama_install["Ollama install<br/>installed engine"]
end

subgraph group_g_host["Host OS scripts"]
  node_install_bat["Windows install<br/>wrapper script<br/>[install.bat]"]
  node_install_ps1["Core install<br/>shared install logic<br/>[install-core.ps1]"]
  node_linux_install["Linux install<br/>wrapper script<br/>[install.sh]"]
  node_linux_install_core["Linux core<br/>shared install logic<br/>[install-core.sh]"]
  node_preflight["Preflight check<br/>environment check<br/>[preflight-check.sh]"]
  node_start_win["Windows start<br/>launcher script<br/>[start-windows.bat]"]
  node_start_mac["macOS start<br/>launcher script<br/>[start-mac.command]"]
  node_start_linux["Linux start<br/>launcher script<br/>[start-linux.sh]"]
end

node_huggingface(("HuggingFace<br/>model source"))

node_install_bat -->|"delegates"| node_install_ps1
node_linux_install -->|"checks"| node_preflight
node_linux_install -->|"delegates"| node_linux_install_core
node_install_ps1 -->|"prepares"| node_anythingllm_install
node_install_ps1 -->|"prepares"| node_ollama_install
node_install_ps1 -->|"downloads"| node_models
node_linux_install_core -->|"prepares"| node_anythingllm_install
node_linux_install_core -->|"prepares"| node_ollama_install
node_linux_install_core -->|"downloads"| node_models
node_install_ps1 -->|"sources"| node_huggingface
node_linux_install_core -->|"sources"| node_huggingface
node_start_win -->|"starts"| node_anythingllm
node_start_win -->|"starts"| node_ollama
node_start_win -->|"cleans"| node_data
node_start_mac -->|"starts"| node_anythingllm
node_start_mac -->|"starts"| node_ollama
node_start_linux -->|"starts"| node_anythingllm
node_start_linux -->|"starts"| node_ollama
node_anythingllm -->|"routes to"| node_ollama
node_ollama -->|"loads"| node_models
node_anythingllm -->|"persists"| node_data
node_usb -->|"contains"| node_anythingllm_install
node_usb -->|"contains"| node_ollama_install
node_usb -->|"contains"| node_models
node_usb -->|"contains"| node_data

click node_install_bat "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/install.bat"
click node_install_ps1 "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/install-core.ps1"
click node_linux_install "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/install.sh"
click node_linux_install_core "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/install-core.sh"
click node_preflight "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/preflight-check.sh"
click node_start_win "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/start-windows.bat"
click node_start_mac "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/start-mac.command"
click node_start_linux "https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/start-linux.sh"

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_usb,node_anythingllm,node_ollama,node_models,node_data,node_anythingllm_install,node_ollama_install toneBlue
class node_install_bat,node_install_ps1,node_linux_install,node_linux_install_core,node_preflight,node_start_win,node_start_mac,node_start_linux toneAmber
class node_huggingface toneNeutral
```

## Components

### USB-contained stack

Portable state and local runtime that move with the drive.

- **USB drive**: portable boundary · The portability boundary where app state, models, and runtimes are kept.
- **AnythingLLM**: ui/orchestrator · User-facing chat interface and request router for the local assistant.
- **Ollama**: local engine · Local model-serving backend used for offline inference.
- **Models**: gguf store · Local GGUF weights and model metadata stored on the USB drive.
- **App data**: persistent state · Chats, settings, and other AnythingLLM state persisted on the USB drive.
- **AnythingLLM install**: installed app · USB-local AnythingLLM installation prepared by the installer.
- **Ollama install**: installed engine · USB-local Ollama installation prepared by the installer.

### Host OS scripts

Platform-specific wrappers that install, validate, and start the portable stack.

- [Windows install](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/install.bat): wrapper script · Windows entrypoint that drives installation setup on the USB drive. · `install.bat`
- [Core install](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/install-core.ps1): shared install logic · Shared Windows install logic used to prepare the portable stack. · `install-core.ps1`
- [Linux install](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/install.sh): wrapper script · Linux entrypoint that drives installation setup on the USB drive. · `linux/install.sh`
- [Linux core](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/install-core.sh): shared install logic · Shared Linux install logic used to prepare the portable stack. · `linux/install-core.sh`
- [Preflight check](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/preflight-check.sh): environment check · Linux readiness check that runs before install or startup. · `linux/preflight-check.sh`
- [Windows start](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/start-windows.bat): launcher script · Windows launcher that starts the local stack and handles cache cleanup. · `start-windows.bat`
- [macOS start](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/start-mac.command): launcher script · macOS launcher that starts the local stack and opens the interface. · `start-mac.command`
- [Linux start](https://github.com/jarvesusaram99/portable-ai-usb/blob/main/linux/start-linux.sh): launcher script · Linux launcher that starts the local stack and opens the interface. · `linux/start-linux.sh`

### Other components

- **HuggingFace**: model source · External source used to download curated model weights during install.

## Connections

- Windows install → Core install: delegates · Windows wrapper hands off to shared install logic.
- Linux install → Preflight check: checks · Linux install is preceded by an environment readiness check.
- Linux install → Linux core: delegates · Linux wrapper hands off to shared install logic.
- Core install → AnythingLLM install: prepares · Installer lays down the AnythingLLM installation on the USB drive.
- Core install → Ollama install: prepares · Installer lays down the Ollama runtime on the USB drive.
- Core install → Models: downloads · Installer fetches selected models into local storage.
- Linux core → AnythingLLM install: prepares · Linux install logic prepares the USB-local AnythingLLM installation.
- Linux core → Ollama install: prepares · Linux install logic prepares the USB-local Ollama runtime.
- Linux core → Models: downloads · Linux install logic fetches selected models into local storage.
- Core install → HuggingFace: sources · Model acquisition comes from HuggingFace during setup.
- Linux core → HuggingFace: sources · Model acquisition comes from HuggingFace during setup.
- Windows start → AnythingLLM: starts · Windows launcher starts the user-facing assistant.
- Windows start → Ollama: starts · Windows launcher starts the local model engine.
- Windows start → App data: cleans · Windows launcher clears host-specific cache/path state for portability.
- macOS start → AnythingLLM: starts · macOS launcher starts the user-facing assistant.
- macOS start → Ollama: starts · macOS launcher starts the local model engine.
- Linux start → AnythingLLM: starts · Linux launcher starts the user-facing assistant.
- Linux start → Ollama: starts · Linux launcher starts the local model engine.
- AnythingLLM → Ollama: routes to · Chat requests are sent from AnythingLLM to the local backend.
- Ollama → Models: loads · The engine loads the selected GGUF model from local storage.
- AnythingLLM → App data: persists · Chats and settings are stored in USB-local application data.
- USB drive → AnythingLLM install: contains · Installed interface lives on the portable drive.
- USB drive → Ollama install: contains · Installed engine lives on the portable drive.
- USB drive → Models: contains · Model files are kept on the portable drive.
- USB drive → App data: contains · Persistent app state is kept on the portable drive.
