Thanks to visit codestin.com
Credit goes to github.com

Skip to content

keanuharrell/warsawjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

41 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽค WarsawJS Real-Time Demo

Live interactive presentation platform showcasing real-time features with SST, Next.js, and AWS IoT Core.

Built for the WarsawJS 2025 presentation: "From AWS Overwhelm to SST Confidence"


โœจ What is this?

This is a complete real-time web application that allows:

  • ๐Ÿ’ฌ Live Chat - Audience members can chat in real-time during the presentation
  • ๐Ÿ—ณ๏ธ Live Polls - Interactive voting with instant results visualization
  • ๐ŸŽ›๏ธ Admin Dashboard - Control the presentation flow and enable/disable features
  • ๐Ÿ“Š Live Slides - Slidev presentation with real-time data integration

All of this is powered by SST (Serverless Stack) and deployed to AWS with just one command!


๐Ÿš€ Why This Demo?

This project demonstrates how SST makes AWS accessible by:

  1. Type-safe Infrastructure as Code - Define your AWS resources in TypeScript
  2. Instant Local Development - Work with real AWS services locally with sst dev
  3. Built-in Real-time - MQTT over WebSocket via AWS IoT Core, zero config
  4. Monorepo Support - Share code between frontend, backend, and infrastructure
  5. Production Ready - Deploy to multiple stages with one command

Before SST ๐Ÿ˜ฐ

# Complex CloudFormation YAML
Resources:
  MyIoTPolicy:
    Type: AWS::IoT::Policy
    Properties:
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Action: iot:Connect
            Resource: !Sub arn:aws:iot:${AWS::Region}:${AWS::AccountId}:*

With SST ๐ŸŽ‰

// Simple, typed, and powerful
const realtime = new sst.aws.Realtime("Chat", {
  handler: "chat.handler"
});

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         AWS CLOUD                            โ”‚
โ”‚                                                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Next.js    โ”‚โ—„โ”€โ”€โ”€โ”€โ–บโ”‚  AWS IoT     โ”‚โ—„โ”€โ”€โ”€โ”€โ–บโ”‚  Lambda    โ”‚ โ”‚
โ”‚  โ”‚  Web App    โ”‚ MQTT โ”‚  Core        โ”‚ Auth โ”‚  Functions โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Admin      โ”‚โ—„โ”€โ”€โ”€โ”€โ–บโ”‚  DynamoDB    โ”‚      โ”‚ Amazon SES โ”‚ โ”‚
โ”‚  โ”‚  Dashboard  โ”‚      โ”‚  Tables      โ”‚      โ”‚  Email     โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                             โ”‚
โ”‚  โ”‚  Slidev     โ”‚                                             โ”‚
โ”‚  โ”‚  Slides     โ”‚ (Static Site on S3 + CloudFront)           โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Project Structure

warsawjs/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ core/              # ๐ŸŽฏ Shared business logic
โ”‚   โ”‚   โ”œโ”€โ”€ realtime/      #    MQTT client & types
โ”‚   โ”‚   โ”œโ”€โ”€ auth/          #    Authentication
โ”‚   โ”‚   โ”œโ”€โ”€ email/         #    Email service
โ”‚   โ”‚   โ””โ”€โ”€ dynamo/        #    Database entities
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ functions/         # โšก Lambda functions
โ”‚   โ”‚   โ””โ”€โ”€ src/
โ”‚   โ”‚       โ”œโ”€โ”€ api/       #    REST API handlers
โ”‚   โ”‚       โ”œโ”€โ”€ auth/      #    Auth callbacks
โ”‚   โ”‚       โ””โ”€โ”€ realtime/  #    MQTT authorizer
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ web/               # ๐ŸŒ Public web app (Next.js)
โ”‚   โ”œโ”€โ”€ admin/             # ๐ŸŽ›๏ธ Admin dashboard (Next.js)
โ”‚   โ””โ”€โ”€ slides/            # ๐Ÿ“Š Presentation slides (Slidev)
โ”‚
โ”œโ”€โ”€ infra/                 # โ˜๏ธ Infrastructure definitions
โ”‚   โ”œโ”€โ”€ realtime.ts        #    AWS IoT Core setup
โ”‚   โ”œโ”€โ”€ database.ts        #    DynamoDB tables
โ”‚   โ”œโ”€โ”€ auth.ts            #    OpenAuth config
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ””โ”€โ”€ sst.config.ts          # ๐Ÿ”ง SST configuration

