# atanu-sabyasachi/snackify architecture

> Architecture diagram of the GitHub repository atanu-sabyasachi/snackify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atanu-sabyasachi/snackify
- Repository: https://github.com/atanu-sabyasachi/snackify

## Overview

This repository is a Flutter package, not a standalone app. Its architecture is centered around a single public API for showing highly customizable SnackBars, with the rest of the library providing configuration, rendering, lifecycle, and optional text-to-speech behavior.

1. **Public entrypoint**
   - `lib/snackify.dart` is the main facade the consumer imports.
   - The README shows the core usage pattern: `Snackify.show(...)`.
   - This file likely re-exports the package types and presents the stable surface area.

2. **Snack display pipeline**
   - The main flow starts when client code calls `Snackify.show(context, ...)`.
   - The call is translated into a visual snack overlay, with parameters such as type, title/subtitle, duration, position, animation timing, shadows, and persistence.
   - The package is responsible for mounting and removing the snack independently of a standard `ScaffoldMessenger`-only approach.

3. **Overlay-based presentation layer**
   - `lib/overlay_entry.dart` suggests the snackbar is injected via Flutter overlays.
   - This is the boundary that attaches the snack UI to the current screen and controls visibility/dismissal.
   - This design allows top/bottom positioning, persistent display, and animated entrance/exit without requiring a dedicated page or route.

4. **Snack UI rendering**
   - `lib/snackify_snackbar.dart` likely contains the actual widget tree for the snackbar card/banner.
   - This is where the title, subtitle, action widget, close affordance, background gradient, border radius, shadows, and layout rules are assembled.
   - It is the main visual component that consumers experience.

5. **Type-driven styling system**
   - `lib/enums/snack_enums.dart` defines core enum concepts such as `SnackType` and `SnackPosition`.
   - `lib/snack_type_details.dart` and `lib/snacktype_configuration.dart` model the defaults and overrides for each snack type.
   - The architecture uses type as a styling and behavior selector, so `success`, `error`, `warning`, `info`, and `custom` each map to a distinct visual configuration.

6. **Configuration as data, not code**
   - `SnackTypeConfiguration` lets callers override colors, icon, text style, margins, elevation, and border radius.
   - `TTSConfiguration` packages speech-related settings such as `speakOnShow`, language, speech rate, and pitch.
   - This keeps the rendering logic mostly declarative: the UI is built from configuration objects rather than ad hoc branching in application code.

7. **Initialization and defaults**
   - `lib/initializers.dart` likely contains helper logic for normalizing parameters, applying defaults, and building the final snack configuration.
   - This is an important boundary between the API layer and the rendering layer: user inputs are resolved here before the overlay widget is created.
   - It is also where defaults for duration, animation, and fallback visuals probably converge.

8. **Text-to-speech side effect path**
   - TTS is an optional side effect triggered when a snack is shown.
   - The flow is separate from the visual snack rendering: the snack appears, and the message may be spoken based on `TTSConfiguration`.
   - This makes TTS an auxiliary subsystem attached to the show lifecycle rather than part of the UI tree itself.

9. **Consumer-facing example and verification**
   - `example/main.dart` is a usage sample that demonstrates the package in a real Flutter app context.
   - `test/snackify_test.dart` provides a minimal verification boundary for the public API and expected behavior.
   - These two pieces show the intended integration contract without adding runtime complexity to the package itself.

10. **Assets and documentation**
   - `assets/images` and `assets/snack_images` are documentation/demo assets used in the README.
   - They support the package’s visual identity and examples, but they are not part of the runtime control flow.
   - The README acts as the primary integration documentation for consumers.

11. **Overall architectural shape**
   - The package is a small layered system: API facade → config normalization → overlay lifecycle → snackbar widget rendering → optional TTS side effect.
   - The boundaries are cleanly separated between “what the caller wants” and “how Flutter displays it.”
   - For an architecture diagram, the most important nodes are the `Snackify.show()` entrypoint, the overlay controller, the snackbar widget, the type/config model, and the TTS path.

Main entry points: [`lib/initializers.dart`](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/initializers.dart) (Initializers), [`lib/snackify_snackbar.dart`](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snackify_snackbar.dart) (Snack UI), [`lib/snackify.dart`](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snackify.dart) (Snackify), [`README.md`](https://github.com/atanu-sabyasachi/snackify/blob/main/README.md) (README)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public_api["Public API"]
  node_lib_snackify["Snackify<br/>facade<br/>[snackify.dart]"]
end

subgraph group_core_flow["Core Flow"]
  node_lib_initializers["Initializers<br/>normalizer<br/>[initializers.dart]"]
  node_lib_snackify_api(("Show API<br/>call flow"))
end

subgraph group_presentation["Presentation"]
  node_lib_overlay_entry["Overlay Entry<br/>overlay host<br/>[overlay_entry.dart]"]
  node_lib_snackify_snackbar["Snack UI<br/>widget"]
end

subgraph group_configuration["Configuration"]
  node_lib_snack_enums["Snack Enums<br/>enum defs<br/>[snack_enums.dart]"]
  node_lib_snack_type_details["Type Details<br/>type defaults"]
  node_lib_snacktype_configuration["Snack Config<br/>config model"]
  node_lib_tts_config["TTS Config<br/>speech model<br/>[tts_config.dart]"]
end

subgraph group_auxiliary["Auxiliary"]
  node_lib_tts_path(("TTS Path<br/>side effect"))
  node_example_main["Example App<br/>usage sample<br/>[main.dart]"]
  node_test_snackify_test["Tests<br/>verification<br/>[snackify_test.dart]"]
  node_readme["README<br/>docs<br/>[README.md]"]
  node_assets_images[("Images<br/>assets")]
  node_assets_snack_images[("Snack Images<br/>assets")]
end

node_lib_snackify -->|"exposes"| node_lib_snackify_api
node_lib_snackify_api -->|"normalizes"| node_lib_initializers
node_lib_initializers -->|"uses"| node_lib_snack_enums
node_lib_initializers -->|"applies"| node_lib_snack_type_details
node_lib_initializers -->|"merges"| node_lib_snacktype_configuration
node_lib_initializers -->|"includes"| node_lib_tts_config
node_lib_snackify_api -->|"launches"| node_lib_overlay_entry
node_lib_overlay_entry -->|"hosts"| node_lib_snackify_snackbar
node_lib_overlay_entry -->|"triggers"| node_lib_tts_path
node_lib_tts_path -->|"reads"| node_lib_tts_config
node_lib_snackify_snackbar -->|"styles by"| node_lib_snack_enums
node_lib_snackify_snackbar -->|"renders from"| node_lib_snack_type_details
node_lib_snackify_snackbar -->|"overrides"| node_lib_snacktype_configuration
node_example_main -->|"imports"| node_lib_snackify
node_test_snackify_test -->|"verifies"| node_lib_snackify
node_readme -->|"documents"| node_lib_snackify
node_readme -->|"references"| node_assets_images
node_readme -->|"references"| node_assets_snack_images

click node_lib_snackify "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snackify.dart"
click node_lib_initializers "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/initializers.dart"
click node_lib_overlay_entry "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/overlay_entry.dart"
click node_lib_snackify_snackbar "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snackify_snackbar.dart"
click node_lib_snack_enums "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/enums/snack_enums.dart"
click node_lib_snack_type_details "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snack_type_details.dart"
click node_lib_snacktype_configuration "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snacktype_configuration.dart"
click node_lib_tts_config "https://github.com/atanu-sabyasachi/snackify/blob/main/lib/tts_config.dart"
click node_example_main "https://github.com/atanu-sabyasachi/snackify/blob/main/example/main.dart"
click node_test_snackify_test "https://github.com/atanu-sabyasachi/snackify/blob/main/test/snackify_test.dart"
click node_readme "https://github.com/atanu-sabyasachi/snackify/blob/main/README.md"
click node_assets_images "https://github.com/atanu-sabyasachi/snackify/tree/main/assets/images"
click node_assets_snack_images "https://github.com/atanu-sabyasachi/snackify/tree/main/assets/snack_images"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_lib_snackify toneBlue
class node_lib_initializers,node_lib_snackify_api toneAmber
class node_lib_overlay_entry,node_lib_snackify_snackbar toneMint
class node_lib_snack_enums,node_lib_snack_type_details,node_lib_snacktype_configuration,node_lib_tts_config toneRose
class node_lib_tts_path,node_example_main,node_test_snackify_test,node_readme,node_assets_images,node_assets_snack_images toneIndigo
```

## Components

### Public API

Stable import surface and consumer entrypoint

- [Snackify](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snackify.dart): facade · Main public entrypoint exported by the package · `lib/snackify.dart`

### Core Flow

Show call normalization and orchestration

- [Initializers](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/initializers.dart): normalizer · Builds final snack settings and applies defaults · `lib/initializers.dart`
- **Show API**: call flow · The show-call path exposed to consumers

### Presentation

Overlay attachment and snack rendering

- [Overlay Entry](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/overlay_entry.dart): overlay host · Attaches and removes snack UI in Flutter overlay space · `lib/overlay_entry.dart`
- [Snack UI](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snackify_snackbar.dart): widget · Renders the snackbar card, layout, and affordances · `lib/snackify_snackbar.dart`

### Configuration

Type-driven defaults and overrides

- [Snack Enums](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/enums/snack_enums.dart): enum defs · Core enums for type, position, and related choices · `lib/enums/snack_enums.dart`
- [Type Details](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snack_type_details.dart): type defaults · Default visuals and behavior for each snack type · `lib/snack_type_details.dart`
- [Snack Config](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/snacktype_configuration.dart): config model · User overrides for color, icon, layout, and motion · `lib/snacktype_configuration.dart`
- [TTS Config](https://github.com/atanu-sabyasachi/snackify/blob/main/lib/tts_config.dart): speech model · Options for optional text-to-speech behavior · `lib/tts_config.dart`

### Auxiliary

Optional side effects and usage surface

- **TTS Path**: side effect · Optional speech triggered alongside snack display
- [Example App](https://github.com/atanu-sabyasachi/snackify/blob/main/example/main.dart): usage sample · Consumer-facing integration example · `example/main.dart`
- [Tests](https://github.com/atanu-sabyasachi/snackify/blob/main/test/snackify_test.dart): verification · Minimal public API and behavior checks · `test/snackify_test.dart`
- [README](https://github.com/atanu-sabyasachi/snackify/blob/main/README.md): docs · Primary integration and usage documentation · `README.md`
- [Images](https://github.com/atanu-sabyasachi/snackify/tree/main/assets/images): assets · Documentation and demo image assets · `assets/images`
- [Snack Images](https://github.com/atanu-sabyasachi/snackify/tree/main/assets/snack_images): assets · Package imagery used in docs and demos · `assets/snack_images`

## Connections

- Snackify → Show API: exposes · Stable facade forwards consumer calls
- Show API → Initializers: normalizes · Resolves defaults and final configuration
- Initializers → Snack Enums: uses · Interprets type and position choices
- Initializers → Type Details: applies · Maps snack type to default presentation details
- Initializers → Snack Config: merges · Combines caller overrides into final config
- Initializers → TTS Config: includes · Carries optional speech settings
- Show API → Overlay Entry: launches · Creates overlay-backed snack lifecycle
- Overlay Entry → Snack UI: hosts · Places the rendered snack widget into overlay
- Overlay Entry → TTS Path: triggers · Starts optional speech when show is invoked
- TTS Path → TTS Config: reads · Uses speech settings to control playback
- Snack UI → Snack Enums: styles by · Adapts visuals to snack type and placement
- Snack UI → Type Details: renders from · Uses type defaults for colors, icons, and emphasis
- Snack UI → Snack Config: overrides · Applies caller-supplied appearance settings
- Example App → Snackify: imports · Demonstrates package usage in an app
- Tests → Snackify: verifies · Checks public API behavior
- README → Snackify: documents · Shows the primary usage contract
- README → Images: references · Uses documentation images
- README → Snack Images: references · Uses package imagery in docs
