# reyaansh72/lan-chat-android architecture

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

- Interactive diagram: https://gitdiagram.com/reyaansh72/lan-chat-android
- Repository: https://github.com/reyaansh72/lan-chat-android

## Overview

1. **Project shape**
   - This is a **single-module native Android app** (`app/`) built with **Gradle** and standard Android Studio tooling.
   - The repository is a companion client for the separate **LAN-Chat Node.js backend**, so the main architectural boundary is **Android UI/client code on one side** and **networked chat server access on the other**.

2. **Startup and application lifecycle**
   - `SketchApplication` is the app-level `Application` subclass, which is the natural place for global initialization.
   - The manifest and activity set imply a conventional Android launch flow rather than a multi-module or service-heavy architecture.

3. **Primary user flow**
   - The app is centered around a **manual connection flow**: the user enters a server **IP address and port**, then joins the chat system.
   - After connection, the app transitions into the main chat/home experience. This makes the architecture essentially **connection setup → active session UI**.

4. **UI entry screen**
   - `MainActivity` plus `main.xml` / `MainBinding` appear to implement the initial connection screen.
   - This is where the app likely collects connection parameters and triggers the join action toward the backend.

5. **Connected/home screen**
   - `HomeActivity` plus `home.xml` / `HomeBinding` represent the post-connection chat surface.
   - This is the main interaction layer for real-time messaging and session-level chat behavior once the server connection is established.

6. **Debug/diagnostic surface**
   - `DebugActivity` suggests a separate screen for troubleshooting or developer-focused inspection.
   - Architecturally, this is a supporting boundary rather than a core user path, likely used during development or runtime debugging.

7. **Networking boundary**
   - The Android app does not appear to host backend logic itself; instead, it connects outward to an externally running **LAN-Chat backend**.
   - The server is user-supplied at runtime via IP/port, so the app is a **thin client** that depends on a reachable local-network backend instance.

8. **Code generation / view binding**
   - `MainBinding` and `HomeBinding` indicate **view/data binding** is used for UI wiring.
   - This means the activities are likely connected to layouts through generated binding classes rather than manual `findViewById` usage, simplifying the UI-to-code boundary.

9. **Support utilities**
   - `FileUtil`, `SketchLogger`, and `SketchwareUtil` are utility/support classes carried over from the project’s Sketchware origin.
   - These likely provide shared helpers, logging, and convenience methods used across activities rather than representing separate subsystems.

10. **Resources and presentation**
   - The `res/` tree contains the usual Android presentation assets: layouts, colors, strings, styles, and an icon drawable.
   - This suggests a fairly compact UI-focused app with no separate asset pipeline or complex media subsystem.

11. **Runtime and platform constraints**
   - The app targets modern Android via Gradle, with **min SDK 21** and **target SDK 34** per the README.
   - That places the architecture squarely in the standard Android app runtime, with lifecycle-aware components replacing the original Sketchware prototype structure.

12. **What is not present**
   - There is no sign of local databases, background workers, multiple modules, or embedded server logic in this repository.
   - So the diagram should emphasize a **client-only Android UI application** that connects to an external LAN backend, rather than a full distributed system inside this repo.

