Skip to content

Commit cd9ecac

Browse files
Added CLAUDE.md with project setup and architecture details (#589)
1 parent ed45569 commit cd9ecac

File tree

1 file changed

+200
-0
lines changed

1 file changed

+200
-0
lines changed

CLAUDE.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
MindWork AI Studio is a cross-platform desktop application for interacting with Large Language Models (LLMs). The app uses a hybrid architecture combining a Rust Tauri runtime (for the native desktop shell) with a .NET Blazor Server web application (for the UI and business logic).
8+
9+
**Key Architecture Points:**
10+
- **Runtime:** Rust-based Tauri v1.8 application providing the native window, system integration, and IPC layer
11+
- **App:** .NET 9 Blazor Server application providing the UI and core functionality
12+
- **Communication:** The Rust runtime and .NET app communicate via HTTPS with TLS certificates generated at startup
13+
- **Providers:** Multi-provider architecture supporting OpenAI, Anthropic, Google, Mistral, Perplexity, self-hosted models, and others
14+
- **Plugin System:** Lua-based plugin system for language packs, configuration, and future assistant plugins
15+
16+
## Building and Running
17+
18+
### Prerequisites
19+
- .NET 9 SDK
20+
- Rust toolchain (stable)
21+
- Tauri v1.6.2 CLI: `cargo install --version 1.6.2 tauri-cli`
22+
- Tauri prerequisites (platform-specific dependencies)
23+
- **Note:** Development on Linux is discouraged due to complex Tauri dependencies that vary by distribution
24+
25+
### One-Time Setup
26+
```bash
27+
cd app/Build
28+
dotnet run build
29+
```
30+
This builds the .NET app as a Tauri "sidecar" binary, which is required even for development.
31+
32+
### Development Workflow
33+
Run these commands in separate terminals:
34+
35+
**Terminal 1 - Start Rust runtime:**
36+
```bash
37+
cd runtime
38+
cargo tauri dev --no-watch
39+
```
40+
41+
**Terminal 2 - Start .NET app:**
42+
```bash
43+
cd "app/MindWork AI Studio"
44+
dotnet run
45+
```
46+
47+
The app will start in the Tauri window. Hot reload is supported for .NET code changes.
48+
49+
### Building for Production
50+
```bash
51+
cd app/Build
52+
dotnet run build
53+
```
54+
Creates a release build for the current platform and architecture. Output is in `runtime/target/release/`.
55+
56+
### Running Tests
57+
Currently no automated test suite exists in the repository.
58+
59+
## Architecture Details
60+
61+
### Rust Runtime (`runtime/`)
62+
**Entry point:** `runtime/src/main.rs`
63+
64+
Key modules:
65+
- `app_window.rs` - Tauri window management, updater integration
66+
- `dotnet.rs` - Launches and manages the .NET sidecar process
67+
- `runtime_api.rs` - Rocket-based HTTPS API for .NET ↔ Rust communication
68+
- `certificate.rs` - Generates self-signed TLS certificates for secure IPC
69+
- `secret.rs` - Secure secret storage using OS keyring (Keychain/Credential Manager)
70+
- `clipboard.rs` - Cross-platform clipboard operations
71+
- `file_data.rs` - File processing for RAG (extracts text from PDF, DOCX, XLSX, PPTX, etc.)
72+
- `encryption.rs` - AES-256-CBC encryption for sensitive data
73+
- `pandoc.rs` - Integration with Pandoc for document conversion
74+
- `log.rs` - Logging infrastructure using `flexi_logger`
75+
76+
### .NET App (`app/MindWork AI Studio/`)
77+
**Entry point:** `app/MindWork AI Studio/Program.cs`
78+
79+
Key structure:
80+
- **Program.cs** - Bootstraps Blazor Server, configures Kestrel, initializes encryption and Rust service
81+
- **Provider/** - LLM provider implementations (OpenAI, Anthropic, Google, Mistral, etc.)
82+
- `BaseProvider.cs` - Abstract base for all providers with streaming support
83+
- `IProvider.cs` - Provider interface defining capabilities and streaming methods
84+
- **Chat/** - Chat functionality and message handling
85+
- **Assistants/** - Pre-configured assistants (translation, summarization, coding, etc.)
86+
- `AssistantBase.razor` - Base component for all assistants
87+
- **Agents/** - contains all agents, e.g., for data source selection, context validation, etc.
88+
- `AgentDataSourceSelection.cs` - Selects appropriate data sources for queries
89+
- `AgentRetrievalContextValidation.cs` - Validates retrieved context relevance
90+
- **Tools/PluginSystem/** - Lua-based plugin system
91+
- **Tools/Services/** - Core background services (settings, message bus, data sources, updates)
92+
- **Tools/Rust/** - .NET wrapper for Rust API calls
93+
- **Settings/** - Application settings and data models
94+
- **Components/** - Reusable Blazor components
95+
- **Pages/** - Top-level page components
96+
97+
### IPC Communication Flow
98+
1. Rust runtime starts and generates TLS certificate
99+
2. Rust starts internal HTTPS API on random port
100+
3. Rust launches .NET sidecar, passing: API port, certificate fingerprint, API token, secret key
101+
4. .NET reads environment variables and establishes secure HTTPS connection to Rust
102+
5. .NET requests an app port from Rust, starts Blazor Server on that port
103+
6. Rust opens Tauri webview pointing to localhost:app_port
104+
7. Bi-directional communication: .NET ↔ Rust via HTTPS API
105+
106+
### Configuration and Metadata
107+
- `metadata.txt` - Build metadata (version, build time, component versions) read by both Rust and .NET
108+
- `startup.env` - Development environment variables (generated by build script)
109+
- `.NET project` reads metadata.txt at build time and injects as assembly attributes
110+
111+
## Plugin System
112+
113+
**Location:** `app/MindWork AI Studio/Plugins/`
114+
115+
Plugins are written in Lua and provide:
116+
- **Language plugins** - I18N translations (e.g., German language pack)
117+
- **Configuration plugins** - Enterprise IT configurations for centrally managed providers, settings
118+
- **Future:** Assistant plugins for custom assistants
119+
120+
**Example configuration plugin:** `app/MindWork AI Studio/Plugins/configuration/plugin.lua`
121+
122+
Plugins can configure:
123+
- Self-hosted LLM providers
124+
- Update behavior
125+
- Preview features visibility
126+
- Preselected profiles
127+
- Chat templates
128+
129+
## RAG (Retrieval-Augmented Generation)
130+
131+
RAG integration is currently in development (preview feature). Architecture:
132+
- **External Retrieval Interface (ERI)** - Contract for integrating external data sources
133+
- **Data Sources** - Local files and external data via ERI servers
134+
- **Agents** - AI agents select data sources and validate retrieval quality
135+
- **Embedding providers** - Support for various embedding models
136+
- **Vector database** - Planned integration with Qdrant for vector storage
137+
- **File processing** - Extracts text from PDF, DOCX, XLSX via Rust runtime
138+
139+
## Enterprise IT Support
140+
141+
AI Studio supports centralized configuration for enterprise environments:
142+
- **Registry (Windows)** or **environment variables** (all platforms) specify configuration server URL and ID
143+
- Configuration downloaded as ZIP containing Lua plugin
144+
- Checks for updates every ~16 minutes via ETag
145+
- Allows IT departments to pre-configure providers, settings, and chat templates
146+
147+
**Documentation:** `documentation/Enterprise IT.md`
148+
149+
## Provider Confidence System
150+
151+
Multi-level confidence scheme allows users to control which providers see which data:
152+
- Confidence levels: e.g. `NONE`, `LOW`, `MEDIUM`, `HIGH`, and some more granular levels
153+
- Each assistant/feature can require a minimum confidence level
154+
- Users assign confidence levels to providers based on trust
155+
156+
**Implementation:** `app/MindWork AI Studio/Provider/Confidence.cs`
157+
158+
## Dependencies and Frameworks
159+
160+
**Rust:**
161+
- Tauri 1.8 - Desktop application framework
162+
- Rocket 0.5 - HTTPS API server
163+
- tokio - Async runtime
164+
- keyring - OS keyring integration
165+
- pdfium-render - PDF text extraction
166+
- calamine - Excel file parsing
167+
168+
**.NET:**
169+
- Blazor Server - UI framework
170+
- MudBlazor 8.12 - Component library
171+
- LuaCSharp - Lua scripting engine
172+
- HtmlAgilityPack - HTML parsing
173+
- ReverseMarkdown - HTML to Markdown conversion
174+
175+
## Security
176+
177+
- **Encryption:** AES-256-CBC with PBKDF2 key derivation for sensitive data
178+
- **IPC:** TLS-secured communication with random ports and API tokens
179+
- **Secrets:** OS keyring for persistent secret storage (API keys, etc.)
180+
- **Sandboxing:** Tauri provides OS-level sandboxing
181+
182+
## Release Process
183+
184+
1. Create changelog file: `app/MindWork AI Studio/wwwroot/changelog/vX.Y.Z.md`
185+
2. Commit changelog
186+
3. Run from `app/Build`: `dotnet run release --action <patch|minor|major>`
187+
4. Create PR with version bump and changes
188+
5. After PR merge, maintainer creates git tag: `vX.Y.Z`
189+
6. GitHub Actions builds release binaries for all platforms
190+
7. Binaries uploaded to GitHub Releases
191+
192+
## Important Development Notes
193+
194+
- **File changes require Write/Edit tools** - Never use bash commands like `cat <<EOF` or `echo >`
195+
- **Spaces in paths** - Always quote paths with spaces in bash commands
196+
- **Debug environment** - Reads `startup.env` file with IPC credentials
197+
- **Production environment** - Runtime launches .NET sidecar with environment variables
198+
- **MudBlazor** - Component library requires DI setup in Program.cs
199+
- **Encryption** - Initialized before Rust service is marked ready
200+
- **Message Bus** - Singleton event bus for cross-component communication inside the .NET app

0 commit comments

Comments
 (0)