System Architecture Overview

System Architecture Overview

The Hikari framework adopts a modular design, consisting of multiple independent packages, each responsible for specific functional domains.

Core Systems

1. Palette System (hikari-palette)

Color catalog and themed-palette foundation for the design system.

Responsibilities:

  • Provides 660+ curated color definitions across collections
  • Theme palette management
  • Utility class generator
  • Opacity and color blending

Core Features:

rust
1
2
3
4
5
6
7
8
9
10
11
12
use hikari_palette::{Color, opacity};

// Use palette colors
let red = Color::Cinnabar;
let blue = Color::Azurite;

// Opacity handling
let semi_red = opacity(red, 0.5);

// Theme system
let theme = Hikari::default();
println!("Primary: {}", theme.primary.hex());

Design Philosophy:

  • Rich Metadata: Named colors with historical context
  • Type Safety: Compile-time color value checking
  • High Performance: Zero-cost abstractions

2. Theme System (hikari-theme)

Theme context and style injection system.

Responsibilities:

  • Theme provider component
  • Theme context management
  • CSS variable generation
  • Theme switching

Core Features:

rust
1
2
3
4
5
6
7
8
use hikari_theme::ThemeProvider;

rsx! {
    ThemeProvider { initial_palette: "hikari" } {
        // Application content
        App {}
    }
}

