$ show google/automotive-design-compose
This repository is the DesignCompose SDK, a production-grade Android library that renders Figma designs as native Jetpack Compose UI. It provides a complete pipeline: Figma plugins for designers (extended layout, animation timeline, auto-content preview), a Rust-based import crate (`dc_figma_import`) that fetches and caches Figma documents, a layout engine (`dc_layout`) wrapping the Taffy flexbox library, and a Kotlin runtime (`designcompose`) that resolves variants, handles interactions, and renders via Compose. The architecture is modular with clear separation: Rust crates handle data ingestion and layout computation, Kotlin modules provide the public API and rendering, and Gradle plugins automate Rust cross-compilation and Figma token management. The codebase includes extensive tests (unit, integration, Roborazzi screenshot, benchmarks) and reference apps (Tutorial, HelloWorld, Cluster Demo, AAOS Media Center). It supports live updates via polling or WebSocket, incremental document fetching, variable theming, and complex animations (smart animate, keyframe timelines). The repository is actively maintained with frequent commits, a versioned protobuf schema, and a CI/CD pipeline. While the multi-language stack (Kotlin, Rust, TypeScript) adds complexity, the code demonstrates strong engineering practices with reusable patterns in caching, layout, and animation.
The LLM identified 4 files worth highlighting for reuse:
Core Rust layout manager that wraps the Taffy flexbox crate and exposes a JNI interface for Android. It handles style creation, node addition/removal, layout computation, and custom measure callbacks. The design is clean and self-contained: it accepts a closure for external measurement (e.g., text), returns layout diffs, and supports percentages, min/max constraints, and absolute positioning. This component could be extracted and reused in any Android project needing a native layout engine, especially for dynamic UI systems.
Provides custom Compose Brush implementations (RelativeLinearGradient, RelativeRadialGradient, RelativeSweepGradient, RelativeImageFill) that adapt Figma's relative coordinate gradients to absolute pixel shaders. The logic handles rotation, scaling, and image fill tiling. These brushes are non-trivial and solve a common problem in design-to-code pipelines: converting relative design coordinates to screen-space rendering. They are isolated enough to be extracted into a standalone utility library for any Compose project needing similar gradient transformations.
Implements a process-wide, document-keyed smart cache for Figma API responses (images, variables, remote components, variant nodes). It stores raw bytes and metadata, supports session-based reuse to avoid redundant fetches, and integrates with the incremental update system. The caching pattern is generic and could be reused for any API client that needs to cache large, versioned responses with minimal overhead. The code is self-contained with clear invalidation logic and thread-safe access via Mutex.
A Gradle plugin that automates building Rust crates for Android targets (armv7, aarch64, x86_64, i686). It configures cargo with the correct NDK toolchain, target triples, and build profiles. The plugin is reusable for any Android project that includes Rust native code, eliminating the need for manual cargo invocation and NDK setup. It demonstrates a clean extension API and integrates with the Android build lifecycle.