Main entry points: [`app/src/main/java/com/reyaansh72/lanchat/MainActivity.java`](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/MainActivity.java) (Connect screen), [`app/src/main/java/com/reyaansh72/lanchat/HomeActivity.java`](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/HomeActivity.java) (Chat screen), [`app`](https://github.com/reyaansh72/lan-chat-android/tree/main/app) (app module), [`app/src/main/res/values`](https://github.com/reyaansh72/lan-chat-android/tree/main/app/src/main/res/values) (Theme)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_app["Android app"]
  node_n_app["app module<br/>Gradle module"]
  node_n_manifest["Manifest"]
end

subgraph group_grp_ui["UI flow"]
  node_n_main["Connect screen<br/>Activity<br/>[MainActivity.java]"]
  node_n_home["Chat screen<br/>Activity<br/>[HomeActivity.java]"]
  node_n_debug["Debug screen<br/>Activity<br/>[DebugActivity.java]"]
  node_n_mainbind["Main binding<br/>ViewBinding<br/>[MainBinding.java]"]
  node_n_homebind["Home binding<br/>ViewBinding<br/>[HomeBinding.java]"]
end

subgraph group_grp_support["Support code"]
  node_n_appclass["App init"]
  node_n_fileutil["File util<br/>[FileUtil.java]"]
  node_n_logger["Logger<br/>[SketchLogger.java]"]
  node_n_sketchutil["Sketch util"]
end

subgraph group_grp_res["Resources"]
  node_n_mainxml["main layout<br/>XML layout<br/>[main.xml]"]
  node_n_homexml["home layout<br/>XML layout<br/>[home.xml]"]
  node_n_styles["Theme<br/>Android resources"]
  node_n_icon["Logout icon<br/>Drawable asset"]
end

subgraph group_grp_ext["External backend"]
  node_n_backend[("LAN backend<br/>External server")]
end

node_n_app -->|"declares"| node_n_manifest
node_n_app -->|"boots"| node_n_appclass
node_n_app -->|"includes"| node_n_main
node_n_app -->|"includes"| node_n_home
node_n_app -->|"includes"| node_n_debug
node_n_main -->|"uses"| node_n_mainbind
node_n_home -->|"uses"| node_n_homebind
node_n_mainbind -->|"binds"| node_n_mainxml
node_n_homebind -->|"binds"| node_n_homexml
node_n_main -->|"connects to"| node_n_backend
node_n_home -->|"messaging"| node_n_backend
node_n_main -->|"transitions to"| node_n_home
node_n_appclass -->|"launches"| node_n_main
node_n_debug -->|"diagnoses"| node_n_logger
node_n_main -->|"helpers"| node_n_sketchutil
node_n_home -->|"helpers"| node_n_fileutil
node_n_home -->|"renders"| node_n_icon
node_n_styles -->|"styles"| node_n_mainxml
node_n_styles -->|"styles"| node_n_homexml

click node_n_app "https://github.com/reyaansh72/lan-chat-android/tree/main/app"
click node_n_manifest "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/AndroidManifest.xml"
click node_n_appclass "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/SketchApplication.java"
click node_n_main "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/MainActivity.java"
click node_n_home "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/HomeActivity.java"
click node_n_debug "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/DebugActivity.java"
click node_n_mainbind "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/databinding/MainBinding.java"
click node_n_homebind "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/databinding/HomeBinding.java"
click node_n_mainxml "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/res/layout/main.xml"
click node_n_homexml "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/res/layout/home.xml"
click node_n_styles "https://github.com/reyaansh72/lan-chat-android/tree/main/app/src/main/res/values"
click node_n_icon "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/res/drawable-xhdpi/icon_logout_round.xml"
click node_n_fileutil "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/FileUtil.java"
click node_n_logger "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/SketchLogger.java"
click node_n_sketchutil "https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/SketchwareUtil.java"

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_n_app,node_n_manifest toneBlue
class node_n_main,node_n_home,node_n_debug,node_n_mainbind,node_n_homebind toneAmber
class node_n_appclass,node_n_fileutil,node_n_logger,node_n_sketchutil toneMint
class node_n_mainxml,node_n_homexml,node_n_styles,node_n_icon toneRose
class node_n_backend toneIndigo
```

## Components

### Android app

Native single-module Android client

- [app module](https://github.com/reyaansh72/lan-chat-android/tree/main/app): Gradle module · Single Android application module · `app`
- [Manifest](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/AndroidManifest.xml): Android manifest · Declares app entry points and components · `app/src/main/AndroidManifest.xml`

### UI flow

Connection setup and chat screens

- [Connect screen](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/MainActivity.java): Activity · Initial server IP and port connection flow · `app/src/main/java/com/reyaansh72/lanchat/MainActivity.java`
- [Chat screen](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/HomeActivity.java): Activity · Main post-connection chat experience · `app/src/main/java/com/reyaansh72/lanchat/HomeActivity.java`
- [Debug screen](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/DebugActivity.java): Activity · Developer or troubleshooting surface · `app/src/main/java/com/reyaansh72/lanchat/DebugActivity.java`
- [Main binding](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/databinding/MainBinding.java): ViewBinding · Generated binding for the connect layout · `app/src/main/java/com/reyaansh72/lanchat/databinding/MainBinding.java`
- [Home binding](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/databinding/HomeBinding.java): ViewBinding · Generated binding for the chat layout · `app/src/main/java/com/reyaansh72/lanchat/databinding/HomeBinding.java`

### Support code

Shared utilities and app bootstrap

- [App init](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/SketchApplication.java): Application · Global application startup and initialization · `app/src/main/java/com/reyaansh72/lanchat/SketchApplication.java`
- [File util](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/FileUtil.java): Utility · Shared helper functions · `app/src/main/java/com/reyaansh72/lanchat/FileUtil.java`
- [Logger](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/SketchLogger.java): Utility · App logging support · `app/src/main/java/com/reyaansh72/lanchat/SketchLogger.java`
- [Sketch util](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/java/com/reyaansh72/lanchat/SketchwareUtil.java): Utility · Sketchware-origin helper methods · `app/src/main/java/com/reyaansh72/lanchat/SketchwareUtil.java`

### Resources

Layouts and presentation assets

- [main layout](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/res/layout/main.xml): XML layout · Connection screen presentation · `app/src/main/res/layout/main.xml`
- [home layout](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/res/layout/home.xml): XML layout · Chat screen presentation · `app/src/main/res/layout/home.xml`
- [Theme](https://github.com/reyaansh72/lan-chat-android/tree/main/app/src/main/res/values): Android resources · Shared colors, strings, and styles · `app/src/main/res/values`
- [Logout icon](https://github.com/reyaansh72/lan-chat-android/blob/main/app/src/main/res/drawable-xhdpi/icon_logout_round.xml): Drawable asset · UI icon asset used in presentation · `app/src/main/res/drawable-xhdpi/icon_logout_round.xml`

### External backend

Separate LAN-Chat server reached at runtime

- **LAN backend**: External server · Separate Node.js chat server reached over LAN

## Connections

- app module → Manifest: declares · Module packages the Android app manifest
- app module → App init: boots · Application class is part of the app runtime
- app module → Connect screen: includes · Primary launch activity
- app module → Chat screen: includes · Main chat activity
- app module → Debug screen: includes · Supporting debug activity
- Connect screen → Main binding: uses · Connect screen uses generated binding
- Chat screen → Home binding: uses · Chat screen uses generated binding
- Main binding → main layout: binds · Generated from main layout
- Home binding → home layout: binds · Generated from home layout
- Connect screen → LAN backend: connects to · User enters IP and port to join server
- Chat screen → LAN backend: messaging · Active chat session communicates with backend
- Connect screen → Chat screen: transitions to · Connection flow leads into chat session
- App init → Connect screen: launches · Initial app flow starts at the connect screen
- Debug screen → Logger: diagnoses · Debug surface is supported by logging
- Connect screen → Sketch util: helpers · UI flow may reuse shared convenience utilities
- Chat screen → File util: helpers · Chat screen may reuse shared file helpers
- Chat screen → Logout icon: renders · Home UI uses presentation assets
- Theme → main layout: styles · Shared resources style the connect screen
- Theme → home layout: styles · Shared resources style the chat screen
