4.0 KiB
4.0 KiB
Project Plan: OpenChat Overlay
Mission
To build "OpenChat Overlay"—a free, open-source alternative to StreamElements, focused on extraordinary simplicity. Users should never touch a line of code.
Core Technical Stack
- Frontend: Next.js (App Router)
- Database: Supabase (Auth + PostgreSQL)
- Styling: Tailwind CSS (Dashboard), CSS Injection (Overlay)
- Chat Client:
tmi.jsorcomfy.js(Client-side)
Architecture
Next.js Folder Structure (Proposed)
src/
├── app/
│ ├── (dashboard)/ # Route group for the authenticated dashboard
│ │ ├── layout.tsx # Dashboard layout (sidebar, auth checks)
│ │ ├── page.tsx # Main dashboard view
│ │ ├── editor/ # The "Style Creator"
│ │ │ └── page.tsx
│ │ └── settings/ # Account settings
│ │ └── page.tsx
│ ├── api/ # API Routes
│ │ ├── auth/ # NextAuth handlers
│ │ │ └── [...nextauth]/route.ts
│ │ └── overlay/ # Overlay configuration endpoints
│ │ └── [token]/route.ts
│ ├── overlay/ # The public overlay view
│ │ └── [token]/ # Dynamic route for user overlay
│ │ ├── layout.tsx # Transparent background layout
│ │ └── page.tsx # The actual chat overlay component
│ └── globals.css # Tailwind directives
├── components/
│ ├── dashboard/ # Dashboard-specific components
│ │ ├── PreviewFrame.tsx # Live preview iframe/component
│ │ └── StyleControls.tsx # Form for editing styles
│ ├── overlay/ # Overlay-specific components
│ │ ├── ChatContainer.tsx
│ │ └── Message.tsx
│ └── ui/ # Reusable UI components (buttons, inputs)
├── lib/
│ ├── supabase.ts # Supabase client
│ ├── utils.ts # Helper functions
│ └── types.ts # TypeScript interfaces
└── hooks/ # Custom React hooks (useChat, useSettings)
Key Features & Logic
1. One-Click Twitch Auth
- Provider: NextAuth.js with Twitch.
- Action: Authenticate user -> Check if exists in Supabase -> Create profile if new.
2. The "Style Creator"
- Left Panel: Controls for font family, size, colors, opacity, badge toggles, and 7TV/BTTV emote toggles.
- Right Panel: Live preview component rendering mock chat messages with the current settings applied.
- State: React state manages unsaved changes; "Save" pushes to Supabase.
3. The "Secret Sauce" URL (/overlay/[token])
- Route:
src/app/overlay/[token]/page.tsx - Behavior:
- Validates
tokenagainst Supabase. - Fetches user configuration JSON.
- Injects configuration into the chat component styles.
- Connects to Twitch chat via
tmi.jsusing the user's channel name.
- Validates
- Styling: Background must be transparent (
bg-transparent).
4. Real-time Chat
- Library:
tmi.js(client-side execution). - Cost: Zero server-side WebSocket processing.
Implementation Phases
- Project Initialization: Scaffolding Next.js, Tailwind, and Supabase client.
- Authentication: Implementing NextAuth with Twitch.
- Database: Designing the Schema and connecting Supabase.
- Dashboard UI: Building the Style Creator and Preview.
- Overlay Logic: Creating the standalone overlay page and chat connection.
- Deployment: Docker/LXC containerization.
Data Schema (Settings)
{
"user_id": "uuid",
"overlay_token": "string (unique)",
"settings": {
"fontFamily": "Inter, sans-serif",
"fontSize": "14px",
"textColor": "#ffffff",
"backgroundColor": "#000000",
"backgroundOpacity": 0.5,
"showBadges": true,
"emotes": {
"bttv": true,
"seventv": true
}
}
}