How swadesh-c0de/dchat works
dChat is a wallet-based decentralized communications app. A user connects a wallet, the chat page initializes an XMTP client, and the chat experience supports encrypted conversations, real-time message synchronization, peer-to-peer calls, and encrypted IPFS attachments. The README documents profiles and message revocation as additional capabilities. Some wiring and subsystem implementations were not included in the sampled source, so links to those are limited to documented capabilities and visible codec registration.
Main entry points: useWebRTC.ts WebRTC call state · messages.ts Message operations · client.ts XMTP client · ChatWindow.tsx Conversation view
Components 21
Client Experience
- Chat entry
src/app/chat/page.tsx - Chat workspace
src/components/chat/ChatLayout.tsx - Conversation view
src/components/chat/ChatWindow.tsx - Conversation list
src/components/chat/ChatSidebar.tsx - Message composer
src/components/chat/MessageInput.tsx
XMTP Messaging
- XMTP client
src/lib/xmtp/client.ts - Conversation operations
src/lib/xmtp/conversations.ts - Message operations
src/lib/xmtp/messages.ts - Message synchronization
src/hooks/useMessagesSync.ts - Conversation display
src/hooks/useConversationDisplay.ts
Peer Calls
- WebRTC call state
src/hooks/useWebRTC.ts - Call controls
src/components/chat/VideoCallModal.tsx - Incoming call prompt
src/components/chat/IncomingCallModal.tsx - ICE configuration
src/app/api/turn/route.ts - Call codec
src/lib/xmtp/codecs/CallCodec.ts
Encrypted Attachments
- Attachment handling
src/lib/ipfs.ts
Profiles and Revocation
- Profile codec
src/lib/xmtp/codecs/ProfileCodec.ts - Delete codec
src/lib/xmtp/codecs/DeleteCodec.ts
Other components
- Wallet user
- XMTP network
- Pinata IPFS
Connections 28
- Wallet user → Chat entry: connects wallet
- Chat entry → XMTP client: initializes
- Chat entry → Chat workspace: renders
- Chat workspace → Conversation list: shows conversations
- Chat workspace → Conversation view: shows messages
- Conversation view → Message synchronization: syncs messages
- Conversation view → Conversation display: resolves display
- Conversation view → Message composer: composes messages
- XMTP client → XMTP network: creates client
- XMTP client → Call codec: registers codec
- XMTP client → Delete codec: registers codec
- XMTP client → Profile codec: registers codec
- Conversation list → Conversation operations: loads conversations
- Message composer → Message operations: sends messages
- Message synchronization → Message operations: fetches and streams
- Message operations → XMTP network: exchanges messages
- Conversation display → Profile codec: uses profile content
- WebRTC call state → Message operations: sends call signals
- WebRTC call state → Message operations: streams signals
- WebRTC call state → Call codec: handles call payloads
- Call controls → WebRTC call state: controls call
- Incoming call prompt → WebRTC call state: accepts or rejects
- WebRTC call state → ICE configuration: gets ICE config
- Attachment handling → Pinata IPFS: stores encrypted files
- Message operations → Attachment handling: shares attachments
- Message synchronization → Delete codec: processes revocations
- Profile codec → XMTP network: broadcasts profiles
- Delete codec → XMTP network: broadcasts deletions