2026-03-13 12:34:29 +00:00
|
|
|
|
# Story Kit
|
2025-12-24 16:29:33 +00:00
|
|
|
|
|
2026-02-13 12:31:36 +00:00
|
|
|
|
This app runs as a single Rust web server binary that serves the Vite/React frontend and exposes APIs.
|
|
|
|
|
|
The frontend lives in the `frontend/` directory.
|
2025-12-24 16:29:33 +00:00
|
|
|
|
|
2026-02-16 17:05:09 +00:00
|
|
|
|
You can also run the frontend and backend separately in development (Vite dev server + Rust API).
|
|
|
|
|
|
|
2026-02-16 16:02:30 +00:00
|
|
|
|
## Running it in development
|
2026-02-06 16:28:50 +00:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-02-13 12:31:36 +00:00
|
|
|
|
# Build the frontend
|
|
|
|
|
|
cd frontend
|
2026-02-16 17:05:09 +00:00
|
|
|
|
pnpm install
|
|
|
|
|
|
pnpm dev
|
2026-02-13 12:31:36 +00:00
|
|
|
|
|
|
|
|
|
|
# Run the server (serves embedded frontend/dist/)
|
2026-02-16 16:02:30 +00:00
|
|
|
|
cargo run
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-02-16 17:05:09 +00:00
|
|
|
|
## Production
|
2026-02-16 16:02:30 +00:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-02-16 17:05:09 +00:00
|
|
|
|
# Build the release binary (also builds the frontend via build.rs)
|
|
|
|
|
|
cargo build --release
|
2026-02-16 16:02:30 +00:00
|
|
|
|
|
|
|
|
|
|
# Run the server (serves embedded frontend/dist/)
|
2026-03-13 12:52:56 +00:00
|
|
|
|
./target/release/story-kit
|
2026-02-06 16:28:50 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-02-20 17:13:59 +00:00
|
|
|
|
## Cross-Platform Distribution
|
|
|
|
|
|
|
|
|
|
|
|
Story Kit ships as a **single self-contained binary** with the React frontend embedded via
|
|
|
|
|
|
`rust-embed`. No Rust toolchain, Node.js, or extra libraries are required on the target machine.
|
|
|
|
|
|
|
|
|
|
|
|
### macOS
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# Native build – no extra tools required beyond Rust + pnpm
|
|
|
|
|
|
make build-macos
|
2026-03-13 12:52:56 +00:00
|
|
|
|
# Output: target/release/story-kit
|
2026-02-20 17:13:59 +00:00
|
|
|
|
|
|
|
|
|
|
# Verify only system frameworks are linked (Security.framework, libSystem.B.dylib, etc.)
|
2026-03-13 12:52:56 +00:00
|
|
|
|
otool -L target/release/story-kit
|
2026-02-20 17:13:59 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Linux (static x86_64, zero dynamic deps)
|
|
|
|
|
|
|
|
|
|
|
|
The Linux build uses the `x86_64-unknown-linux-musl` target to produce a fully static binary.
|
|
|
|
|
|
|
|
|
|
|
|
**Prerequisites:**
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# Install cross – a Rust cross-compilation tool backed by Docker
|
|
|
|
|
|
cargo install cross
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure Docker Desktop (or Docker Engine) is running
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
**Build:**
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
make build-linux
|
2026-03-13 12:52:56 +00:00
|
|
|
|
# Output: target/x86_64-unknown-linux-musl/release/story-kit
|
2026-02-20 17:13:59 +00:00
|
|
|
|
|
|
|
|
|
|
# Verify the binary is statically linked
|
2026-03-13 12:52:56 +00:00
|
|
|
|
file target/x86_64-unknown-linux-musl/release/story-kit
|
2026-02-20 17:13:59 +00:00
|
|
|
|
# Expected: ELF 64-bit LSB executable, x86-64, statically linked
|
|
|
|
|
|
|
2026-03-13 12:52:56 +00:00
|
|
|
|
ldd target/x86_64-unknown-linux-musl/release/story-kit
|
2026-02-20 17:13:59 +00:00
|
|
|
|
# Expected: not a dynamic executable
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
**Running on any Linux x86_64 machine:**
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# No Rust, Node, glibc, or any other library needed – just copy and run
|
2026-03-13 12:52:56 +00:00
|
|
|
|
./story-kit
|
2026-02-20 17:13:59 +00:00
|
|
|
|
```
|
2026-02-06 16:28:50 +00:00
|
|
|
|
|
2026-01-27 14:45:28 +00:00
|
|
|
|
## Testing
|
2025-12-24 16:29:33 +00:00
|
|
|
|
|
2026-02-19 12:58:40 +00:00
|
|
|
|
### Frontend Tests
|
|
|
|
|
|
|
|
|
|
|
|
The frontend uses **Vitest** for unit tests and **Playwright** for end-to-end tests.
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cd frontend
|
|
|
|
|
|
|
|
|
|
|
|
# Run unit tests
|
|
|
|
|
|
pnpm test
|
|
|
|
|
|
|
|
|
|
|
|
# Run end-to-end tests
|
|
|
|
|
|
pnpm test:e2e
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Backend Tests
|
|
|
|
|
|
|
2026-01-27 14:45:28 +00:00
|
|
|
|
This project uses **nextest** for running tests and **cargo-llvm-cov** for code coverage.
|
|
|
|
|
|
|
|
|
|
|
|
### Install Tools
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cargo install cargo-nextest cargo-llvm-cov
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Run Tests
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# Run all tests
|
|
|
|
|
|
cargo nextest run
|
|
|
|
|
|
|
|
|
|
|
|
# Run specific module
|
|
|
|
|
|
cargo nextest run search_files
|
|
|
|
|
|
|
|
|
|
|
|
# Run with verbose output
|
|
|
|
|
|
cargo nextest run --no-capture
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Generate Coverage
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# HTML report (opens in browser)
|
|
|
|
|
|
cargo llvm-cov nextest --html --open
|
|
|
|
|
|
|
|
|
|
|
|
# Terminal output
|
|
|
|
|
|
cargo llvm-cov nextest
|
|
|
|
|
|
|
|
|
|
|
|
# LCOV format (for CI)
|
|
|
|
|
|
cargo llvm-cov nextest --lcov --output-path lcov.info
|
|
|
|
|
|
|
|
|
|
|
|
# Clean coverage data
|
|
|
|
|
|
cargo llvm-cov clean
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Configuration
|
|
|
|
|
|
|
|
|
|
|
|
- **Nextest config**: `.config/nextest.toml`
|
|
|
|
|
|
- **Coverage output**: `target/llvm-cov/html/index.html`
|
|
|
|
|
|
|
|
|
|
|
|
## Current Coverage (search_files module)
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
Module: commands/search.rs
|
|
|
|
|
|
├── Region Coverage: 75.36%
|
|
|
|
|
|
├── Function Coverage: 69.05%
|
|
|
|
|
|
└── Line Coverage: 72.55%
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Available Test Profiles
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# Development (default)
|
|
|
|
|
|
cargo nextest run
|
|
|
|
|
|
|
|
|
|
|
|
# CI with retries
|
|
|
|
|
|
cargo nextest run --profile ci
|
|
|
|
|
|
|
|
|
|
|
|
# Coverage optimized
|
|
|
|
|
|
cargo nextest run --profile coverage
|
|
|
|
|
|
```
|