Files
plexus/docs/data-model.md

44 lines
1.5 KiB
Markdown

# 📊 Data Model
Plexus uses **DuckDB** for fast, analytical, and serverless-friendly data storage.
## 🗄 Tables
### `users`
Stores user identity and profile information.
- `wallet_address` (VARCHAR, PK): Unique Solana wallet address.
- `username` (VARCHAR, UNIQUE): Display name.
- `bio` (VARCHAR): User biography.
- `banner_color` (VARCHAR): Hex code for profile banner.
- `last_seen` (TIMESTAMP): Last activity time.
### `messages`
Stores chat history.
- `id` (INTEGER, PK): Unique message ID (from `seq_msg_id`).
- `channel_id` (VARCHAR): ID of the channel.
- `wallet_address` (VARCHAR, FK): Sender's wallet.
- `content` (VARCHAR): Message text.
- `timestamp` (TIMESTAMP): Time sent.
- `tx_id` (VARCHAR): Simulated transaction ID.
### `reactions`
Stores message reactions.
- `message_id` (INTEGER, FK): ID of the message.
- `wallet_address` (VARCHAR, FK): User who reacted.
- `emoji` (VARCHAR): The emoji character.
- *Composite PK*: `(message_id, wallet_address, emoji)`.
### `posts`
Stores social wall posts.
- `id` (INTEGER, PK): Unique post ID (from `seq_post_id`).
- `wallet_address` (VARCHAR, FK): Owner of the wall.
- `content` (VARCHAR): Post text.
- `timestamp` (TIMESTAMP): Time posted.
## 🔢 Sequences
- `seq_msg_id`: Increments for each new message.
- `seq_post_id`: Increments for each new wall post.
## 🔄 Migrations
The `server/db.js` file handles automatic schema initialization and migrations (e.g., adding `tx_id` or `bio` columns if they are missing from an existing database).