botui/PROMPT.md

227 lines
5.3 KiB
Markdown
Raw Normal View History

# BotUI Development Prompt Guide
2025-12-03 18:42:22 -03:00
**Version:** 6.1.0
**Purpose:** LLM context for BotUI development
---
## Project Overview
2025-12-03 18:42:22 -03:00
BotUI is a **dual-mode UI application** built in Rust that runs as either a desktop app (Tauri) or web server (Axum). All business logic is in **botserver** - BotUI is purely presentation + HTTP bridge.
### Workspace Position
```
botui/ # THIS PROJECT - Web/Desktop UI
botserver/ # Main server (business logic)
botlib/ # Shared library (consumed here)
botapp/ # Desktop wrapper (consumes botui)
botbook/ # Documentation
```
### What BotUI Provides
- **Web Mode**: Axum server serving HTML/CSS/JS UI on port 3000
- **Desktop Mode**: Tauri native application with same UI
- **HTTP Bridge**: Proxies all requests to botserver
- **Local Assets**: All JS/CSS bundled locally (no CDN)
---
2025-12-03 18:42:22 -03:00
## Quick Start
```bash
# Terminal 1: Start BotServer
cd ../botserver && cargo run
2025-12-03 18:42:22 -03:00
# Terminal 2: Start BotUI (Web Mode)
cd ../botui && cargo run
2025-12-03 18:42:22 -03:00
# Visit http://localhost:3000
# OR Desktop Mode
2025-12-03 18:42:22 -03:00
cargo tauri dev
```
---
## Architecture
2025-12-03 18:42:22 -03:00
### Dual Modes
| Mode | Command | Description |
|------|---------|-------------|
| Web | `cargo run` | Axum server on port 3000 |
| Desktop | `cargo tauri dev` | Tauri native window |
2025-12-03 18:42:22 -03:00
### Code Organization
```
src/
├── main.rs # Entry point - mode detection
├── lib.rs # Feature-gated module exports
├── http_client.rs # HTTP wrapper for botserver (web-only)
2025-12-03 18:42:22 -03:00
├── ui_server/
│ └── mod.rs # Axum router + UI serving (web-only)
2025-12-03 18:42:22 -03:00
├── desktop/
│ ├── mod.rs # Desktop module organization
│ ├── drive.rs # File operations via Tauri
│ ├── tray.rs # System tray infrastructure
│ └── stream.rs # Streaming operations
2025-12-03 18:42:22 -03:00
└── shared/
└── state.rs # Shared application state
ui/
├── suite/ # Main UI (HTML/CSS/JS)
│ ├── js/vendor/ # Local JS libraries (htmx, marked, etc.)
│ └── css/ # Stylesheets
└── minimal/ # Minimal chat UI
└── js/vendor/ # Local JS libraries
2025-12-03 18:42:22 -03:00
```
---
2025-12-03 18:42:22 -03:00
## Feature Gating
2025-12-03 18:42:22 -03:00
```rust
#[cfg(feature = "desktop")] // Desktop build only
2025-12-03 18:42:22 -03:00
pub mod desktop;
#[cfg(not(feature = "desktop"))] // Web build only
2025-12-03 18:42:22 -03:00
pub mod http_client;
```
Build commands:
```bash
cargo build # Web mode (default)
cargo build --features desktop # Desktop mode
cargo tauri build # Optimized desktop build
2025-12-03 18:42:22 -03:00
```
---
2025-12-03 18:42:22 -03:00
## Code Generation Rules
2025-12-03 18:42:22 -03:00
### CRITICAL REQUIREMENTS
2025-12-03 18:42:22 -03:00
```
- BotUI = Presentation + HTTP bridge ONLY
- All business logic goes in botserver
- No code duplication between layers
- Feature gates eliminate unused code paths
- Zero warnings - feature gating prevents dead code
- All JS/CSS must be local (no CDN)
2025-12-03 18:42:22 -03:00
```
### Key Principles
2025-12-03 18:42:22 -03:00
1. **Minimize Code** - Only presentation and HTTP bridging
2. **Feature Gating** - Desktop code doesn't compile in web mode
3. **HTTP Communication** - All botserver calls through BotServerClient
4. **Local Assets** - All vendor JS in ui/*/js/vendor/
2025-12-03 18:42:22 -03:00
---
2025-12-03 18:42:22 -03:00
## Local JS/CSS Vendor Files
2025-12-03 18:42:22 -03:00
All external libraries are bundled locally:
2025-12-03 18:42:22 -03:00
```
ui/suite/js/vendor/
├── htmx.min.js # HTMX 1.9.10
├── htmx-ws.js # HTMX WebSocket extension
├── htmx-json-enc.js # HTMX JSON encoding
├── marked.min.js # Markdown parser
├── gsap.min.js # Animation library
├── alpinejs.min.js # Alpine.js reactivity
└── livekit-client.umd.min.js # LiveKit video
2025-12-03 18:42:22 -03:00
```
**NEVER use CDN URLs** - always reference local vendor files:
```html
<!-- CORRECT -->
<script src="js/vendor/htmx.min.js"></script>
2025-12-03 18:42:22 -03:00
<!-- WRONG - DO NOT USE -->
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
2025-12-03 18:42:22 -03:00
```
---
2025-12-03 18:42:22 -03:00
## HTTP Client
2025-12-03 18:42:22 -03:00
```rust
pub struct BotServerClient {
client: Arc<Client>,
base_url: String,
}
2025-12-03 18:42:22 -03:00
impl BotServerClient {
pub async fn get<T: Deserialize>(&self, endpoint: &str) -> Result<T, String>
pub async fn post<T, R>(&self, endpoint: &str, body: &T) -> Result<R, String>
pub async fn health_check(&self) -> bool
}
2025-12-03 18:42:22 -03:00
```
---
2025-12-03 18:42:22 -03:00
## Adding Features
### Process
2025-12-03 18:42:22 -03:00
1. Add business logic to **botserver** first
2. Create REST API endpoint in botserver
3. Add HTTP wrapper in BotUI
2025-12-03 18:42:22 -03:00
4. Add UI in `ui/suite/`
5. For desktop-specific: Add Tauri command in `src/desktop/`
2025-12-03 18:42:22 -03:00
### Desktop Tauri Command
2025-12-03 18:42:22 -03:00
```rust
#[tauri::command]
pub fn list_files(path: &str) -> Result<Vec<FileItem>, String> {
// Implementation
2025-12-03 18:42:22 -03:00
}
```
---
2025-12-03 18:42:22 -03:00
## Environment Variables
2025-12-03 18:42:22 -03:00
```bash
BOTSERVER_URL=http://localhost:8081 # BotServer location
RUST_LOG=debug # Logging level
2025-12-03 18:42:22 -03:00
```
---
2025-12-03 18:42:22 -03:00
## Dependencies
2025-12-03 18:42:22 -03:00
| Library | Version | Purpose |
|---------|---------|---------|
| axum | 0.7.5 | Web framework |
| reqwest | 0.12 | HTTP client |
| tokio | 1.41 | Async runtime |
| askama | 0.12 | Templates |
| diesel | 2.1 | Database (sqlite) |
2025-12-03 18:42:22 -03:00
---
2025-12-03 18:42:22 -03:00
## Testing
2025-12-03 18:42:22 -03:00
```bash
cargo build # Web mode
cargo build --features desktop # Desktop mode
cargo test
cargo run # Start web server
cargo tauri dev # Start desktop app
```
2025-12-03 18:42:22 -03:00
---
## Rules
- **No business logic** - only presentation
- **No CDN** - all assets local
- **Feature gate** - unused code never compiles
- **Zero warnings** - clean compilation
- **HTTP bridge** - all data from botserver