Skip to main content

Architecture

1. Why​

This note fixes how the pieces of Camouflage connect before any code exists: which concept owns what, which module depends on which, and the exact path a call like CamoButton(...) takes to become pixels. Every later note fills in one box of this picture. If a later note seems to contradict this one, this one wins, or it gets updated with an entry in Decisions.

2. Shape​

2.1 Three concepts, three responsibilities​

ThemeSkinComponent
Isdata (immutable values), including optional per-component overridesbehavior (a set of renderers), plus complete per-component defaultsAPI (a function or widget the app calls)
Knows aboutnothingThemeSkin + Theme (through the provider)
Written bythe app, or generated from Figmaa skin librarycamouflage-core
Swapped byCamouflageProvider(theme = …)CamouflageProvider(skin = …)never swapped

The dependency direction is one way: Component → Skin → Theme. A Theme never knows which skin draws it, so the same brand theme works on Material and Cupertino.

2.2 The render path​

Step by step, for one button press:

  1. The app calls CamoButton(text = "Save", onClick = save, appearance = Solid, prefixIcon = AppIcon.save()).
  2. The component (in core) packs its inputs into two objects:
    • ButtonState: the values: text, enabled, appearance, tone, the interaction state (pressed/focused/hovered).
    • ButtonSlots: the widgets: prefixIcon, suffixIcon.
  3. It reads the nearest CamouflageProvider above it and gets skin and theme.
  4. It resolves the button's component theme (style = skin.button.defaults(theme).merge(theme.components.button)) and calls skin.button.render(state, slots, theme, style).
  5. MinimalSkin's ButtonRenderer draws a flat container with theme.colors.primary, its style's shape (radius 8), and a soft fade on press (the skin's InteractionFeedback). It draws the text itself in labelLarge, and sets the ambient icon style (18, onPrimary) so the AppIcon needs no parameters.
  6. The component wires up the click callback and semantics (role = button). This is not the renderer's job, so every skin is accessible by default.
Split of duties inside a component

Core component owns behavior that must never differ between skins: the click/value callbacks, the semantics role and label, the enabled check, and the minimum touch target. Renderer owns everything visual and anything structural: layout, colors, shape, animation, press feedback, how text values are drawn, the icon style around icon widgets, and where they go.

2.3 Modules​

ModuleContainsDepends on
camouflage-coreCamoTheme and its groups, CamoSkin plus every renderer interface, SurfaceTreatment, InteractionFeedback, CamouflageProvider, CamoEnvironment, the componentsthe platform UI toolkit only (Compose foundation / Flutter widgets)
camouflage-skin-minimalMinimalSkin (Camouflage's own dialect), its renderers, the Flat surface treatment, Fade feedback, minimalThemecamouflage-core
camouflage-skin-fluent (ADR-38)FluentSkin (Fluent 2), its renderers, the Solid, Acrylic and Mica surface treatments, Subtle feedback, fluentThemecamouflage-core
camouflage-skin-material, -cupertino, -carbon (M12 to M14, ADR-40)the other dialects (Skins)camouflage-core
camouflage-navigation3 (Compose only)scene strategies that open dialogs and sheets as Navigation 3 entriescamouflage-core, Navigation 3
camouflage-charts (ADR-40)the chart family on one shared chart frame. Charts aren't part of the skin contract.camouflage-core
Later skinsone module eachcamouflage-core
camouflage-storybook, camouflage-filesystem, … (family packages in the same repo, ADR-26)a component catalog built with Camouflage; a file layer with a browser/picker built with Camouflage. See Roadmap.both → core (never the reverse)
camouflage-blueprint (Later)server-driven UI: builds Camouflage components, forms and CamoRules from JSON through a type registrycamouflage-core (never the reverse)

Dart package names use underscores: camouflage_core, camouflage_skin_minimal.

Why skins are separate libraries:

  • An app pays only for the skins it uses: binary size, and no unused dependencies.
  • A skin can be versioned and released on its own. A Material fix doesn't force a core release.
  • It proves the contract is complete: if skin-minimal can be built using only core's public API, a third-party or AI-generated skin can be too.

2.4 Platforms​

Camouflage compiles for every platform its toolkits support (ADR-18). All library code is common code. Anything platform-specific goes through expect/actual (Kotlin) or a platform check with a fallback (Flutter).

PlatformKotlin targetFlutterPlatform-specific parts Camouflage needs
AndroidandroidTargetandroidsystem animation scale (reduced motion); optional dynamicCamoColors() (Android 12+, androidMain only)
iOSiosArm64, iosSimulatorArm64iosreduced-motion setting; bold-text setting
Desktop (Windows, macOS, Linux)jvmwindows, macos, linuxmouse hover and keyboard-first focus (already in the contracts); window resizing
WebwasmJswebprefers-reduced-motion and prefers-color-scheme; limited screen-reader support on the canvas; bundle size

Rules:

  1. No platform-only API in commonMain / shared Dart code. The build of each target is what enforces it.
  2. Every expect has an actual on every target, even if it's a safe fallback (haptics → no-op on web).
  3. Optional platform extras (dynamic color) live in platform source sets as additions, never as part of the core API.

2.5 Surface treatment: the "material" of a design language​

Most design languages share a structure: a button is a container with a label. What sets them apart is the surface:

Design languageSurface metaphorTreatment
Google, Material Designpaperopaque fill, elevation expressed as shadow and tonal tint
Apple, Liquid Glass (iOS 26+)glasstranslucent, blurs and refracts what is behind it
Microsoft, Fluentacrylic / micafrosted blur (acrylic) or a wallpaper tint (mica)

So SurfaceTreatment is a separate, reusable part of a skin (see Skin Contract). This is why one skin can reuse another's renderers and swap only the surface treatment.

Camouflage guarantees the same behavior and layout on every platform, not the same pixels (ADR-42). A material a platform can't draw falls back along a chain (Liquid Glass → Classic blur → opaque, Mica → Solid), chosen at runtime from CamoCapabilities. The user's Reduce Transparency setting always wins.

2.6 Environment​

A theme describes a brand, but conventions also depend on where the app runs (ADR-41). The root provider computes a CamoEnvironment: window size, input (touch or pointer), platform and capabilities. A theme can adapt to it (CamoTheme.adapt { env -> … }), and the provider applies that once per environment change, so components and renderers still read one plain theme.

2.7 Where Camouflage sits in an app​

Camouflage is the UI half of an app's libraries layer, and Sinew is the rest. It's called from the presentation layer, and nothing below the state holder imports it.

App moduleHoldsWhy there
appthe root CamouflageProvider(skin, theme)Swapping a skin or theme is one change in one place
shared presentationthe brand theme, renderer overrides, widgets used by 2+ modulesEvery feature shares one brand, and no feature depends on another
products, featurespages that call Camo*, passing plain state and callbacksA component holds no app state and never fetches
navigationroute setup for overlays (camouflage-navigation3 on Compose)Modules never import the router; pages leave by callback

Camouflage never depends on Sinew: it takes plain values, and only sinew_camouflage knows both. The full structure, with its dependency rules and one screen through every layer, is in App Architecture.

3. API​

This note introduces no new API. It is the map of the API defined elsewhere:

NameKindDefined inWhat it's for
CamoThemedataThemeall token values for one brand in one mode, including optional component themes
CamoComponentThemes, ButtonTheme…dataTheme §3.10 + each component noteper-component overrides, merged over skin defaults
CamoSkindata of renderersSkin Contracteverything needed to draw every component
XRenderer.render(state, slots, theme, style) + defaults(theme)interfaceSkin Contractdraws one component
SurfaceTreatment, InteractionFeedbackinterfacesSkin Contractreusable skin parts
CamouflageProvider(skin, theme, content)componentProvider and Scopingputs a skin and a theme into the tree
Camouflage.skin, Camouflage.themeaccessorsProvider and Scopingread the current skin and theme
CamoText … CamoBottomSheet, CamoFormcomponentsComponents — Overviewwhat apps call
CamoEnvironment, CamoCapabilitiesdata§2.5 and §2.6, ADR-41, ADR-42where the app runs, and what the platform can draw
MinimalSkinskinMinimal SkinCamouflage's own dialect
FluentSkinskinFluent SkinFluent 2 (ADR-38)
MaterialSkin, CupertinoSkin, CarbonSkinskinsSkinsthe other v0.1 dialects (ADR-40)

The full render path as pseudocode (one button):

// camouflage-core
fun CamoButton(text: String, onClick: () -> Unit, appearance: Appearance = Solid, tone: Tone = Default,
enabled: Boolean = true, prefixIcon: Widget? = null, suffixIcon: Widget? = null) {
val skin = Camouflage.skin // nearest provider, fails fast if none
val theme = Camouflage.theme
val interaction = rememberInteractionState() // pressed / focused / hovered
val state = ButtonState(text, enabled, appearance, tone, interaction.current)
val slots = ButtonSlots(prefixIcon, suffixIcon)
val style = skin.button.defaults(theme).merge(theme.components.button) // theme overrides win
Clickable(onClick, enabled, role = Button, label = text, minTouchTarget = 48, interaction) {
skin.button.render(state, slots, theme, style)
}
}

// camouflage-skin-minimal
object MinimalButtonRenderer : ButtonRenderer {
override fun defaults(theme: CamoTheme) = ButtonTheme(
height = 40, shape = theme.shapes.medium, padding = (theme.spacing.l, 0), iconSize = 16, iconGap = theme.spacing.s,
textStyle = theme.typography.labelLarge, /* colors per appearance, referencing theme.colors … */)
fun render(state: ButtonState, slots: ButtonSlots, theme: CamoTheme, style: ButtonTheme) {
val f = theme.colors.family(state.tone) // Default → primary (ink) / its container
val (container, onContainer) = when (state.appearance) {
Solid -> f.strong to f.onStrong
Soft -> theme.colors.surfaceContainerHigh to theme.colors.onSurface
Raised -> theme.colors.surface to theme.colors.onSurface // + a hairline border, no shadow
Outline, Ghost, Link -> Transparent to f.strong
}
Box(height = style.height, shape = style.shape, color = container, padding = style.padding) {
ProvideIconStyle(IconStyle(size = style.iconSize, color = onContainer)) {
Row(gap = style.iconGap) {
slots.prefixIcon?.invoke()
Text(state.text, style = style.textStyle, color = onContainer)
slots.suffixIcon?.invoke()
}
}
}
}
}

4. Build steps​

This is the M0 skeleton. No component draws anything yet.

  1. Create the repository with the module layout from §2.3: camouflage-core, camouflage-skin-minimal, and a sample app. Platform details: Project Setup / Project Setup.
  2. Make camouflage-skin-minimal depend on camouflage-core, and sample depend on both.
  3. Add one empty public type in core (CamoTheme) and use it from skin-minimal and sample, to prove the dependency wiring compiles.
  4. Turn on public-API tracking for core (the binary compatibility validator for Kotlin; dart analyze with public_member_api_docs for Flutter).
  5. Set up CI to build all modules on every push.

Done when

  • The three modules build in CI.
  • sample compiles against both libraries.
  • A change to skin-minimal does not require touching core, and core does not depend on skin-minimal (check the dependency graph).

5. Edge cases​

CaseDecided behavior
The app depends on camouflage-core only, with no skinIt compiles. The first Camo* component to render fails fast with "No CamouflageProvider found above CamoButton." Core never ships a default skin, because a default would make core visually opinionated.
A skin module needs something core doesn't exposeAdd it to core's public API (a core change with an ADR). Never let a skin reach into core internals: that breaks the "skins use only public API" guarantee.
Circular dependency (a core helper wants a Material helper)Forbidden. Shared helpers go into core as neutral utilities, or are duplicated inside the skin.
A component behavior that looks visual but is really behavior (e.g. minimum touch target)It belongs to the component, so it holds under every skin.
What goes into a core contract (ADR-23)Only what every documented dialect can render: Minimal, Material, Cupertino, Fluent, Carbon. Check the component's row in each skin note before adding a parameter. Anything one dialect has and others don't (Material's hero icon in dialogs, Carbon's "On/Off" toggle text) stays out of core: the developer composes it in a slot, or the skin offers it as a skin option or component-theme field.
Component vs renderer split (settled 2026-09-27)The component owns semantics, input handling, dismissal, focus and results. The renderer owns the look and the arrangement of the slots it receives. Example: CamoDialog gets confirm and dismiss as separate slots, so Minimal/Material/Fluent place them end-aligned side by side, Cupertino stacks them when the labels are long, and Carbon makes a full-width row, all without changing the contract. Layout inside content belongs to the developer.
How a brand design is built (ADR-28)The common case is one brand design on the Minimal skin. Climb the ladder only as far as needed: theme tokens → component-theme fields → a renderer override (your own, or borrowed from another skin when the feedback is "make it behave like Apple's") → a new skin. Layout choices brands often change (label placement, label side, label visibility) are component-theme fields, so most brands never write a renderer.
Imaginative designs (ADR-30)When a design goes beyond the component (a floating or hiding nav bar, a nav bar that expands into a menu), use the cheapest level: a theme option, a controlled behavior input (visible), the component's public building blocks, or a renderer override.
sample app location (settled 2026-09-27)It lives in the same repo, next to the libraries, so every change is checked against it. It doubles as the showcase for recordings. If it outgrows the repo (store builds, several demo apps), extract it then.