Skip to content

Repository files navigation

Chat app with AI-Powered Smart Replies

A production-ready live streaming chat application that integrates Stream's React Chat SDK with Synthetic's inference API to provide context-aware smart reply suggestions.

Features

  • Real-time Chat: Built on Stream's powerful Chat API with React SDK
  • AI Smart Replies: Context-aware reply suggestions powered by Synthetic AI
  • Streaming Platform UI: Sleek, dark theme inspired by Twitch and StreamLabs
  • Secure Authentication: Backend token generation for Stream users
  • Fully Responsive: Works seamlessly across all devices

Prerequisites

  • Node.js 18+ and npm installed
  • Stream account with API key and secret
  • Synthetic API key
  • Basic knowledge of React and Next.js

Setup Instructions

1. Install Dependencies

npm install

2. Configure Environment Variables

Create a .env.local file in the root directory:

# Client-side (public)
NEXT_PUBLIC_STREAM_API_KEY=your_stream_api_key

# Server-side (private)
STREAM_API_SECRET=your_stream_api_secret
SYNTHETIC_API_KEY=your_synthetic_api_key

3. Run the Development Server

npm run dev

Open http://localhost:3000 to see the application.

How It Works

Backend Token Server

The /api/token endpoint generates secure Stream user tokens:

  • Accepts userId and userName
  • Creates or updates user in Stream
  • Returns authentication token

Stream Chat Integration

  • Initializes Stream client with user token
  • Creates or joins a messaging channel
  • Renders chat UI with Stream's React components

Smart Reply Generation

  1. Captures recent conversation messages
  2. Sends context to Synthetic AI inference API
  3. Generates 3 contextually relevant reply suggestions
  4. Displays suggestions as clickable buttons
  5. Sends selected reply instantly to chat

Architecture

┌─────────────┐
│   Frontend  │
│  (Next.js)  │
└──────┬──────┘
       │
       ├─────────────┐
       │             │
       ▼             ▼
┌─────────────┐ ┌─────────────┐
│   Stream    │ │  Synthetic  │
│  Chat API   │ │   AI API    │
└─────────────┘ └─────────────┘

Deployment

Deploy to Vercel with one click:

  1. Push code to GitHub
  2. Import project in Vercel
  3. Add environment variables
  4. Deploy

Tech Stack

stream-synthetic
├─ app
│  ├─ api
│  │  ├─ smart-replies
│  │  │  └─ route.ts
│  │  └─ token
│  │     └─ route.ts
│  ├─ globals.css
│  ├─ layout.tsx
│  └─ page.tsx
├─ components
│  ├─ discord-chat-layout.tsx
│  ├─ smart-reply-bar.tsx
│  ├─ stream-chat-container.tsx
│  ├─ theme-provider.tsx
│  └─ ui
│     ├─ accordion.tsx
│     ├─ alert-dialog.tsx
│     ├─ alert.tsx
│     ├─ aspect-ratio.tsx
│     ├─ avatar.tsx
│     ├─ badge.tsx
│     ├─ breadcrumb.tsx
│     ├─ button-group.tsx
│     ├─ button.tsx
│     ├─ calendar.tsx
│     ├─ card.tsx
│     ├─ carousel.tsx
│     ├─ chart.tsx
│     ├─ checkbox.tsx
│     ├─ collapsible.tsx
│     ├─ command.tsx
│     ├─ context-menu.tsx
│     ├─ dialog.tsx
│     ├─ drawer.tsx
│     ├─ dropdown-menu.tsx
│     ├─ empty.tsx
│     ├─ field.tsx
│     ├─ form.tsx
│     ├─ hover-card.tsx
│     ├─ input-group.tsx
│     ├─ input-otp.tsx
│     ├─ input.tsx
│     ├─ item.tsx
│     ├─ kbd.tsx
│     ├─ label.tsx
│     ├─ menubar.tsx
│     ├─ navigation-menu.tsx
│     ├─ pagination.tsx
│     ├─ popover.tsx
│     ├─ progress.tsx
│     ├─ radio-group.tsx
│     ├─ resizable.tsx
│     ├─ scroll-area.tsx
│     ├─ select.tsx
│     ├─ separator.tsx
│     ├─ sheet.tsx
│     ├─ sidebar.tsx
│     ├─ skeleton.tsx
│     ├─ slider.tsx
│     ├─ sonner.tsx
│     ├─ spinner.tsx
│     ├─ switch.tsx
│     ├─ table.tsx
│     ├─ tabs.tsx
│     ├─ textarea.tsx
│     ├─ toast.tsx
│     ├─ toaster.tsx
│     ├─ toggle-group.tsx
│     ├─ toggle.tsx
│     ├─ tooltip.tsx
│     ├─ use-mobile.tsx
│     └─ use-toast.ts
├─ components.json
├─ hooks
│  ├─ use-dialog-manager.ts
│  ├─ use-mobile.ts
│  └─ use-toast.ts
├─ lib
│  ├─ synthetic-ai.ts
│  └─ utils.ts
├─ next.config.mjs
├─ package-lock.json
├─ package.json
├─ pnpm-lock.yaml
├─ postcss.config.mjs
├─ public
│  ├─ placeholder-logo.png
│  ├─ placeholder-logo.svg
│  ├─ placeholder-user.jpg
│  ├─ placeholder.jpg
│  └─ placeholder.svg
├─ README.md
├─ src
│  ├─ components
│  │  └─ chat
│  ├─ hooks
│  ├─ services
│  └─ types
├─ styles
│  └─ globals.css
└─ tsconfig.json

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages