# gurupreet/composecookbook architecture

> Architecture diagram of the GitHub repository gurupreet/composecookbook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gurupreet/composecookbook
- Repository: https://github.com/gurupreet/composecookbook

## Overview

This project is a multi-module Android repository built to showcase the power and variety of Jetpack Compose. Essentially, it is a cookbook of composable UI elements, layouts, widgets, animations, themes, and complete demo applications (such as cryptoapp, datingapp, moviesapp, etc.) that can be used as references or building blocks for modern Android UI development with Compose.

##### Main Components
- Core UI Modules – These modules house the reusable UI components, layouts, widgets, animations, themes, and utility functions. You have dedicated directories such as “components” (with submodules like carousel, charts, colorpicker, etc.), “theme” (for styling), “templates” (for various sample screens like onboarding, login, etc.), and “animations”.
- Data Layer – The “data” module provides data sources, models, and data providers (e.g., DemoDataProvider, AlbumsDataProvider) that power many of the composables’ dynamic content.
- App Module – This is the main application “app” module where the ComposeCookBook host app is created, containing the main activity and orchestrating the display of various UI screens.
- Build & Dependency Management – “buildSrc” contains Kotlin DSL scripts and Gradle configurations (dependency and configuration scripts), which streamline module builds and dependency management.
- Demo Applications – A series of demo subprojects (under the “demos” directory) such as “cryptoapp”, “datingapp”, “spotify”, “instagram”, “twitter”, etc. Each of these stands as a complete app that leverages components from the core modules to demonstrate real-world usage and integrations (for example, MVVM, MVI patterns, Retrofit, Room integration).
- Animations & Assets – The “animations” directory is split into parts such as “canvas” and “lottie”, each demonstrating different animation techniques using Jetpack Compose.

##### Relationships and Interactions
- The core UI modules (components, theme, templates) are designed as independent Gradle modules. They interact with the “app” module, which acts as the container and navigation hub.
- Modules in “data” provide models and data providers that are usually consumed by UI components in both the “app” and the demo applications.
- Demos are loosely coupled standalone apps that rely on the core modules. They help illustrate how the building blocks can be integrated together to build fully-functional applications.
- The “buildSrc” module provides centralized dependency and configuration management for all modules, ensuring consistency across the project.
- CI/CD workflows (in the “.github” folder) act on corresponding modules to build, test, and package the applications (including the creation of APKs).

