# kryptokrona/hugin-native architecture

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

- Interactive diagram: https://gitdiagram.com/kryptokrona/hugin-native
- Repository: https://github.com/kryptokrona/hugin-native

## Overview

Hugin is a React Native mobile app for decentralized messaging, group chat, voice/video calling, file sharing, and a Kryptokrona wallet. The user enters through the app shell and navigates authentication and main screens; messaging and wallet capabilities are backed by JavaScript services and a Bare runtime, with persistent client state and native crypto support. The excerpts show app startup, persisted stores, RPC dispatch, and peer-file storage; many screen-to-service connections are not sampled, so those links are left out rather than inferred.

Main entry points: [`bare/main.js`](https://github.com/kryptokrona/hugin-native/blob/master/bare/main.js) (Bare RPC handler), [`src/App.tsx`](https://github.com/kryptokrona/hugin-native/blob/master/src/App.tsx) (App shell), [`src/components/_navigation/root-navigator.tsx`](https://github.com/kryptokrona/hugin-native/blob/master/src/components/_navigation/root-navigator.tsx) (Navigation), [`src/screens`](https://github.com/kryptokrona/hugin-native/tree/master/src/screens) (Messaging and wallet screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Mobile app"]
  node_entry["App entry<br/>[index.js]"]
  node_app_shell["App shell<br/>[App.tsx]"]
  node_navigation["Navigation<br/>[root-navigator.tsx]"]
  node_auth_screens["Account screens"]
  node_main_screens["Messaging and wallet screens"]
end

subgraph group_messaging["Messaging runtime"]
  node_bare_bridge["Bare RPC handler<br/>[main.js]"]
  node_bare_swarm["Peer messaging<br/>[swarm.js]"]
  node_bare_account["Account runtime<br/>[account.js]"]
  node_file_storage[("Peer file storage<br/>[storage.js]")]
  node_bare_messages["Message operations<br/>[messages.js]"]
  node_bare_rpc["RPC client<br/>[rpc.js]"]
  node_bare_service["Bare service"]
  node_call_service["Call service"]
end

subgraph group_wallet["Wallet"]
  node_wallet_service["Wallet service"]
end

subgraph group_state["Identity and state"]
  node_hugin_identity["Hugin identity"]
  node_persisted_state[("Persisted app state")]
end

subgraph group_native["Native support"]
  node_native_crypto["Native crypto<br/>[kryptokrona.cpp]"]
  node_native_module["Native bridge"]
end

node_user(("Mobile user"))
node_peer_network(("Peer network"))
node_wallet_network(("Kryptokrona network"))

node_user -->|"opens app"| node_entry
node_entry -->|"renders"| node_app_shell
node_app_shell -->|"mounts"| node_navigation
node_navigation -->|"routes"| node_auth_screens
node_navigation -->|"routes"| node_main_screens
node_app_shell -->|"reads theme"| node_persisted_state
node_bare_bridge -->|"initializes"| node_bare_account
node_bare_bridge -->|"dispatches message work"| node_bare_messages
node_bare_bridge -->|"dispatches peer work"| node_bare_swarm
node_bare_bridge -->|"dispatches file work"| node_file_storage
node_bare_swarm -->|"communicates"| node_peer_network
node_file_storage -->|"shares files"| node_peer_network
node_bare_rpc -->|"sends requests"| node_bare_bridge
node_bare_service -->|"uses RPC"| node_bare_rpc
node_bare_messages -->|"sends messages"| node_peer_network
node_main_screens -->|"wallet actions"| node_wallet_service
node_wallet_service -->|"queries and submits"| node_wallet_network
node_main_screens -->|"call features"| node_call_service
node_bare_account -->|"uses identity"| node_hugin_identity
node_native_module -->|"invokes"| node_native_crypto

click node_entry "https://github.com/kryptokrona/hugin-native/blob/master/index.js"
click node_app_shell "https://github.com/kryptokrona/hugin-native/blob/master/src/App.tsx"
click node_navigation "https://github.com/kryptokrona/hugin-native/blob/master/src/components/_navigation/root-navigator.tsx"
click node_auth_screens "https://github.com/kryptokrona/hugin-native/tree/master/src/screens/_auth-screens"
click node_main_screens "https://github.com/kryptokrona/hugin-native/tree/master/src/screens"
click node_bare_bridge "https://github.com/kryptokrona/hugin-native/blob/master/bare/main.js"
click node_bare_swarm "https://github.com/kryptokrona/hugin-native/blob/master/bare/swarm.js"
click node_bare_account "https://github.com/kryptokrona/hugin-native/blob/master/bare/account.js"
click node_file_storage "https://github.com/kryptokrona/hugin-native/blob/master/bare/storage.js"
click node_bare_messages "https://github.com/kryptokrona/hugin-native/blob/master/bare/messages.js"
click node_bare_rpc "https://github.com/kryptokrona/hugin-native/blob/master/src/lib/rpc.js"
click node_bare_service "https://github.com/kryptokrona/hugin-native/tree/master/src/services/bare"
click node_wallet_service "https://github.com/kryptokrona/hugin-native/tree/master/src/services/kryptokrona"
click node_call_service "https://github.com/kryptokrona/hugin-native/tree/master/src/services/calls"
click node_hugin_identity "https://github.com/kryptokrona/hugin-native/tree/master/src/services/hugin"
click node_persisted_state "https://github.com/kryptokrona/hugin-native/blob/master/src/services/zustand/async-storage-stores.ts"
click node_native_crypto "https://github.com/kryptokrona/hugin-native/blob/master/android/app/src/main/jni/kryptokrona.cpp"
click node_native_module "https://github.com/kryptokrona/hugin-native/blob/master/android/app/src/main/java/com/hugin/TurtleCoinModule.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_entry,node_app_shell,node_navigation,node_auth_screens,node_main_screens,node_user toneBlue
class node_bare_bridge,node_bare_swarm,node_bare_account,node_file_storage,node_bare_messages,node_bare_rpc,node_bare_service,node_call_service toneAmber
class node_wallet_service toneMint
class node_hugin_identity,node_persisted_state toneRose
class node_native_crypto,node_native_module,node_peer_network,node_wallet_network toneIndigo
```

## Components

### Mobile app

- [App entry](https://github.com/kryptokrona/hugin-native/blob/master/index.js): `index.js`
- [App shell](https://github.com/kryptokrona/hugin-native/blob/master/src/App.tsx): `src/App.tsx`
- [Navigation](https://github.com/kryptokrona/hugin-native/blob/master/src/components/_navigation/root-navigator.tsx): `src/components/_navigation/root-navigator.tsx`
- [Account screens](https://github.com/kryptokrona/hugin-native/tree/master/src/screens/_auth-screens): `src/screens/_auth-screens`
- [Messaging and wallet screens](https://github.com/kryptokrona/hugin-native/tree/master/src/screens): `src/screens`

### Messaging runtime

- [Bare RPC handler](https://github.com/kryptokrona/hugin-native/blob/master/bare/main.js): `bare/main.js`
- [Peer messaging](https://github.com/kryptokrona/hugin-native/blob/master/bare/swarm.js): `bare/swarm.js`
- [Account runtime](https://github.com/kryptokrona/hugin-native/blob/master/bare/account.js): `bare/account.js`
- [Peer file storage](https://github.com/kryptokrona/hugin-native/blob/master/bare/storage.js): `bare/storage.js`
- [Message operations](https://github.com/kryptokrona/hugin-native/blob/master/bare/messages.js): `bare/messages.js`
- [RPC client](https://github.com/kryptokrona/hugin-native/blob/master/src/lib/rpc.js): `src/lib/rpc.js`
- [Bare service](https://github.com/kryptokrona/hugin-native/tree/master/src/services/bare): `src/services/bare`
- [Call service](https://github.com/kryptokrona/hugin-native/tree/master/src/services/calls): `src/services/calls`

### Wallet

- [Wallet service](https://github.com/kryptokrona/hugin-native/tree/master/src/services/kryptokrona): `src/services/kryptokrona`

### Identity and state

- [Hugin identity](https://github.com/kryptokrona/hugin-native/tree/master/src/services/hugin): `src/services/hugin`
- [Persisted app state](https://github.com/kryptokrona/hugin-native/blob/master/src/services/zustand/async-storage-stores.ts): `src/services/zustand/async-storage-stores.ts`

### Native support

- [Native crypto](https://github.com/kryptokrona/hugin-native/blob/master/android/app/src/main/jni/kryptokrona.cpp): `android/app/src/main/jni/kryptokrona.cpp`
- [Native bridge](https://github.com/kryptokrona/hugin-native/blob/master/android/app/src/main/java/com/hugin/TurtleCoinModule.java): `android/app/src/main/java/com/hugin/TurtleCoinModule.java`

### Other components

- **Mobile user**
- **Peer network**
- **Kryptokrona network**

## Connections

- Mobile user → App entry: opens app
- App entry → App shell: renders
- App shell → Navigation: mounts
- Navigation → Account screens: routes
- Navigation → Messaging and wallet screens: routes
- App shell → Persisted app state: reads theme
- Bare RPC handler → Account runtime: initializes
- Bare RPC handler → Message operations: dispatches message work
- Bare RPC handler → Peer messaging: dispatches peer work
- Bare RPC handler → Peer file storage: dispatches file work
- Peer messaging → Peer network: communicates
- Peer file storage → Peer network: shares files
- RPC client → Bare RPC handler: sends requests
- Bare service → RPC client: uses RPC
- Message operations → Peer network: sends messages
- Messaging and wallet screens → Wallet service: wallet actions
- Wallet service → Kryptokrona network: queries and submits
- Messaging and wallet screens → Call service: call features
- Account runtime → Hugin identity: uses identity
- Native bridge → Native crypto: invokes