๐ŸŽฏ Getting Started

Prerequisites

  • Node.js 18+ or Bun (recommended)
  • AWS Account with credentials configured (guide)
  • SST CLI (installed automatically with npm)

Quick Start

# 1. Clone the repository
git clone https://github.com/keanuharrell/warsawjs.git
cd warsawjs

# 2. Install dependencies (using Bun - fast!)
bun install

# 3. Set required secrets
npx sst secret set RealtimeWriteToken "your-write-token-here"
npx sst secret set RealtimeReadOnlyToken "your-readonly-token-here"

# 4. Start development (this will deploy to AWS!)
npx sst dev

That's it! ๐ŸŽ‰ Your app is now running with:

  • โœ… Real AWS services (DynamoDB, IoT Core, Lambda)
  • โœ… Live reload for instant feedback
  • โœ… Local function invocation
  • โœ… Real-time infrastructure updates

Access Your Apps

Once sst dev is running:


๐ŸŽฎ Features Walkthrough

1. Live Chat ๐Ÿ’ฌ

Real-time messaging between all connected participants.

How it works:

  • Users type messages in the web app
  • Messages are published to MQTT topic warsawjs/{stage}/chat
  • All connected clients (including slides) receive updates instantly
  • Messages are stored in DynamoDB for persistence
// It's this simple!
const { messages, publish } = useRealtimeTopic<ChatMessage>('chat')

// Publish a message
publish({ id: '1', text: 'Hello!', username: 'John', timestamp: Date.now() })

2. Live Voting ๐Ÿ—ณ๏ธ

Interactive polls with real-time results.

How it works:

  • Users vote by clicking an option (A, B, C, or D)
  • Votes are stored in DynamoDB (upsert by userId)
  • Real-time updates via MQTT show live percentages
  • Slides display results in a beautiful 2x2 grid

Features:

  • โœ… One vote per user (stored in localStorage)
  • โœ… Vote persistence across page refreshes
  • โœ… Winner card highlighted with ๐Ÿ‘‘
  • โœ… Smooth animations and progress bars

3. Admin Control Panel ๐ŸŽ›๏ธ

Control the entire presentation flow.

Features:

  • ๐Ÿ“ก Enable/disable chat and voting
  • ๐Ÿ”„ Reset all demo data
  • ๐Ÿ“Š View real-time connection status
  • โœ‰๏ธ Send email summaries

Admin Flow:

1. Open admin dashboard
2. Authenticate (OpenAuth)
3. Enable Chat โ†’ Participants can now chat
4. Enable Vote โ†’ Poll appears on all devices
5. Reset โ†’ Clean slate for next demo

4. Live Slides ๐Ÿ“Š

Slidev presentation with embedded real-time components.

Cool Features:

  • Live chat messages appear during Demo #1
  • Live vote results displayed during Demo #2
  • QR code for easy audience participation
  • Connection status indicator

๐Ÿ› ๏ธ Technology Stack

Category Technology Why?
Framework SST Type-safe IaC, instant local dev
Frontend Next.js 15 React framework with App Router
Slides Slidev Markdown-based slides with Vue
Real-time AWS IoT Core Managed MQTT broker
Database DynamoDB Serverless NoSQL database
Auth OpenAuth Modern auth for serverless
Email Amazon SES Scalable email service
Styling Tailwind CSS + shadcn/ui Beautiful, accessible components
ORM ElectroDB DynamoDB made easy

