How fardays90/filezone works
1. Overall shape
- FileZone is a two-part system: a Go signaling server and a React/WebRTC client.
- The important architectural boundary is that the backend is not a file store; it only helps peers find each other and establish connections. File payloads move directly between browsers.
2. Backend role
- The repository root contains main.go plus go.mod/go.sum, which indicates a small Go service.
- From the README, this server provides WebSocket signaling and room coordination.
- Its responsibility is to manage room membership and exchange connection setup messages, not to relay or persist user files.
3. Frontend application
- The client lives in client/FileZone and is a React + TypeScript + Vite app styled with Tailwind.
- src/main.tsx bootstraps the app, while src/App.tsx and src/Home.tsx likely separate the entry experience from the active room experience.
- This client is the main orchestration layer for both signaling and WebRTC transfer.
4. Room-based interaction model
- The app is organized around a room concept, reflected by src/Room.tsx.
- Users first join or create a room, then the app connects them to the other peers currently in that room.
- This room boundary is the point where signaling, peer discovery, text messages, and file transfer all come together.
5. State management boundaries
- The hooks directory contains domain-specific stores:
- useSocketStore.ts for signaling/WebSocket state,
- usePeerStore.ts for connected peer state,
- useFileStore.ts for file transfer state,
- useTextStore.ts for chat/text message state.
- This suggests the client separates transport state from UI state, which is useful for a diagram: each store is a distinct subsystem feeding the room UI.
6. WebSocket signaling path
- useSocketStore.ts is the likely client-side entry point to the Go server.
- The data flow here is control-plane only: join room, announce presence, exchange WebRTC offers/answers/ICE candidates, and coordinate peer lifecycle.
- Once the WebRTC connection is established, the Go server is no longer involved in file delivery.
7. Peer-to-peer transfer path
- utils/peerManager.ts is the core WebRTC subsystem on the client.
- It likely creates and manages RTCPeerConnection instances and DataChannels for each remote peer.
- This is the actual data plane: files and other room messages move directly from sender browser to receiver browser over WebRTC.
8. File handling and browser storage
- useFileStore.ts and utils/opfsWriter.ts indicate that received files are written to the browser using the Origin Private File System (OPFS) or a similar browser-managed storage layer.
- This means incoming file data is assembled and persisted locally on the recipient side, rather than uploaded to any central backend.
- For the diagram, this is a local sink on the receiving client, not a server-side storage tier.
9. Text and file UI components
- src/TextInput.tsx, IncomingBubble.tsx, OutgoingBubble.tsx, UploadedFile.tsx, and ReceivedFIle.tsx form the presentation layer for room activity.
- These components render the status of messages and transfers, separating sender/receiver views and likely reflecting progress/completion states.
- They sit on top of the store layer and do not appear to own transport logic themselves.
10. Client runtime and offline support
- public/serviceWorker.js suggests the client may register a service worker for caching/offline behavior or improved load reliability.
- src/index.css, src/App.css, and tailwind.config.js show the UI is styled with Tailwind plus app-specific CSS.
- These are supporting concerns, not core architecture, but they affect how the browser app is delivered and cached.
11. Primary end-to-end flow
- User opens the client, joins a room, and the client connects to the Go WebSocket server.
- The server coordinates signaling so peers can establish WebRTC connections.
- After the peer mesh is formed, text and files flow directly over DataChannels.
- Received files are written locally in the browser, and the UI updates through the Zustand stores.
12. What to emphasize in an architecture diagram
- Draw three main boundaries: browser UI/state, Go signaling server, and direct peer-to-peer WebRTC links.
- Show the server only on the signaling path, not the file path.
- Show the client split into transport/state management, peer connection management, and UI/rendering, with local browser storage as the final destination for received files.
Main entry points: Room.tsx Room view · peerManager.ts Peer manager · useSocketStore.ts Socket store · App.tsx App shell
Components 17
Go signaling
Room coordination and WebSocket signaling only
- Signaling server · Coordinates rooms and exchanges connection setup messages
main.go
Browser client
React app, state, WebRTC peers, and local file handling
- Socket store · Holds WebSocket connection and signaling events
client/FileZone/hooks/useSocketStore.ts - Peer store · Tracks connected peers and connection lifecycle
client/FileZone/hooks/usePeerStore.ts - File store · Tracks file transfer progress and received payloads
client/FileZone/hooks/useFileStore.ts - Text store · Tracks room text messages and message state
client/FileZone/hooks/useTextStore.ts - Peer manager · Creates and manages peer connections and data channels
client/FileZone/utils/peerManager.ts - OPFS writer · Writes received files into local browser storage
client/FileZone/utils/opfsWriter.ts - Main entry · Bootstraps the browser app
client/FileZone/src/main.tsx - App shell · Top-level app composition and routing
client/FileZone/src/App.tsx - Home screen · Entry experience for joining or creating a room
client/FileZone/src/Home.tsx - Room view · Main room workspace where peers, chat, and files meet
client/FileZone/src/Room.tsx - Text input · Lets users send room messages
client/FileZone/src/TextInput.tsx - Incoming bubble · Renders received chat or transfer status
client/FileZone/src/IncomingBubble.tsx - Outgoing bubble · Renders sent chat or transfer status
client/FileZone/src/OutgoingBubble.tsx - Uploaded file · Shows outbound file items and transfer state
client/FileZone/src/UploadedFile.tsx - Received file · Shows inbound files and local availability
client/FileZone/src/ReceivedFIle.tsx - Service worker · Provides caching or offline support for the client
client/FileZone/public/serviceWorker.js
Connections 19
- Main entry → App shell: starts · Bootstraps the top-level app
- App shell → Home screen: shows · Entry flow for room access
- App shell → Room view: navigates to · Main collaborative room experience
- Room view → Socket store: uses · Connects to signaling and room membership
- Room view → Peer store: uses · Displays and manages connected peers
- Room view → File store: uses · Reflects transfer progress and received files
- Room view → Text store: uses · Renders and sends room chat
- Room view → Text input: contains · Message composer inside room
- Room view → Incoming bubble: contains · Inbound message rendering
- Room view → Outgoing bubble: contains · Outbound message rendering
- Room view → Uploaded file: contains · Outbound file rendering
- Room view → Received file: contains · Inbound file rendering
- Socket store → Signaling server: signaling · Joins rooms and exchanges WebRTC setup messages
- Socket store → Peer manager: feeds · Hands off signaling events needed for peer setup
- Peer manager → Peer store: updates · Publishes peer lifecycle and connection state
- Peer manager → File store: streams · Delivers file data over DataChannels
- Peer manager → Text store: streams · Delivers chat and room messages directly peer-to-peer
- File store → OPFS writer: persists · Writes received payloads locally in the browser
- Service worker → Main entry: supports · Client-side load and caching support