# golden2710/chatnet architecture

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

- Interactive diagram: https://gitdiagram.com/golden2710/chatnet
- Repository: https://github.com/golden2710/chatnet

## Overview

ChatNET is a React Native peer-to-peer messenger: users configure a peer address and shared encryption settings, then send text or selected images over TCP; the receiving app reassembles frames, decrypts messages, and displays them. App.tsx owns the main UI and networking workflow, while utility modules provide encryption, framing, and file handling. README documents additional behaviors such as auto-delete, usernames, and recents, but excerpts do not expose all their internal wiring; those links are omitted where unverified.

Main entry points: [`App.tsx`](https://github.com/golden2710/chatnet/blob/main/App.tsx) (Chat UI and workflow), [`index.js`](https://github.com/golden2710/chatnet/blob/main/index.js) (React Native entry), [`src/utils/fileHandler.ts`](https://github.com/golden2710/chatnet/blob/main/src/utils/fileHandler.ts) (File validation and protocol), [`src/utils/framing.ts`](https://github.com/golden2710/chatnet/blob/main/src/utils/framing.ts) (TCP framing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_entry["React Native entry<br/>[index.js]"]
  node_chat["Chat UI and workflow<br/>[App.tsx]"]
end

subgraph group_transport["Peer Transport"]
  node_tcp["TCP socket"]
  node_framing["TCP framing<br/>[framing.ts]"]
end

subgraph group_security["Encryption"]
  node_aes["AES encryption<br/>[aesEncryption.ts]"]
  node_des["DES encryption<br/>[desEncryption.ts]"]
  node_caesar["Caesar cipher<br/>[caesarCipher.ts]"]
  node_rsa["RSA-like encryption<br/>[rsaEncryption.ts]"]
  node_signature["HMAC signature helper"]
end

subgraph group_files["Image and File Handling"]
  node_files["File validation and protocol<br/>[fileHandler.ts]"]
  node_picker["Image library picker"]
end

node_user(("Chat user"))
node_peer(("Peer device"))

node_user -->|"opens app"| node_entry
node_entry -->|"registers"| node_chat
node_user -->|"configures and chats"| node_chat
node_chat -->|"encrypts with"| node_aes
node_chat -->|"encrypts with"| node_des
node_chat -->|"encrypts with"| node_caesar
node_chat -->|"encrypts with"| node_rsa
node_chat -->|"frames and decodes"| node_framing
node_chat -->|"connects and writes"| node_tcp
node_tcp -->|"transfers payloads"| node_peer
node_peer -->|"sends payloads"| node_tcp
node_chat -->|"opens image picker"| node_picker
node_chat -->|"records recents"| node_files
node_chat -.->|"builds file messages"| node_files

click node_entry "https://github.com/golden2710/chatnet/blob/main/index.js"
click node_chat "https://github.com/golden2710/chatnet/blob/main/App.tsx"
click node_framing "https://github.com/golden2710/chatnet/blob/main/src/utils/framing.ts"
click node_aes "https://github.com/golden2710/chatnet/blob/main/src/utils/aesEncryption.ts"
click node_des "https://github.com/golden2710/chatnet/blob/main/src/utils/desEncryption.ts"
click node_caesar "https://github.com/golden2710/chatnet/blob/main/src/utils/caesarCipher.ts"
click node_rsa "https://github.com/golden2710/chatnet/blob/main/src/utils/rsaEncryption.ts"
click node_files "https://github.com/golden2710/chatnet/blob/main/src/utils/fileHandler.ts"
click node_signature "https://github.com/golden2710/chatnet/blob/main/src/utils/digitalSignature.ts"

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_chat,node_user toneBlue
class node_tcp,node_framing toneAmber
class node_aes,node_des,node_caesar,node_rsa,node_signature toneMint
class node_files,node_picker toneRose
class node_peer toneIndigo
```

## Components

### Application

- [React Native entry](https://github.com/golden2710/chatnet/blob/main/index.js): `index.js`
- [Chat UI and workflow](https://github.com/golden2710/chatnet/blob/main/App.tsx): `App.tsx`

### Peer Transport

- **TCP socket**
- [TCP framing](https://github.com/golden2710/chatnet/blob/main/src/utils/framing.ts): `src/utils/framing.ts`

### Encryption

- [AES encryption](https://github.com/golden2710/chatnet/blob/main/src/utils/aesEncryption.ts): `src/utils/aesEncryption.ts`
- [DES encryption](https://github.com/golden2710/chatnet/blob/main/src/utils/desEncryption.ts): `src/utils/desEncryption.ts`
- [Caesar cipher](https://github.com/golden2710/chatnet/blob/main/src/utils/caesarCipher.ts): `src/utils/caesarCipher.ts`
- [RSA-like encryption](https://github.com/golden2710/chatnet/blob/main/src/utils/rsaEncryption.ts): `src/utils/rsaEncryption.ts`
- [HMAC signature helper](https://github.com/golden2710/chatnet/blob/main/src/utils/digitalSignature.ts): `src/utils/digitalSignature.ts`

### Image and File Handling

- [File validation and protocol](https://github.com/golden2710/chatnet/blob/main/src/utils/fileHandler.ts): `src/utils/fileHandler.ts`
- **Image library picker**

### Other components

- **Chat user**
- **Peer device**

## Connections

- Chat user → React Native entry: opens app (evidence: `README.md`)
- React Native entry → Chat UI and workflow: registers (evidence: `index.js`)
- Chat user → Chat UI and workflow: configures and chats (evidence: `README.md`)
- Chat UI and workflow → AES encryption: encrypts with (evidence: `App.tsx`)
- Chat UI and workflow → DES encryption: encrypts with (evidence: `App.tsx`)
- Chat UI and workflow → Caesar cipher: encrypts with (evidence: `App.tsx`)
- Chat UI and workflow → RSA-like encryption: encrypts with (evidence: `App.tsx`)
- Chat UI and workflow → TCP framing: frames and decodes (evidence: `App.tsx`)
- Chat UI and workflow → TCP socket: connects and writes (evidence: `App.tsx`)
- TCP socket → Peer device: transfers payloads (evidence: `README.md`)
- Peer device → TCP socket: sends payloads (evidence: `README.md`)
- Chat UI and workflow → Image library picker: opens image picker (evidence: `App.tsx`)
- Chat UI and workflow → File validation and protocol: records recents (evidence: `App.tsx`)
- Chat UI and workflow → File validation and protocol: builds file messages (evidence: `App.tsx`)
