# blink616/share architecture

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

- Interactive diagram: https://gitdiagram.com/blink616/share
- Repository: https://github.com/blink616/share

## Overview

1. **Overall shape**
   - This repo is a **hybrid Flutter + Unity AR application**.
   - Flutter owns the app shell, screens, and non-AR UI; Unity owns the real-time AR drawing experience.
   - The architecture is split into three main parts: `lib/` for Flutter, `unity/ardoodle/` for the Unity module, and `android/` / `ios/` for native packaging.

2. **Flutter presentation layer**
   - The Flutter app starts in `lib/main.dart` and is organized around screens in `lib/screens/`.
   - Key screens suggest the app flow: authentication (`loginscreen.dart`, `registrationscreen.dart`), home/navigation (`home.dart`), drawing entry points (`drawing.dart`, `ar_draw.dart`, `ar_controls.dart`), social browsing (`doodles.dart`), and map views (`map.dart`, `map-old.dart`).
   - Flutter is responsible for the app’s UI/UX, navigation, and any non-AR interactions.

3. **AR drawing subsystem**
   - The actual AR drawing mechanics live in Unity under `unity/ardoodle/Assets/Scripts/`.
   - `ARDraw.cs`, `ColorPicker.cs`, `Follow.cs`, and `OpenClose.cs` indicate Unity handles line creation, tool/color selection, object positioning, and toggling of AR UI elements.
   - The Unity scene set is centered on `SampleScene.unity`, with a `Line.prefab` used as the drawing primitive.

4. **Flutter ↔ Unity integration boundary**
   - The repo uses **flutter-unity-widget / FlutterUnityIntegration** to embed Unity inside Flutter.
   - That bridge is implemented by the integration assets in `unity/ardoodle/Assets/FlutterUnityIntegration/` and the Flutter-side screen(s) that host the Unity view.
   - This boundary is important: Flutter sends commands into Unity, and Unity can send messages back through the integration layer.

5. **Interaction/data flow**
   - A typical flow is: user enters the drawing experience in Flutter, Unity renders the AR canvas, the user creates a doodle, then Flutter handles the surrounding app actions such as sharing/uploading and browsing other drawings.
   - The README describes drawings being “uploaded,” “explored,” and “pinned on maps,” so the AR output is treated as a shareable artifact, not just a local rendering.

6. **Social/explore/map layer**
   - `lib/screens/doodles.dart` and the map screens indicate a discovery layer for browsing shared AR drawings.
   - The README says the Explore tab shows drawings within a **25-meter radius** of the user’s location, which implies location-aware filtering and geotagged content.
   - The map screens represent a separate visualization boundary: content is shown spatially rather than in the AR canvas itself.

7. **Domain models**
   - `lib/models/doodle_model.dart` and `lib/models/user_model.dart` define the app’s core data entities.
   - These models likely carry user identity, drawing metadata, and location-related fields needed by the explore/map features.
   - The model layer sits between the UI and whatever persistence or backend service is used.

8. **Native platform wrappers**
   - Android and iOS projects are present to package the Flutter app and host the embedded Unity runtime.
   - Android entrypoints include `MainActivity.kt` and standard Gradle setup; iOS includes `AppDelegate.swift`, `Podfile`, and `GoogleService-Info.plist`.
   - These platform projects are the boundary where Flutter, Unity, and any native plugins are assembled into runnable mobile apps.

9. **AR and device capability configuration**
   - Unity is configured with **AR Foundation**, **ARCore**, and **ARKit** assets, so the AR layer is cross-platform at the Unity level.
   - The Unity project contains loader/settings assets for both Android and iOS, showing that device AR support is a first-class concern.
   - The Flutter shell itself is not doing low-level AR; it delegates that capability to Unity.

10. **Assets and presentation resources**
   - Flutter assets live under `assets/` and `fonts/`, while Unity manages its own prefabs, scenes, icons, and plugin assets.
   - This means UI assets and AR scene assets are intentionally separated by runtime: Flutter assets for app chrome, Unity assets for immersive content.
   - The separation is important for drawing a diagram because the two runtimes do not share a single asset pipeline.

11. **Backend/service boundary**
   - The repo strongly suggests some remote storage or sync layer because drawings are uploaded and shared, but that implementation is not visible here.
   - For architecture purposes, treat persistence, authentication, and content retrieval as an external boundary behind the Flutter models/screens.
   - The visible code only shows the client-side front end and AR module, not the server.

