Skip to content

Rapitzo/OfflineOS

Repository files navigation

OfflineOS

Mobile-first offline knowledge + local AI for your phone

Download knowledge packs. Ask questions. Get answers with citations. No internet required.

License: MIT Platform Expo SDK TypeScript PRs Welcome


OfflineOS is a React Native app that runs large language models entirely on your device. Download knowledge packs covering survival, first aid, cooking, and more, then ask questions and get cited answers — all without an internet connection.

Inspired by Project NOMAD, the offline survival computer for desktop. OfflineOS brings this concept to mobile with on-device AI and a retrieval-augmented generation pipeline.

Screenshots

Screenshots coming soon. The app includes four main screens: a Home dashboard, a Library browser, an AI Chat interface with streaming responses, and a Settings screen for model management.

Features

  • On-device LLM inference — Run Phi-3, Gemma 2, Qwen 2.5, Llama 3.2, or SmolLM2 locally via llama.cpp
  • Knowledge packs — Downloadable content bundles with markdown articles and full-text search indexes
  • RAG pipeline — Questions are matched against knowledge packs via FTS5, top results are injected as context, and the LLM generates answers with source citations
  • Dynamic model catalog — Fetches the latest GGUF models from HuggingFace at runtime
  • 14 bundled articles — Survival Essentials and First Aid packs loaded on first launch
  • Offline-first — Everything works without internet after initial setup
  • Dark mode — Full dark and light theme support

Architecture

User question
  |
  v
FTS5 full-text search across installed knowledge packs
  |
  v
Top 5 article chunks selected as RAG context
  |
  v
llama.rn on-device inference (llama.cpp backend)
  |
  v
Streaming tokens rendered in chat UI
  |
  v
Source citations displayed with links to original articles

Tech Stack

Layer Technology
Framework React Native (Expo SDK 55)
Routing expo-router (file-based)
Database expo-sqlite with FTS5 full-text search
LLM Runtime llama.rn (llama.cpp bindings)
State Zustand
Language TypeScript

Getting Started

Quick Start (Expo Go)

Expo Go does not support native modules, so LLM inference will be unavailable. Use this mode for UI development and content browsing.

git clone https://github.com/Rapitzo/OfflineOS.git
cd OfflineOS
npm install
npx expo start

Full Build (with LLM support)

A development build is required for on-device AI. This compiles the native llama.cpp bindings.

git clone https://github.com/Rapitzo/OfflineOS.git
cd OfflineOS
npm install

# Android
npx expo prebuild --platform android
npx expo run:android

# iOS
npx expo prebuild --platform ios
npx expo run:ios

Requirements

  • Node.js 18+
  • For Android builds: Android Studio with NDK installed
  • For iOS builds: Xcode 15+ and CocoaPods

Project Structure

app/                  # Expo Router screens (at repo root, per expo-router convention)
├── (tabs)/           # Home, Library, Chat, Settings
├── reader/[id].tsx   # Article reader
├── pack/[id].tsx     # Pack detail view
├── onboarding.tsx
└── _layout.tsx

src/
├── services/         # Core business logic
│   ├── DatabaseService.ts
│   ├── LLMService.ts
│   ├── PackManagerService.ts
│   ├── PackDownloadService.ts
│   ├── BundledPackLoader.ts
│   ├── ContentIndexService.ts
│   ├── ChunkIndexService.ts
│   ├── ModelCatalogService.ts
│   ├── ModelDownloadService.ts
│   └── StorageService.ts
├── stores/           # Zustand state management
├── hooks/            # useLLM, useContentSearch
├── types/            # TypeScript type definitions
├── config/           # Constants and model configs
└── data/             # Embedded article content

assets/packs/         # Bundled knowledge packs (loaded on first launch)
dist/packs/           # Downloadable pack JSON files (served from this repo)
scripts/              # Pack build tooling

Knowledge Pack Format

Packs are ZIP archives with the following structure:

my-pack.zip
├── manifest.json          # Pack metadata (id, name, version, description)
├── content/
│   └── articles/
│       ├── article-one.md
│       └── article-two.md
├── embeddings/
│   └── chunks.json        # Pre-chunked text for RAG context
└── index/
    └── fts-seed.sql       # FTS5 search index seed data

Build a pack from a directory of markdown files:

npx ts-node scripts/build-pack.ts --input ./my-articles --output ./dist/my-pack

Roadmap

  • Phase 1: Foundation — Expo scaffold, SQLite, services, tab navigation
  • Phase 2: On-device AI — llama.rn integration, streaming inference, model downloads
  • Phase 3: RAG pipeline — FTS5 search, context injection, source citations
  • Phase 4: Pack store — Dynamic model catalog, article browsing, reader view
  • Phase 5: Offline maps — MapLibre GL + PMTiles for fully offline mapping
  • Phase 6: Polish — Onboarding flow, bookmarks, EAS builds, app store release

Contributing

Contributions are welcome. Here are some high-impact areas:

  • Knowledge packs — Write markdown articles on any topic, then build them into packs using the build script
  • Markdown rendering — Improve the article reader with better formatting and syntax highlighting
  • Semantic search — Integrate an on-device embedding model to replace keyword-based FTS5 search
  • Offline maps — Help integrate MapLibre GL with PMTiles for offline map support
  • iOS testing — Test and optimize performance on iOS devices

To contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes
  4. Push to the branch and open a pull request

License

This project is licensed under the MIT License. See LICENSE for details.

About

Mobile-first offline AI: downloadable knowledge packs, on-device llama.cpp inference, RAG search. React Native + Expo.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors