Developer Documentation for YUMLABS â
Version: 2.1 Last Updated: 2025-10-04
Table of Contents â
- Project Overview
- Architecture
- Design System
- Modules Breakdown
- Dependencies
- Configuration
- Development Guide
Project Overview â
YUMLABS is a professional Rust-based GUI application built with the Iced framework. It serves as a multi-purpose assistant with LLM integration, todo management, and stock market tracking.
Key Features â
- LLM Integration - Query Perplexity and Gemini APIs
- Todo Management - Create, complete, and delete tasks (MongoDB: yumlabs.todos)
- Finance Tracking - Real-time stock market data with AI analysis (MongoDB: yumlabs.finance_data)
- Tools Dashboard - Quick access to external services
- Professional UI - Modern, streamlined design system
Technical Stack â
- Rust 2021 - Systems programming language
- Iced 0.13 - GUI framework with Tokio async
- Reqwest - HTTP client for API calls
- MongoDB - Consolidated database 'yumlabs' for todos, finance, and LLM data
- Serde - JSON serialization
- Arboard - Clipboard operations
- Dotenv - Environment configuration
Window Configuration â
- Size: 300x550 pixels
- Position: Bottom-right corner (1920x1080 screens)
- Style: Transparent, always-on-top, no decorations
- Focus: Query input focused on startup
Architecture â
MVC-Inspired Structure â
src/
âââ main.rs # Entry point, window setup
âââ models.rs # State management, message types
âââ update/ # Business logic
â âââ mod.rs # Message router
â âââ llm_updater.rs # LLM logic
â âââ todo_updater.rs # Todo logic
â âââ finance_updater.rs # Finance logic
âââ view/ # UI rendering
â âââ mod.rs # View router
â âââ llm_view.rs # LLM interface
â âââ todo_view.rs # Todo list
â âââ finance_view.rs # Stock market
â âââ tools_view.rs # Tools dashboard
â âââ components.rs # Reusable components
âââ colors.rs # Color palette (15 colors)
âââ theme.rs # Component styles (6 functions)
âââ api.rs # LLM API integration
âââ finance.rs # Finance API integration
âââ todo.rs # Todo database models
âââ mongo_connection.rs # MongoDB connection
âââ icons.rs # Icon loading
âââ constants.rs # App constantsKey Principles â
- Modular - Clear separation of concerns
- Async - Tokio for non-blocking operations
- Immutable - State updates via messages
- Typed - Strong type safety with Result types
- Declarative - UI built with Iced widgets
Design System â
Philosophy â
The YUMLABS design system emphasizes simplicity, consistency, and purpose. Every color and component has a clear reason for existing.
Color Palette (15 Colors) â
Core Colors (3) â
PRIMARY: #4285F4 // Professional blue - interactive elements, focus, scrollbars
SUCCESS: #34BB72 // Green - positive values, stock gains
ERROR: #F2434F // Red - negative values, stock lossesNeutral Colors (3) â
BACKGROUND: #171A21 // Main app background (96% opacity)
SURFACE: #212730 // Cards, buttons (95% opacity)
SURFACE_ELEVATED: #292E3A // Tooltips, hover states (97% opacity)Text Colors (3) â
TEXT_PRIMARY: #F2F4F7 // Main content (high emphasis)
TEXT_SECONDARY: #B5BCC7 // Labels (medium emphasis)
TEXT_MUTED: #949DAD // Placeholders (low emphasis)Border Colors (3) â
BORDER: #404857 // Default borders
BORDER_FOCUS: #4285F4 // Focused elements (primary blue)
BORDER_HOVER: #595C6C // Hovered elementsComponent-Specific (3) â
PANEL_SHADOW: rgba(0,0,0,0.65) // Main panel shadow
BUTTON_SHADOW: rgba(0,0,0,0.35) // Button shadows
INPUT_BG: #1A1C23 // Input backgrounds
SELECTION: rgba(#4285F4,0.25) // Text selection
SCROLLER_BG: #1C1D28 // Scrollable backgroundsTypography â
20px - Main titles (TEXT_PRIMARY)
16px - Section headers (TEXT_PRIMARY)
14px - Body text (TEXT_PRIMARY)
13px - Labels (TEXT_SECONDARY)
12px - Metadata (TEXT_SECONDARY)
10px - Fine print (TEXT_MUTED)Spacing System â
8px - Extra small (compact elements)
12px - Small (buttons, inputs)
16px - Medium (cards)
24px - Large (view padding)Component Library (6 Functions) â
1. panel() â
Main application container
container(content).style(theme::panel())2. panel_button() â
Universal button with three states (default, hover, pressed)
button(content).padding(12).style(theme::panel_button())3. input() â
Text input with focus effects
text_input("Placeholder", &value).padding(12).style(theme::input())4. picker() & picker_menu() â
Dropdown selection
pick_list(options, selected, on_select)
.style(theme::picker())
.menu_style(theme::picker_menu())5. scroller() â
Scrollable container with custom scrollbar
scrollable(content).style(theme::scroller())6. tooltip() â
Tooltip with elevated appearance
tooltip(element, "Text", Position::Bottom).style(theme::tooltip())Design Patterns â
View Layout â
column![
row![back_button].align_y(Alignment::Center),
text("Title").size(20).style(|_| text::Style {
color: Some(crate::colors::TEXT_PRIMARY),
}),
// content...
]
.spacing(18)
.padding(24)Button Group â
row![btn1, btn2, btn3]
.spacing(12)
.align_y(Alignment::Center)Form Field â
column![
text("Label").size(13).style(|_| text::Style {
color: Some(crate::colors::TEXT_SECONDARY),
}),
text_input("Placeholder", &value).padding(12).style(theme::input())
]
.spacing(8)Modules Breakdown â
main.rs â
Entry point (src/main.rs). Sets up the Iced application with window settings and initial state.
- Imports:
iced::window::{self, Level, Position},iced::{Task, Point}, and local modules. - main(): Creates default
LlmWidgetstate, configures window (size 300x550, position bottom-right, always-on-top, no decorations, transparent), runs app with initial task to focus the query input field. - Purpose: Bootstraps the GUI loop; sets up initial focus for user convenience.
models.rs â
Core data models (src/models.rs). Defines state, enums, and messages for the app.
AppStateStruct: The single source of truth for the application. It holds thecurrent_viewand instances of view-specific states likeLlmStateandTodoState. It also contains global fields likeis_loadinganderror.- View-Specific States: Structs like
LlmStateandTodoStatehold data relevant only to their corresponding views. MessageEnum: A nested enum structure. The top-levelMessagehandles global events and navigation, while sub-enums likeLlmMessageandTodoMessagecontain actions specific to a view.- Purpose: To create a modular and scalable state management system where state and logic are co-located by feature.
update.rs â
The update module is responsible for all state mutations.
update/mod.rs: The main entry point. Theupdatefunction acts as a router, delegating messages to the appropriate sub-updater based on the message variant (e.g.,Message::Llmgoes tollm_updater).update/llm_updater.rs,update/todo_updater.rs: Each file handles the logic for its specific part of the state. They receive the relevantMessagevariant and a mutable reference to the mainAppState.- Purpose: To break down the application logic into manageable, feature-specific chunks, improving readability and maintainability.
view.rs â
The view module is responsible for UI rendering.
view/mod.rs: The main entry point. Contains the top-levelviewfunction that acts as a router, selecting which sub-view to render based on the application's current state (LlmWidget.current_view).view/llm_view.rs,view/todo_view.rs, etc.: Each file is responsible for building a specific screen of the application. They contain the layout logic and widget definitions for their respective views.view/components.rs: Contains reusable UI components, such ascreate_buttonandbuild_error_display, that are shared across multiple views.- Purpose: To create a modular and maintainable UI layer by separating the concerns of each view.
colors.rs â
Professional color palette (src/colors.rs). Defines a streamlined, focused color system.
- Primary Color: PRIMARY (#4285F4) - Professional blue for interactive elements
- Status Colors: SUCCESS (#34BB72) green, ERROR (#F2434F) red
- Neutral Colors: BACKGROUND, SURFACE, SURFACE_ELEVATED - Dark theme layers
- Text Colors: TEXT_PRIMARY, TEXT_SECONDARY, TEXT_MUTED - Clear hierarchy
- Border Colors: BORDER, BORDER_FOCUS, BORDER_HOVER - Interactive states
- Component Colors: PANEL_SHADOW, BUTTON_SHADOW, INPUT_BG, SELECTION, SCROLLER_BG
- Purpose: Minimal, essential color palette for consistency and maintainability
theme.rs â
Professional component styling (src/theme.rs). Defines style functions for all UI components.
- panel(): Main application container with background, border, shadow
- panel_button(): Universal button style with three states (default, hover, pressed)
- Default: Surface background, border, subtle shadow
- Hover: Elevated surface, enhanced border, larger shadow
- Pressed: Primary border, reduced shadow
- input(): Text input with focus ring and hover states
- picker(): Pick list styled with hover feedback
- picker_menu(): Dropdown menu with elevated appearance
- scroller(): Scrollable container with custom scrollbar (primary blue thumb)
- tooltip(): Elevated tooltip with shadow
- Purpose: Consistent, professional theming across all components
api.rs â
API interaction (src/api.rs). Handles async LLM queries.
- Imports: Serde, dotenv, std::env.
- get_api_key() (lines 7-22): Loads dotenv, checks env for PERPLEXITY_API_KEY or GEMINI_API_KEY.
- Structs: ChatCompletionRequest/MessageReq (Perplexity), ChatCompletionResponse/Choice/MessageResp (Perplexity response); GeminiRequest/Content/Part (Gemini), GeminiResponse/Candidate/ContentResp/PartResp (Gemini response).
- fetch_llm_response() (lines 86-173): Async fn taking query, provider, model.
- Loads dotenv, creates reqwest client.
- Match provider:
- Perplexity: Gets API key, builds ChatCompletionRequest, POST to api.perplexity.ai, parses response.
- Gemini: Gets API key, builds GeminiRequest, POST to generativelanguage.googleapis.com with model, parses response.
- Returns Result<String, String> with content or error.
- Purpose: Encapsulates HTTP logic; error handling for keys, requests, parsing.
Dependencies â
From Cargo.toml:
- iced 0.13 (tokio feature): GUI framework.
- reqwest 0.12 (json): HTTP client.
- serde 1.0 (derive): Serialization.
- arboard 3.4.0: Clipboard.
- tokio 1 (full): Async runtime.
- dotenv 0.15.0: Env loading.
Configuration â
- API keys: Set PERPLEXITY_API_KEY and GEMINI_API_KEY in .env file.
- Build:
cargo build. - Run:
cargo run(loads .env automatically). - Development: Install cargo-watch with
cargo install cargo-watch, then usecargo watch -x runfor auto-rebuild and run on file changes. - No linting specified; use
cargo clippyfor checks.
Development Guide â
Getting Started â
Clone and Setup
bashgit clone <repository> cd yumlabsConfigure Environment Create
.envfile:PERPLEXITY_API_KEY=your_key_here GEMINI_API_KEY=your_key_here MONGODB_URI=your_mongodb_uriBuild and Run
bashcargo build cargo runDevelopment Mode
bashcargo install cargo-watch cargo watch -x run
Code Patterns â
Async Operations â
// In update.rs
Task::perform(
async move {
api::fetch_llm_response(query, provider, model).await
},
|result| Message::Llm(LlmMessage::ResponseReceived(result))
)Error Handling â
match result {
Ok(data) => {
state.data = Some(data);
state.error.clear();
}
Err(e) => {
state.error = format!("Error: {}", e);
}
}State Updates â
// Immutable updates via messages
pub fn update(state: &mut AppState, message: Message) -> Task<Message> {
match message {
Message::Llm(msg) => llm_updater::update(state, msg),
Message::Todo(msg) => todo_updater::update(state, msg),
// ...
}
}Best Practices â
Colors â
â
Use PRIMARY for interactive elements â
Use SUCCESS for positive values â
Use ERROR for negative values â
Use TEXT_PRIMARY for main content â Don't use hardcoded RGB values â Don't create custom colors
Components â
â
Use panel_button() for ALL buttons â
Apply consistent padding (12px buttons, 16px cards, 24px views) â
Use theme functions for styling â Don't create custom button styles â Don't skip hover/focus states
Spacing â
â Use 8, 12, 16, 24px values â 18px for section spacing â 24px for view padding â Don't use arbitrary values
Testing â
cargo test
cargo clippy # Linting
cargo fmt # FormattingDatabase Migration (2025-10-04) â
The application previously used separate MongoDB databases: finance_db, llm_db, and todo_db. These have been consolidated into a single database named yumlabs with the following collections:
todos(from todo_db)finance_data(from finance_db)llm_responses(from llm_db)
If migrating from older versions, use mongodump and mongorestore to consolidate data. Ensure your MONGODB_URI in .env points to the correct MongoDB instance.
Common Tasks â
Adding a New View â
- Create
src/view/new_view.rs - Add view enum variant in
models.rs - Add message enum variant in
models.rs - Create updater in
src/update/new_updater.rs - Wire up in
view/mod.rsandupdate/mod.rs - Use
panel_button()and follow spacing system
Adding a New Color â
â ī¸ Think twice! The palette is intentionally minimal.
- Add to
src/colors.rswith clear purpose - Document usage in this file
- Update design system section
Styling a Component â
// Use existing theme functions
button(content).style(theme::panel_button())
text_input(placeholder, value).style(theme::input())
// For custom containers
container(content).style(|_| container::Style {
background: Some(Background::Color(crate::colors::SURFACE)),
border: Border {
color: crate::colors::BORDER,
width: 1.0,
radius: 12.0.into(),
},
..Default::default()
})Troubleshooting â
Build Errors
- Check Rust version:
rustc --version(need 2021 edition) - Update dependencies:
cargo update - Clean build:
cargo clean && cargo build
API Errors
- Verify
.envfile exists and has correct keys - Check API key validity
- Review error messages in UI
MongoDB Errors
- Verify MongoDB is running
- Check connection string in
.env - Ensure 'yumlabs' database exists and has proper permissions
- Confirm collections: todos, finance_data, llm_responses
Code Navigation Tips â
- Start with
models.rs- Understand state structure - Follow message flow - View â Message â Update â Task
- Check theme -
colors.rsandtheme.rsfor styling - Review views -
src/view/for UI patterns - API integration -
api.rsandfinance.rsfor external calls
File References â
- State:
src/models.rs - Logic:
src/update/*.rs - UI:
src/view/*.rs - Styling:
src/colors.rs,src/theme.rs - APIs:
src/api.rs,src/finance.rs - Database:
src/todo.rs,src/mongo_connection.rs
Additional Documentation â
- Finance Feature: See
finance-implementation.mdfor stock market feature details - Proposed Features: See
proposed.mdfor future enhancements - Workflow: See
workflow.mdfor development workflow
Last Updated: 2025-10-04 Version: 2.1 Maintainer: YUMLABS Team