12. **Other platform surfaces**
   - A `web/` directory exists, but the README is clearly centered on mobile AR, so web appears to be a Flutter scaffold rather than the primary runtime.
   - The main architecture to diagram is therefore **mobile-first**, with Flutter as the host and Unity as the AR engine.

Main entry points: [`unity/ardoodle/Assets/Scripts/ARDraw.cs`](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/ARDraw.cs) (ARDraw), [`unity/ardoodle/Assets/FlutterUnityIntegration`](https://github.com/blink616/share/tree/main/unity/ardoodle/Assets/FlutterUnityIntegration) (Unity bridge), [`lib/screens/home.dart`](https://github.com/blink616/share/blob/main/lib/screens/home.dart) (Home), [`lib/models/doodle_model.dart`](https://github.com/blink616/share/blob/main/lib/models/doodle_model.dart) (Doodle model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flutter["Flutter app"]
  node_main["Main app<br/>Flutter entry<br/>[main.dart]"]
  node_home["Home<br/>Flutter screen<br/>[home.dart]"]
  node_login["Login<br/>Flutter screen<br/>[loginscreen.dart]"]
  node_register["Register<br/>Flutter screen"]
  node_drawing["Drawing<br/>Flutter screen<br/>[drawing.dart]"]
  node_ar_draw_screen["AR draw<br/>Flutter screen<br/>[ar_draw.dart]"]
  node_ar_controls["AR controls<br/>Flutter screen<br/>[ar_controls.dart]"]
  node_doodles["Doodles<br/>Flutter screen<br/>[doodles.dart]"]
  node_map["Map<br/>Flutter screen<br/>[map.dart]"]
  node_map_old["Old map<br/>Flutter screen<br/>[map-old.dart]"]
  node_doodle_model["Doodle model<br/>Data model<br/>[doodle_model.dart]"]
  node_user_model["User model<br/>Data model<br/>[user_model.dart]"]
end

subgraph group_unity["Unity AR"]
  node_integration{{"Unity bridge<br/>Flutter-Unity integration"}}
  node_game_manager["Game manager<br/>Unity bridge script<br/>[GameManager.cs]"]
  node_ar_draw["ARDraw<br/>Unity AR script<br/>[ARDraw.cs]"]
  node_color_picker["Color picker<br/>Unity UI script<br/>[ColorPicker.cs]"]
  node_follow["Follow<br/>Unity scene script<br/>[Follow.cs]"]
  node_open_close["Open close<br/>Unity UI script<br/>[OpenClose.cs]"]
  node_sample_scene["Sample scene<br/>Unity scene<br/>[SampleScene.unity]"]
  node_line_prefab["Line prefab<br/>Unity prefab<br/>[Line.prefab]"]
end

subgraph group_native["Native packaging"]
  node_android_host["Android host<br/>Native Android project"]
  node_ios_host["iOS host<br/>Native iOS project"]
end

subgraph group_web["Web scaffold"]
  node_web_entry["Web entry<br/>Flutter web<br/>[index.html]"]
end

node_main -->|"starts"| node_home
node_home -->|"auth"| node_login
node_home -->|"auth"| node_register
node_home -->|"launch"| node_drawing
node_drawing -->|"AR entry"| node_ar_draw_screen
node_ar_draw_screen -->|"hosts"| node_integration
node_ar_controls -->|"controls"| node_integration
node_integration -->|"messages"| node_game_manager
node_game_manager -->|"coordinates"| node_ar_draw
node_ar_draw -->|"uses"| node_color_picker
node_ar_draw -->|"positions"| node_follow
node_ar_draw -->|"toggles"| node_open_close
node_ar_draw -->|"instantiates"| node_line_prefab
node_sample_scene -->|"contains"| node_ar_draw
node_sample_scene -->|"uses"| node_line_prefab
node_doodles -->|"reads"| node_doodle_model
node_map -->|"maps"| node_doodle_model
node_map_old -->|"maps"| node_doodle_model
node_login -->|"binds"| node_user_model
node_register -->|"creates"| node_user_model
node_android_host -->|"packages"| node_integration
node_ios_host -->|"packages"| node_integration
node_web_entry -->|"boots"| node_main

click node_main "https://github.com/blink616/share/blob/main/lib/main.dart"
click node_home "https://github.com/blink616/share/blob/main/lib/screens/home.dart"
click node_login "https://github.com/blink616/share/blob/main/lib/screens/loginscreen.dart"
click node_register "https://github.com/blink616/share/blob/main/lib/screens/registrationscreen.dart"
click node_drawing "https://github.com/blink616/share/blob/main/lib/screens/drawing.dart"
click node_ar_draw_screen "https://github.com/blink616/share/blob/main/lib/screens/ar_draw.dart"
click node_ar_controls "https://github.com/blink616/share/blob/main/lib/screens/ar_controls.dart"
click node_doodles "https://github.com/blink616/share/blob/main/lib/screens/doodles.dart"
click node_map "https://github.com/blink616/share/blob/main/lib/screens/map.dart"
click node_map_old "https://github.com/blink616/share/blob/main/lib/screens/map-old.dart"
click node_doodle_model "https://github.com/blink616/share/blob/main/lib/models/doodle_model.dart"
click node_user_model "https://github.com/blink616/share/blob/main/lib/models/user_model.dart"
click node_integration "https://github.com/blink616/share/tree/main/unity/ardoodle/Assets/FlutterUnityIntegration"
click node_game_manager "https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/FlutterUnityIntegration/GameManager.cs"
click node_ar_draw "https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/ARDraw.cs"
click node_color_picker "https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/ColorPicker.cs"
click node_follow "https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/Follow.cs"
click node_open_close "https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/OpenClose.cs"
click node_sample_scene "https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scenes/SampleScene.unity"
click node_line_prefab "https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Prefab/Line.prefab"
click node_android_host "https://github.com/blink616/share/tree/main/android"
click node_ios_host "https://github.com/blink616/share/tree/main/ios"
click node_web_entry "https://github.com/blink616/share/blob/main/web/index.html"

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_main,node_home,node_login,node_register,node_drawing,node_ar_draw_screen,node_ar_controls,node_doodles,node_map,node_map_old,node_doodle_model,node_user_model toneBlue
class node_integration,node_game_manager,node_ar_draw,node_color_picker,node_follow,node_open_close,node_sample_scene,node_line_prefab toneAmber
class node_android_host,node_ios_host toneMint
class node_web_entry toneRose
```

## Components

### Flutter app

Mobile shell, screens, and domain models.

- [Main app](https://github.com/blink616/share/blob/main/lib/main.dart): Flutter entry · Bootstraps the Flutter application and app shell. · `lib/main.dart`
- [Home](https://github.com/blink616/share/blob/main/lib/screens/home.dart): Flutter screen · Primary navigation and launch hub. · `lib/screens/home.dart`
- [Login](https://github.com/blink616/share/blob/main/lib/screens/loginscreen.dart): Flutter screen · Authentication entry screen. · `lib/screens/loginscreen.dart`
- [Register](https://github.com/blink616/share/blob/main/lib/screens/registrationscreen.dart): Flutter screen · Account creation screen. · `lib/screens/registrationscreen.dart`
- [Drawing](https://github.com/blink616/share/blob/main/lib/screens/drawing.dart): Flutter screen · Entry point into the drawing experience. · `lib/screens/drawing.dart`
- [AR draw](https://github.com/blink616/share/blob/main/lib/screens/ar_draw.dart): Flutter screen · Hosts or routes into the Unity AR view. · `lib/screens/ar_draw.dart`
- [AR controls](https://github.com/blink616/share/blob/main/lib/screens/ar_controls.dart): Flutter screen · Surrounding UI for AR tool controls. · `lib/screens/ar_controls.dart`
- [Doodles](https://github.com/blink616/share/blob/main/lib/screens/doodles.dart): Flutter screen · Browse and discover shared drawings. · `lib/screens/doodles.dart`
- [Map](https://github.com/blink616/share/blob/main/lib/screens/map.dart): Flutter screen · Geographic view for nearby shared content. · `lib/screens/map.dart`
- [Old map](https://github.com/blink616/share/blob/main/lib/screens/map-old.dart): Flutter screen · Legacy map view kept alongside the current one. · `lib/screens/map-old.dart`
- [Doodle model](https://github.com/blink616/share/blob/main/lib/models/doodle_model.dart): Data model · Drawing metadata and location-aware content shape. · `lib/models/doodle_model.dart`
- [User model](https://github.com/blink616/share/blob/main/lib/models/user_model.dart): Data model · User identity and profile data used by the app. · `lib/models/user_model.dart`

### Unity AR

Embedded AR drawing runtime and scene assets.

- [Unity bridge](https://github.com/blink616/share/tree/main/unity/ardoodle/Assets/FlutterUnityIntegration): Flutter-Unity integration · Messaging and embedding layer connecting Flutter and Unity. · `unity/ardoodle/Assets/FlutterUnityIntegration`
- [Game manager](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/FlutterUnityIntegration/GameManager.cs): Unity bridge script · Integration-side coordination for messages and runtime state. · `unity/ardoodle/Assets/FlutterUnityIntegration/GameManager.cs`
- [ARDraw](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/ARDraw.cs): Unity AR script · Core AR drawing logic and line creation. · `unity/ardoodle/Assets/Scripts/ARDraw.cs`
- [Color picker](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/ColorPicker.cs): Unity UI script · Tool and color selection for drawing. · `unity/ardoodle/Assets/Scripts/ColorPicker.cs`
- [Follow](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/Follow.cs): Unity scene script · Positions or tracks AR elements in the scene. · `unity/ardoodle/Assets/Scripts/Follow.cs`
- [Open close](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scripts/OpenClose.cs): Unity UI script · Toggles AR interface elements open and closed. · `unity/ardoodle/Assets/Scripts/OpenClose.cs`
- [Sample scene](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Scenes/SampleScene.unity): Unity scene · Main Unity scene for the AR doodle experience. · `unity/ardoodle/Assets/Scenes/SampleScene.unity`
- [Line prefab](https://github.com/blink616/share/blob/main/unity/ardoodle/Assets/Prefab/Line.prefab): Unity prefab · Reusable drawing primitive instantiated in AR. · `unity/ardoodle/Assets/Prefab/Line.prefab`

### Native packaging

Android and iOS host projects for the combined app.

- [Android host](https://github.com/blink616/share/tree/main/android): Native Android project · Android packaging and launch entry for the app. · `android`
- [iOS host](https://github.com/blink616/share/tree/main/ios): Native iOS project · iOS packaging and launch entry for the app. · `ios`

### Web scaffold

Flutter web entry surface present in the repo.

- [Web entry](https://github.com/blink616/share/blob/main/web/index.html): Flutter web · Web scaffold and browser entry surface. · `web/index.html`

## Connections

- Main app → Home: starts · Launches the app into the main navigation flow.
- Home → Login: auth · Routes to sign-in.
- Home → Register: auth · Routes to account creation.
- Home → Drawing: launch · Enters the drawing experience.
- Drawing → AR draw: AR entry · Moves from app flow into the AR drawing screen.
- AR draw → Unity bridge: hosts · Embeds the Unity runtime inside Flutter.
- AR controls → Unity bridge: controls · Sends UI actions into the embedded Unity view.
- Unity bridge → Game manager: messages · Bridges Flutter commands and Unity runtime state.
- Game manager → ARDraw: coordinates · Delegates drawing behavior to the AR script.
- ARDraw → Color picker: uses · Consumes selected tools and colors.
- ARDraw → Follow: positions · Relies on scene tracking and object placement.
- ARDraw → Open close: toggles · Shows or hides AR controls.
- ARDraw → Line prefab: instantiates · Creates drawn strokes from the line prefab.
- Sample scene → ARDraw: contains · Scene wires in the core AR script.
- Sample scene → Line prefab: uses · References the drawing primitive.
- Doodles → Doodle model: reads · Uses doodle metadata for browse and explore views.
- Map → Doodle model: maps · Visualizes location-bound doodles.
- Old map → Doodle model: maps · Legacy map visualization over the same data.
- Login → User model: binds · Authenticates against user data shape.
- Register → User model: creates · Creates new user records.
- Android host → Unity bridge: packages · Bundles the Flutter app with the Unity module on Android.
- iOS host → Unity bridge: packages · Bundles the Flutter app with the Unity module on iOS.
- Web entry → Main app: boots · Browser scaffold points to the Flutter app entry.
