This document provides a high-level overview of the Automotive Design for Compose (DesignCompose) project, intended to be used by the Gemini code assistant.
Automotive Design for Compose (DesignCompose) is an extension for Jetpack Compose that enables defining Android application UIs in Figma. It supports live updates from Figma designs, allowing for a more iterative and collaborative design and development process.
The core of DesignCompose consists of a Jetpack Compose library, a Kotlin compiler plugin, and a Rust-based service for fetching and serializing Figma documents.
- Frontend: Jetpack Compose (Kotlin)
- Backend/Figma Integration: Rust
- Build System: Gradle
- Dependency Management: Gradle, Cargo (for Rust)
- Protos: The project uses a git submodule for its proto files, located at
crates/dc_bundle/src/proto.
The project is a multi-module Gradle project with a mix of Kotlin, Java, and Rust code.
designcompose: The main runtime library that interprets and renders Figma documents.annotation: Contains Kotlin annotations like@DesignDocand@DesignComponent.codegen: A Kotlin compiler plugin that processes the annotations and generates Composables.common: Contains code shared between other modules.
The Rust code is located in the crates/ directory and is responsible for interacting with the Figma API.
dc_bundle: Handles the bundling of Figma data.dc_jni: Provides the Java Native Interface (JNI) for the Android runtime to communicate with the Rust code.dc_layout: Manages layout information from Figma.dc_figma_import: Fetches and serializes Figma documents.
The reference-apps/ directory contains several example applications that demonstrate how to use DesignCompose.
helloworld: A basic "Hello, World!" application.tutorial: An interactive tutorial application.aaos-unbundled: A sample media center for Android Automotive OS.cluster-demo: A demonstration of a dashboard cluster.
integration-tests/: Contains various integration tests.integration-tests/benchmarks/: Contains benchmarking applications.test/: Contains unit tests.validation/: Contains a visual validation app.
The designcompose library has a benchmark variant that is used by the benchmark apps in integration-tests/benchmarks/. These apps are used for performance testing of various DesignCompose features.
build-logic/: Contains custom Gradle build logic.plugins/: Contains custom Gradle plugins for handling the Rust and Android parts of the build.build.gradle.kts,settings.gradle.kts: The main Gradle build files.gradle/libs.versions.toml: Defines the project's dependencies.
README.md: The main entry point for understanding the project.docs/: Contains the project's documentation website, built with Jekyll.
The project uses specific formatters to maintain a consistent code style.
- Kotlin:
ktfmtwith the--kotlinlang-styleflag. - Rust:
rustfmt
The easiest way to ensure all files are formatted correctly is to run the format-all.sh script located in the dev-scripts/ directory.
The project is built using Gradle. The build process involves compiling the Kotlin/Java code, the Rust code, and then packaging everything into Android libraries and applications.
./gradlew build: Builds the entire project../gradlew test: Runs all unit tests../gradlew connectedCheck: Runs all instrumented tests on a connected device or emulator../dev-scripts/test-all.sh: A script that runs all tests, including formatting checks.
- Android NDK: Version 27.0.12077973 is required for the Rust JNI library.
- Rust: Version 1.68.0 is required.
- Protobuf Compiler: Required for compiling the protobuf messages.
-
Initial Setup:
- Clone the repository with
--recurse-submodules. - Install the required dependencies (Android Studio, NDK, Rust, Protobuf compiler). .
- Run
./install-rust-toolchains.shto install the necessary Rust toolchains.
- Clone the repository with
-
Branching:
- Create a new branch from
mainusing the formatwb/<user>/<branch-name>.
- Create a new branch from
-
Making Changes:
- Modify the code in the appropriate module.
- If changing the Figma serialization format, update the serialized files.
-
Testing:
- Run
./dev-scripts/format-all.shto format the code. - Run
./dev-scripts/test-all.shto run all tests.
- Run
-
Submitting Changes:
- Create a pull request.
To generate a code coverage report for the Kotlin code, run the following command:
./gradlew jacocoTestReport
This will generate an XML report at build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml.
To ensure that work can be continued across sessions, the agent will use a notes system.
-
Creating Notes: For any task that will require large amounts of planning or file changes, the agent will create a markdown file in the
.gemini/directory (e.g.,.gemini/task-name-notes.md). This file will contain a summary of the work completed, the plan for what is left to do, and any other relevant context. -
Continuing Tasks: At the beginning of a new session, the agent will look for any files in the
.gemini/directory (ignoring the.gitignorefile, so it is important to use the correct tool parameter to see all files). If the agent finds any, it will read them and ask the user if they want to continue the tasks described in them.
This section describes the command-line tools available for interacting with Figma.
The fetch tool downloads a Figma document, extracts specified nodes, and saves the output to a .dcf file. This tool requires a Figma access token, which can be provided via the FIGMA_ACCESS_TOKEN environment variable or a file at ~/.config/figma_access_token.
Usage:
To fetch a single node:
cargo run --features="fetch" --bin fetch -- --doc-id <DOCUMENT_ID> --nodes <NODE_NAME> --output <OUTPUT_FILE.dcf>To fetch multiple nodes, repeat the --nodes argument for each node ID:
cargo run --features="fetch" --bin fetch -- --doc-id <DOCUMENT_ID> --nodes <NODE_NAME_1> --nodes <NODE_NAME_2> --nodes <NODE_NAME_3> --output <OUTPUT_FILE.dcf>Example:
Fetching a single node:
cargo run --features="fetch" --bin fetch -- --doc-id 2aM4SczJzWg1rov2qqBMpe --nodes "#MainFrame" --output output.dcfFetching multiple nodes:
cargo run --features="fetch" --bin fetch -- --doc-id dGS6HEmsfv8QSHgAGBwEH7 --nodes "#root" --nodes "#DynamicRoot" --nodes "#Item" --output ListPaginationTestDoc_dGS6HEmsfv8QSHgAGBwEH7.dcfImportant: Do NOT pass multiple node IDs as a comma-separated string to a single --nodes argument. Use a separate --nodes argument for each node ID.
The dcf_info tool inspects a .dcf file and prints its contents, including header information and variable data.
Usage:
cargo run --features="dcf_info" --bin dcf_info -- <INPUT_FILE.dcf> --varinfoExample:
cargo run --features="dcf_info" --bin dcf_info -- output.dcf --varinfo