Messenger is a relational database design for modern messaging applications. It provides a practical schema to build both one-to-one and group chat systems with support for common messaging workflows.
If you use this project in production or for learning, feel free to share your implementation.
messenger.sql: SQL schema for a messaging platform.Messenger.mwb: MySQL Workbench model file for visual schema design.Messenger.png: ER-style diagram preview of the schema.
ARCHITECTURE.md: Table domains, relationships, and design notes.AGENTS.md: Cross-agent development rules for this repository.CLAUDE.md: Claude-specific implementation guidance..github/copilot-instructions.md: Copilot-specific coding guidance.docs/AGENTIC_DEVELOPMENT.md: AI-assisted development workflow.docs/NODE_EXPRESS_TYPESCRIPT_POSTGRES_SOCKET.md: Node.js + Express + TypeScript + PostgreSQL + Socket.IO implementation guide.docs/GO_POSTGRES_SOCKET.md: Go + PostgreSQL + WebSocket implementation guide.CONTRIBUTING.md: Contribution and pull request expectations.
.github/prompts/node-express-typescript-postgres-socket.prompt.md: Generate a full Node.js backend scaffold..github/prompts/go-postgres-socket.prompt.md: Generate a full Go backend scaffold..github/prompts/dual-backend-roadmap.prompt.md: Generate a phased delivery roadmap for both stacks.
- One-to-one conversation support.
- Group chat support.
- Message persistence and relational integrity.
- Attachment/gallery table support for media messages.
- Device access modeling improvements from previous versions.
flowchart LR
A[User Registration] --> B[User Verification]
B --> C[Device Registration]
C --> D[Access Token Issued]
D --> E[Contact Sync]
E --> F[Conversation Creation]
F --> G[Participant Join]
G --> H[Message Send]
H --> I[Attachment Save]
H --> J[Activity Log]
H --> K[Moderation Checks]
K --> L[Report or Block]
- Import
messenger.sqlinto your MySQL-compatible database. - Open
Messenger.mwbin MySQL Workbench if you want to inspect or extend the model visually. - Connect your API/service layer to this schema and implement your messaging logic.
- Mobile chat backend foundations.
- SaaS communication modules.
- Prototyping chat APIs.
- Learning relational modeling for messaging apps.
- Dating app real-time chat and trust/safety messaging.
- One-to-one direct messaging.
- Group conversation messaging.
- Message history retrieval by conversation.
- Multi-media messaging using attachments.
- Soft delete behavior for user-visible message cleanup.
- Conversation hide/delete per user.
- Phone and email based account registration.
- User verification with temporary verification codes.
- Multi-device registration per user.
- Token issuance and token revocation modeling.
- Device-level session tracking.
- Contact import and synchronization.
- User-to-contact linking for personalized contact books.
- Contact-based conversation bootstrapping.
- Blocking a user in a conversation context.
- Reporting users or conversation participants.
- Tracking moderation status from pending to resolved.
- Activity feed generation for app events.
- Auditing major messaging actions.
- Push-ready architecture through device token storage.
- Team workspace channels for project or department communication.
- Tenant-style customer support chat between users and account teams.
- Internal incident and operations communication rooms.
- Secure conversation audit trails for compliance review.
- Multi-device employee messaging with controlled token access.
- Match-to-chat activation after a successful match event.
- One-to-one private messaging between matched users.
- Media sharing inside match conversations.
- User report and block flows for trust and safety.
- Soft-delete and hide-conversation behavior for privacy expectations.
- Activity logging for abuse detection and moderation analytics.
- API-first chat backend prototyping.
- Database design interviews and exercises.
- Proof-of-concept schema for startup MVPs.
- Foundation schema for a larger microservice split.
graph TD
U1[Account Signup] --> T1[users]
U1 --> T2[user_verification]
U2[Contact Sync] --> T3[contacts]
U2 --> T4[user_contact]
U3[Create Conversation] --> T5[conversation]
U3 --> T6[participants]
U4[Send Message] --> T7[messages]
U4 --> T8[attachments]
U5[Delete Message for User] --> T9[deleted_messages]
U6[Hide Conversation for User] --> T10[deleted_conversations]
U7[Block or Report User] --> T11[block_list]
U7 --> T12[reports]
U8[Session Access] --> T13[devices]
U8 --> T14[access]
U9[Track User Event] --> T15[activities]
U10[SaaS Workspace Channel Chat] --> T5
U10 --> T6
U10 --> T7
U11[Dating Match Chat] --> T5
U11 --> T6
U11 --> T7
U11 --> T11
U11 --> T12
flowchart LR
M[Match Service Emits Match Event] --> C[Create Conversation]
C --> P[Insert Two Participants]
P --> X[Enable Socket Room]
X --> Y[Allow Message and Attachment Events]
Y --> Z[Trust and Safety Checks]
Z --> R[Report or Block if Needed]
For implementation support, contact hi@crew.lk or visit Crew. Crew is an open innovation house based in Sri Lanka.
Based on git commit history:
Added a unique index on participants(conversation_id, user_id).
Commit: d41bb71
Added attachment table support for message galleries.
Commit: 4f83420
Fix for issue #4.
Commit: f45a282
Updated access-to-device relationship to one-to-one.
Commits: ffea804, 936038e
Initial release.
Commit: 2c2b89f

