docs: overhaul project documentation and contributing guide (Task #190)
This commit is contained in:
32
docs/functions.md
Normal file
32
docs/functions.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# ⚙️ Functions & API
|
||||
|
||||
Plexus communicates primarily through WebSockets (Socket.io) for real-time interaction.
|
||||
|
||||
## 🔌 Socket Events
|
||||
|
||||
### 📥 Client to Server
|
||||
- `join({ walletAddress, username })`: Register or login a user.
|
||||
- `sendMessage({ channelId, walletAddress, content, txId })`: Send a message to a channel.
|
||||
- `toggleReaction({ messageId, walletAddress, emoji })`: Toggle a reaction on a message.
|
||||
- `updateUsername({ walletAddress, newUsername, txId })`: Change username (simulated cost).
|
||||
- `getProfile(walletAddress)`: Fetch user profile and wall posts.
|
||||
- `updateProfile({ walletAddress, bio, bannerColor })`: Update profile details.
|
||||
- `createPost({ walletAddress, content })`: Post a message to the user's wall.
|
||||
|
||||
### 📤 Server to Client
|
||||
- `userList(users)`: Broadcast the updated list of online/offline users.
|
||||
- `newMessage(message)`: Broadcast a new message to all clients.
|
||||
- `updateReactions({ messageId, reactions })`: Broadcast updated reactions for a message.
|
||||
- `usernameUpdated({ username })`: Confirm a username change to the specific user.
|
||||
- `profileData(data)`: Send requested profile data to a user.
|
||||
- `profileUpdated(data)`: Confirm profile update.
|
||||
- `postCreated(post)`: Confirm post creation.
|
||||
- `error({ message })`: Send error messages to the client.
|
||||
|
||||
## 🌐 REST API
|
||||
- `GET /api/channels`: List all available chat channels.
|
||||
- `GET /api/messages/:channelId`: Fetch the last 100 messages and reactions for a channel.
|
||||
|
||||
## 🛠 Internal Logic
|
||||
- **Username Authority**: The server validates and ensures unique usernames, appending suffixes if necessary.
|
||||
- **Transaction Simulation**: The client simulates a 1.5s delay and a 5% failure rate for "blockchain" transactions.
|
||||
Reference in New Issue
Block a user