##### Architectural Patterns & Design Principles
- Modularization – The project is architected as a multi-module Gradle project, promoting separation of concerns (UI, data, theming, configuration, demos, etc.).
- Reusability – Independent, well-defined UI components and templates ensure that every demo or app can reuse the same building blocks.
- Declarative UI – The use of Jetpack Compose means that the entire UI is built with a declarative approach.
- Layers – Although not a strict MVVM or Clean Architecture implementation across every module, typical demos may demonstrate patterns like MVVM or MVI (especially in demo apps like CryptoApp, MovieApp, DatingApp).
- Build Automation – Usage of Gradle’s Kotlin DSL and custom scripts via “buildSrc” demonstrates an emphasis on maintainability and scalable dependency management.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Infrastructure Layer
    subgraph "Infrastructure"
        BS("Build & Dependency Management"):::config
        DT("Data Layer"):::config
    end

    %% ComposeCookBook Library (Core UI Modules)
    subgraph "ComposeCookBook Library"
        COMP("Components"):::core
        TH("Theme"):::core
        TEMPL("Templates"):::core
        ANIM("Animations"):::core
            subgraph "Animations Submodules"
                CAN("Canvas Animations"):::animStyle
                LOT("Lottie Animations"):::animStyle
            end
    end

    %% Application Layer
    subgraph "Application Layer"
        APP("App Module"):::appComp
        subgraph "Demo Applications"
            CR("CryptoApp"):::demo
            DA("DatingApp"):::demo
            MO("MoviesApp"):::demo
            IG("Instagram"):::demo
            TW("Twitter"):::demo
            GM("Gmail"):::demo
            ME("Meditation"):::demo
            PA("Paint"):::demo
            SP("Spotify"):::demo
            TK("Tiktok"):::demo
            YT("Youtube"):::demo
        end
    end

    %% Connections from Infrastructure to Library
    BS --> COMP
    BS --> TH
    BS --> TEMPL
    BS --> ANIM
    DT --> COMP
    DT --> TH
    DT --> TEMPL
    DT --> ANIM

    %% Connections from Infrastructure to Application Layer
    BS --> APP
    BS --> CR
    BS --> DA
    BS --> MO
    BS --> IG
    BS --> TW
    BS --> GM
    BS --> ME
    BS --> PA
    BS --> SP
    BS --> TK
    BS --> YT

    DT --> APP
    DT --> CR
    DT --> DA
    DT --> MO
    DT --> IG
    DT --> TW
    DT --> GM
    DT --> ME
    DT --> PA
    DT --> SP
    DT --> TK
    DT --> YT

    %% Connections from Library to Application Layer (App Module)
    COMP --> APP
    TH --> APP
    TEMPL --> APP
    ANIM --> APP

    %% Connections from Library to Demo Applications
    COMP --> CR
    COMP --> DA
    COMP --> MO
    COMP --> IG
    COMP --> TW
    COMP --> GM
    COMP --> ME
    COMP --> PA
    COMP --> SP
    COMP --> TK
    COMP --> YT

    TH --> CR
    TH --> DA
    TH --> MO
    TH --> IG
    TH --> TW
    TH --> GM
    TH --> ME
    TH --> PA
    TH --> SP
    TH --> TK
    TH --> YT

    TEMPL --> CR
    TEMPL --> DA
    TEMPL --> MO
    TEMPL --> IG
    TEMPL --> TW
    TEMPL --> GM
    TEMPL --> ME
    TEMPL --> PA
    TEMPL --> SP
    TEMPL --> TK
    TEMPL --> YT

    ANIM --> CR
    ANIM --> DA
    ANIM --> MO
    ANIM --> IG
    ANIM --> TW
    ANIM --> GM
    ANIM --> ME
    ANIM --> PA
    ANIM --> SP
    ANIM --> TK
    ANIM --> YT

    %% Click Events for Component Mapping
    click COMP "https://github.com/gurupreet/composecookbook/tree/master/components"
    click TH "https://github.com/gurupreet/composecookbook/tree/master/theme"
    click TEMPL "https://github.com/gurupreet/composecookbook/tree/master/templates"
    click ANIM "https://github.com/gurupreet/composecookbook/tree/master/animations"
    click CAN "https://github.com/gurupreet/composecookbook/tree/master/animations/canvas"
    click LOT "https://github.com/gurupreet/composecookbook/tree/master/animations/lottie"
    click DT "https://github.com/gurupreet/composecookbook/tree/master/data"
    click BS "https://github.com/gurupreet/composecookbook/tree/master/buildSrc"
    click APP "https://github.com/gurupreet/composecookbook/tree/master/app"
    click CR "https://github.com/gurupreet/composecookbook/tree/master/demos/cryptoapp"
    click DA "https://github.com/gurupreet/composecookbook/tree/master/demos/datingapp"
    click MO "https://github.com/gurupreet/composecookbook/tree/master/demos/moviesapp"
    click IG "https://github.com/gurupreet/composecookbook/tree/master/demos/instagram"
    click TW "https://github.com/gurupreet/composecookbook/tree/master/demos/twitter"
    click GM "https://github.com/gurupreet/composecookbook/tree/master/demos/gmail"
    click ME "https://github.com/gurupreet/composecookbook/tree/master/demos/meditation"
    click PA "https://github.com/gurupreet/composecookbook/tree/master/demos/paint"
    click SP "https://github.com/gurupreet/composecookbook/tree/master/demos/spotify"
    click TK "https://github.com/gurupreet/composecookbook/tree/master/demos/tiktok"
    click YT "https://github.com/gurupreet/composecookbook/tree/master/demos/youtube"

    %% Styles
    classDef config fill:#FFCCCB,stroke:#D9534F,stroke-width:2px;
    classDef core fill:#B3E5FC,stroke:#039BE5,stroke-width:2px;
    classDef appComp fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef demo fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef animStyle fill:#F0F4C3,stroke:#9E9D24,stroke-width:2px;
```
