How cactus-compute/cactus works
Project type and purpose
• Cactus is an open-source, multi-platform AI inference framework. At its heart is a high-performance C/C++ library (the “cactus” folder) that implements model loading and inference via GGML backends. Around it are language bindings and plugins for Flutter (Dart), React-Native (TypeScript), native iOS, and Android (JNI). There are also example apps (C++, Flutter, React), documentation, and build scripts.
File structure
• Top-level:
• cactus/ — the C/C++ core library + GGML backends + patches + tools
• cactus-flutter/ — Dart/Flutter plugin (lib/, android/, ios/, ffigen.yaml)
• cactus-react/ — React-Native plugin (src/, android/, ios/, podspec, TS configs)
• cactus-ios/ — prebuilt iOS xcframework target
• examples/ — demo apps for C++, Flutter, React
• docs/ — markdown docs for each platform
• scripts/ — build and packaging scripts (shell)
• Patterns:
• Core library built via CMake → outputs static / shared libs and xcframework/JNILibs
• Language layers use FFI (Dart ffi, React-Native JSI/bridging) to call C++
• Example apps import the plugin packages and invoke APIs
Insights from the README
• Purpose: run LLMs locally on mobile with low overhead
• Components mentioned: CactusContext, CactusCompletionParams, initLlama, common_params
• Dependencies: GGML, CMake, Flutter SDK, React-Native CLI, CocoaPods, Android NDK