Files
plexus/docs/architecture.md

35 lines
1.5 KiB
Markdown

# Architecture Overview
Plexus is designed as a real-time, decentralized-first chat application.
## 🏗 System Components
### 1. Frontend (Client)
- Built with **Vue 3** and **Vite**.
- Uses **Pinia** for state management (messages, users, channels).
- Communicates with the backend via **Socket.IO** for real-time updates.
- Simulates Solana transactions for messages, reactions, and username changes.
### 2. Backend (Server)
- Built with **Node.js** and **Express**.
- Uses **Socket.IO** to handle real-time communication.
- **DuckDB** is used as the primary data store for:
- User profiles (wallet addresses, unique usernames).
- Message history.
- Reactions.
### 3. Database Schema
- `users`: `wallet_address` (PK), `username` (UNIQUE), `last_seen`.
- `messages`: `id` (PK), `channel_id`, `wallet_address`, `content`, `timestamp`, `tx_id`.
- `reactions`: `message_id`, `wallet_address`, `emoji`.
## 🔄 Data Flow
1. **User Joins**: Client emits `join` with wallet address and requested username. Server verifies/generates unique username and updates `users` table.
2. **Sending Message**: Client simulates transaction, then emits `sendMessage` with `txId`. Server saves message to DuckDB and broadcasts `newMessage` to all clients.
3. **Reactions**: Client emits `toggleReaction`. Server updates `reactions` table and broadcasts `updateReactions`.
## 🛡 Security
- Currently uses a simple wallet-based identification.
- Future versions will implement full message signing and verification.