Skip to content

Instantly share code, notes, and snippets.

@denielchiang
Last active August 5, 2025 15:52
Show Gist options
  • Select an option

  • Save denielchiang/fdc23974d7eb807393a46414e114d648 to your computer and use it in GitHub Desktop.

Select an option

Save denielchiang/fdc23974d7eb807393a46414e114d648 to your computer and use it in GitHub Desktop.
Project Relay — MVP Specifica

Project Relay — MVP Specification

1. Overview

One-liner:
White‑label multi‑tenant chat hub that connects LINE & Discord messages into a unified Phoenix LiveView chatroom, with Slack‑style subdomain branding.

Primary Goal:
Allow companies to apply for an account, invite team members, connect LINE and Discord channels, and sync messages in real time.


2. Core Features (MVP Scope)

  1. Multi‑tenant Company Accounts

    • Slack‑style subdomain: company.relay.chat
    • Branding: logo, primary color, accent color
  2. Auth & Roles

    • Pow authentication
    • Roles: Owner, Admin, Member
    • RBAC via Bodyguard
  3. SNS Connectors

    • LINE Bot: shared bot model, QR invite, webhook integration
    • Discord Bot: shared bot, OAuth2 invite link, channel selection, gateway listener
  4. LiveView Chatroom

    • Real-time message display & input
    • Connector‑aware message styling (LINE green, Discord purple, internal = company theme)
    • File/image upload (optional for MVP)
  5. Isolation & Security

    • company_id scoping for all queries
    • Per‑role permissions for actions

3. Tech Stack

  • Backend: Elixir 1.18.x, Phoenix LiveView 1.1.3
  • Database: PostgreSQL
  • Auth: Pow 1.0.39
  • RBAC: Bodyguard 2.4.3
  • Deployment: Fly.io with Managed Postgres
  • Integrations:
    • LINE Messaging API (Webhook + Push API)
    • Discord API (Gateway + REST)

4. Architecture

Flow: [LINE User] → LINE Webhook → Relay → LiveView Chatroom [Discord User] → Discord Gateway Event → Relay → LiveView Chatroom [Relay Chatroom] → Send Message → LINE Push API & Discord Channel POST Tenant Isolation:

  • *.relay.chat wildcard DNS → Tenant loader plug → @current_company
  • All queries filtered by company_id

5. Database Schema (MVP)

companies

  • id (PK)
  • name
  • subdomain
  • logo_url
  • primary_color
  • accent_color
  • inserted_at, updated_at

users

  • id (PK)
  • email
  • password_hash (Pow)
  • role (enum: owner, admin, member)
  • company_id (FK)
  • inserted_at, updated_at

sns_connections

  • id (PK)
  • company_id (FK)
  • type (enum: line, discord)
  • config (JSONB: tokens, webhook tokens, channel IDs)
  • inserted_at, updated_at

messages

  • id (PK)
  • company_id (FK)
  • sns_source (enum: line, discord, internal)
  • sender_name
  • sender_role
  • content
  • attachments (JSONB)
  • inserted_at

6. RBAC Rules

Role Permissions
Owner All actions, billing, delete company
Admin Manage SNS connectors, invite/remove members, moderate messages
Member Send/receive messages only

7. UI Design

Layout:

  • Left Sidebar: Logo, company name, connectors list, channels list, settings link
  • Center: Chat area with message list & input bar
  • Right Panel: Optional (member list, SNS info)
Matplotlib Chart

Branding:

  • Theme colors & logo pulled from @current_company
  • Connector‑aware message bubbles

8. Milestones

Step 1 — Base Foundation

  • Pow auth with roles
  • Companies table + subdomain routing + Tenant Loader Plug
  • Bodyguard RBAC skeleton

Step 2 — Company Settings UI

  • Branding controls
  • SNS connections list

Step 3 — LINE Connector

  • Shared bot QR invite
  • Webhook handler → messages table
  • Push API for outbound

Step 4 — Discord Connector

  • OAuth2 invite link
  • Channel selection UI
  • Gateway listener

Step 5 — LiveView Chatroom

  • Real‑time message display
  • Input bar → relay to connectors
  • Styling per connector

Step 6 — Security Polish

  • Enforce company_id scoping
  • Role checks in LiveView & controllers

9. Future Features (Post‑MVP)

  • Slack/Teams/WhatsApp connectors
  • AI assistant for message summarization
  • Advanced file sharing & search
  • Per‑company billing with Stripe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment