78 lines
3.2 KiB
Markdown
78 lines
3.2 KiB
Markdown
# Journal.App
|
|
|
|
SvelteKit 5 + Tauri 2 desktop application for Project Journal.
|
|
|
|
## Tech Stack
|
|
|
|
- **Frontend**: SvelteKit 5, TypeScript, Vite 6
|
|
- **Tauri shell**: Rust (Tauri 2), `tokio` async runtime
|
|
- **Backend bridge**: `Journal.Sidecar.exe` managed as a persistent long-lived child process
|
|
|
|
## Dev Setup
|
|
|
|
```powershell
|
|
npm install
|
|
npm run dev # SvelteKit dev server at http://localhost:1420
|
|
npm run tauri dev # Tauri desktop window (connects to dev server)
|
|
```
|
|
|
|
## Build Targets
|
|
|
|
| Command | Output | Use case |
|
|
|---------|--------|----------|
|
|
| `npm run build` | `Journal.App/build/` | Web bundle for `Journal.WebGateway` |
|
|
| `.\scripts\publish-app.ps1 -Target web` | `Journal.App/build/` | Same, via script |
|
|
| `.\scripts\publish-app.ps1 -Target tauri -TauriBundles none` | `src-tauri/target/release/journalapp.exe` | Raw desktop exe |
|
|
| `.\scripts\publish-app.ps1 -Target tauri -TauriBundles nsis` | NSIS installer | Packaged installer |
|
|
|
|
## Frontend State Management
|
|
|
|
Svelte stores are the source of truth for all feature state.
|
|
|
|
### Current Stores
|
|
|
|
| Store file | State exports | Notes |
|
|
|-----------|---------------|-------|
|
|
| `src/lib/stores/entries.ts` | `entriesStore` | Entry list, `getDefaultEntry`, `createEntryDraft` |
|
|
| `src/lib/stores/fragments.ts` | `fragmentsStore` | Fragment CRUD + parse/serialize helpers |
|
|
| `src/lib/stores/todos.ts` | `todoListsStore`, `todosStore` | Todo list and item CRUD |
|
|
| `src/lib/stores/lists.ts` | `listsStore` | Generic list CRUD, `createListDraft` |
|
|
| `src/lib/stores/settings.ts` | `settingsTags`, `settingsFragmentTypes` | Tag/type config |
|
|
|
|
### Store-First Rule
|
|
|
|
- Components call **store helper functions** for CRUD operations — not inline mutations.
|
|
- Components should focus on rendering, local form state, and invoking store operations.
|
|
- Backend calls (`sendCommand`) belong inside store/service helpers, not components.
|
|
|
|
## Tauri Commands (Rust → Frontend)
|
|
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `sidecar_command` | Forward a `CommandEnvelope` to `Journal.Sidecar` stdin/stdout and return parsed JSON |
|
|
| `get_sidecar_root` | Get currently resolved sidecar root path |
|
|
| `set_sidecar_root` | Override root path (saved to `settings.json`, restarts sidecar) |
|
|
| `get_ui_settings` | Load tag/fragment-type settings |
|
|
| `set_ui_settings` | Persist tag/fragment-type settings |
|
|
| `shutdown` | Stop sidecar, exit app |
|
|
|
|
## Sidecar Path Resolution
|
|
|
|
The Rust shell looks for `Journal.Sidecar.exe` starting from the auto-detected repository root:
|
|
|
|
1. `<root>/Journal.Sidecar.exe`
|
|
2. `<root>/publish/Journal.Sidecar.exe`
|
|
3. `<root>/Journal.Sidecar/bin/Debug/net10.0/Journal.Sidecar.exe`
|
|
4. `<root>/Journal.Sidecar/bin/Release/net10.0/win-x64/publish/Journal.Sidecar.exe`
|
|
5. Recursive scan of `<root>/Journal.Sidecar/`
|
|
|
|
Build the sidecar before running the Tauri app:
|
|
|
|
```powershell
|
|
.\scripts\publish-sidecar.ps1 -Configuration Release -Runtime win-x64
|
|
```
|
|
|
|
## Recommended IDE Setup
|
|
|
|
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
|