Supported Themes:

  • Hikari (Light) - Light theme
    • Primary: Pink (#FFB3A7)
    • Secondary: Dark Green (#519A73)
    • Accent: Turmeric (#FFC773)
  • Tairitsu - Dark theme
    • Primary: Duck Blue (#144A74)
    • Secondary: Dark Green (#519A73)
    • Accent: Turmeric (#FFC773)

3. Animation System (hikari-animation)

High-performance declarative animation system.

Responsibilities:

  • Animation builder
  • Animation context
  • Easing functions
  • Preset animations

Core Features:

rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use hikari_animation::{AnimationBuilder, AnimationContext};
use hikari_animation::style::CssProperty;

// Static animation
AnimationBuilder::new(&elements)
    .add_style("button", CssProperty::Opacity, "0.8")
    .apply_with_transition("300ms", "ease-in-out");

// Dynamic animation (mouse following)
AnimationBuilder::new(&elements)
    .add_style_dynamic("button", CssProperty::Transform, |ctx| {
        let x = ctx.mouse_x();
        let y = ctx.mouse_y();
        format!("translate({}px, {}px)", x, y)
    })
    .apply_with_transition("150ms", "ease-out");

Architecture Components:

  • builder - Animation builder API
  • context - Runtime animation context
  • style - Type-safe CSS operations
  • easing - 30+ easing functions
  • tween - Interpolation system
  • timeline - Timeline control
  • presets - Preset animations (fade, slide, scale)
  • spotlight - Spotlight effect

Performance Features:

  • WASM optimization
  • Debounced updates
  • requestAnimationFrame integration
  • Minimized reflows and repaints

4. Icon System (hikari-icons)

Icon management and rendering system.

Responsibilities:

  • Icon enum definitions
  • SVG content generation
  • Icon size variants
  • Material Design Icons integration

Core Features:

rust
1
2
3
4
5
6
7
8
9
use hikari_icons::{Icon, MdiIcon};

rsx! {
    Icon {
        icon: MdiIcon::Search,
        size: 24,
        color: "var(--hi-primary)"
    }
}

Icon Sources:

  • Material Design Icons (7000+ icons)
  • Extensible custom icons
  • Multiple size support

5. Component Library (hikari-components)

Complete UI component library.

Responsibilities:

  • Basic UI components
  • Layout components
  • Style registry
  • Responsive hooks

Component Categories:

  1. Basic Components (feature: "basic")
    • Button, Input, Card, Badge
  2. Feedback Components (feature: "feedback")
    • Alert, Toast, Tooltip, Spotlight
  3. Navigation Components (feature: "navigation")
    • Menu, Tabs, Breadcrumb
  4. Layout Components (always available)
    • Layout, Header, Aside, Content, Footer
  5. Data Components (feature: "data")
    • Table, Tree, Pagination

Modular Design:

mermaid

Style System:

  • SCSS source
  • Type-safe utility classes
  • Component-level style isolation
  • CSS variable integration

6. Icon Build System

Compile-time code generation and SCSS compilation.

Responsibilities:

  • SCSS compilation (using Grass)
  • Component discovery
  • Code generation
  • Resource bundling

Build Process:

mermaid

Usage:

rust
1
2
3
4
// build.rs
fn main() {
    tairitsu-icons build system::build().expect("Build failed");
}

Generated Files:

  • public/styles/bundle.css - Compiled CSS

7. Render Service (moved to the tairitsu packager)

The hikari-render-service crate has been retired. HTML template rendering, the style registry, the Axum router builder and static-asset mounting moved to the tairitsu framework (tairitsu-packager / tairitsu-ssr), which hosts hikari-components; see <https://github.com/celestia-island/tairitsu> for the current API. Nothing in this repository depends on a hikari_render_service crate any more.

8. Extra component data models (retired)

The hikari-extra-components package — framework-agnostic data models for the timeline, drag layer, zoom controls and the node graph — has been removed. Nothing in the workspace depended on it, and its types duplicated same-named render components. Use the components in hikari-components instead: display::{Timeline, DragLayer, UserGuide, ZoomControls}, production::{VideoPlayer, RichTextEditor, CodeHighlight}.

Architecture Principles

1. Modular Design

Each package is independent and can be used separately:

toml
1
2
3
4
5
6
7
8
9
10
11
12
# Use only palette
[dependencies]
hikari-palette = "0.1"

# Use components and theme
[dependencies]
hikari-components = "0.1"
hikari-theme = "0.1"

# Use animation system
[dependencies]
hikari-animation = "0.1"

2. Layered Architecture

mermaid

3. Unidirectional Data Flow

mermaid

4. Type Safety

All APIs are type-safe:

  • Compile-time checking
  • IDE autocompletion
  • Refactoring safety

5. Performance First

  • WASM optimization
  • Virtual scrolling
  • Debouncing/throttling
  • Minimized DOM manipulation

Build Process

Development Mode

bash
1
cargo run

Production Build

bash
1
2
3
4
5
6
# 1. Build Rust code
cargo build --release

# 2. Build system automatically compiles SCSS
# 3. Generate CSS bundle
# 4. Bundle static assets

WASM Build

bash
1
trunk build --release

Dependencies

mermaid

Extensibility

Adding Custom Components

rust
1
2
3
4
5
6
7
8
9
use hikari_components::{StyledComponent, StyleRegistry};

pub struct MyComponent;

impl StyledComponent for MyComponent {
    fn register_styles(registry: &mut StyleRegistry) {
        registry.register("my-component", include_str!("my-component.scss"));
    }
}

Adding Custom Themes

rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use hikari_palette::{Palette, ThemeMode, Color};

struct CustomTheme;

impl CustomTheme {
    pub fn palette() -> Palette {
        Palette {
            mode: ThemeMode::Light,
            primary: Color::from_rgb_hex(0xEE, 0xA2, 0xA4),
            secondary: Color::from_rgb_hex(0x51, 0x9A, 0x73),
            accent: Color::from_rgb_hex(0xF5, 0x9E, 0x0B),
            success: Color::from_rgb_hex(0x1f, 0x65, 0x30),
            warning: Color::from_rgb_hex(0x89, 0x48, 0x00),
            danger: Color::from_rgb_hex(0xa6, 0x29, 0x37),
            info: Color::from_rgb_hex(0x00, 0x62, 0x74),
            background: Color::from_rgb_hex(0xd6, 0xec, 0xf0),
            surface: Color::from_rgb_hex(0xe0, 0xf0, 0xe9),
            border: Color::from_rgb_hex(0xc4, 0xd8, 0xda),
            text_primary: Color::from_rgb_hex(0x2d, 0x2d, 0x2d),
            text_secondary: Color::from_rgb_hex(0x6b, 0x72, 0x80),
        }
    }
}

Adding Custom Animation Presets

rust
1
2
3
4
5
6
7
8
9
10
11
12
use hikari_animation::{AnimationBuilder, AnimationContext};

pub fn fade_in(
    builder: AnimationBuilder,
    element: &str,
    duration: u32,
) -> AnimationBuilder {
    builder
        .add_style(element, CssProperty::Opacity, "0")
        .add_style(element, CssProperty::Opacity, "1")
        .apply_with_transition(&format!("{}ms", duration), "ease-out")
}

Performance Optimization

1. CSS Optimization

  • SCSS compiled to optimized CSS
  • Remove unused styles (tree-shaking)
  • Minify production CSS

2. WASM Optimization

  • wasm-opt optimization
  • Lazy WASM module loading
  • Linear memory optimization

3. Runtime Optimization

  • Virtual scrolling (large data lists)
  • Debounced animation updates
  • requestAnimationFrame

4. Build Optimization

  • Parallel compilation
  • Incremental compilation
  • Binary caching

Testing Strategy

Unit Tests

Each module has complete unit tests:

rust
1
2
3
4
5
6
7
8
#[cfg(test)]
mod tests {
    #[test]
    fn test_color_conversion() {
        let color = Color::Cinnabar;
        assert_eq!(color.hex(), "#519A73");
    }
}

Integration Tests

Example applications in examples/ serve as integration tests

Visual Regression Testing

Use Percy or similar tools for UI snapshot testing

Next Steps