๐Ÿ“š Learn More

Key Concepts

๐Ÿ”Œ Real-time with MQTT

This project uses AWS IoT Core for real-time communication via MQTT over WebSocket.

Topics Structure:

{app}/{stage}/{feature}

Examples:
- warsawjs/dev/chat       (development chat)
- warsawjs/prod/vote      (production voting)
- warsawjs/dev/control    (admin control)

Authorization:

  • JWT tokens for admin users (full access)
  • Static write token for participants (chat + vote)
  • Static read-only token for slides (subscribe only)

๐Ÿ” Security

The realtime/authorizer.ts Lambda function validates tokens and returns fine-grained permissions:

// Admin (JWT) โ†’ Full access
{ publish: ["warsawjs/dev/*"], subscribe: ["warsawjs/dev/*"] }

// Write token โ†’ Can chat and vote
{ publish: ["warsawjs/dev/chat", "warsawjs/dev/vote"], subscribe: ["warsawjs/dev/*"] }

// Read-only token โ†’ Slides can only subscribe
{ publish: ["warsawjs/dev/_readonly_dummy"], subscribe: ["warsawjs/dev/*"] }

๐Ÿ“ฆ Monorepo Architecture

The core package is the heart of the application:

  • Shared types and business logic
  • Framework-agnostic MQTT client
  • Reusable across web, admin, functions, and slides

This ensures:

  • โœ… Type safety across packages
  • โœ… Single source of truth
  • โœ… Easy refactoring and updates

๐Ÿšข Deployment

Deploy to Staging

npx sst deploy --stage staging

Deploy to Production

npx sst deploy --stage production

Custom Domain Setup

Update infra/dns.ts with your domain:

export const domain = "yourdomain.com"

SST will automatically:

  • Create CloudFront distributions
  • Set up SSL certificates
  • Configure DNS records (via Cloudflare)

๐Ÿงช Development Tips

Adding a New Real-time Feature

  1. Define types in packages/core/src/realtime/types.ts:

    export interface MyFeatureMessage {
      id: string
      data: string
      timestamp: number
    }
  2. Add topic to TopicType union:

    export type TopicType = 'chat' | 'vote' | 'control' | 'my-feature'
  3. Use in React with the hook:

    const { messages, publish } = useRealtimeTopic<MyFeatureMessage>('my-feature')
  4. Update authorizer permissions if needed in functions/src/realtime/authorizer.ts

Debugging

MQTT Connection Issues:

  • Check browser console for [MQTT] logs
  • Verify tokens are set: npx sst secret list
  • Test topic format: {app}/{stage}/{feature}

Lambda Functions:

  • View logs: npx sst logs
  • Tail specific function: npx sst logs --stage dev --function RealtimeAuthorizer

Infrastructure:

  • View resources: npx sst console
  • Check CloudFormation: AWS Console โ†’ CloudFormation

๐Ÿค Contributing

This project was created for a WarsawJS presentation, but feel free to:

  • โญ Star the repo if you found it helpful
  • ๐Ÿ› Report issues or bugs
  • ๐Ÿ’ก Suggest improvements
  • ๐Ÿ”€ Fork and build your own version

๐Ÿ“„ License

MIT License - feel free to use this code for your own projects!


๐Ÿ‘จโ€๐Ÿ’ป Author

Keanu Harrell


๐Ÿ™ Acknowledgments

  • WarsawJS community for the opportunity to present
  • SST team for building an amazing framework
  • WebDevCody for the YouTube video that introduced me to SST
  • Everyone who contributed to the open-source libraries used in this project

๐ŸŽฌ Demo Video

๐ŸŽฅ Coming soon! Link to the WarsawJS presentation recording


Built with โค๏ธ using SST

Documentation ยท Discord ยท GitHub

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published