Skip to content

johnleonrive/serverless-chat-frontend

Repository files navigation

Serverless Chat Frontend

Real-time serverless chat application frontend built with Next.js 14, TypeScript, and Tailwind CSS for CPSC 465.

Team: Muhammad Shahwar Shamim, Daniel Wright, Ansh Tomar, John-Leon Rivera

Live Application: https://d57e9mww85f95.cloudfront.net

Features

  • User Authentication - Sign up, sign in, forgot password with email verification via AWS Cognito
  • Real-Time Messaging - Instant message delivery via WebSocket connections
  • Friend System - Search users, send/accept/reject friend requests
  • AI Content Moderation - Messages flagged for inappropriate content shown with visual indicators
  • Message History - Persistent chat history loaded on conversation open
  • Multi-Tab Sync - Messages sync across multiple browser tabs
  • Responsive UI - Mobile-friendly design delivered globally via CloudFront CDN

Tech Stack

Category Technology
Framework Next.js 14 (App Router, Static Export)
Language TypeScript (strict mode)
Styling Tailwind CSS
State Management Zustand
Authentication AWS Amplify + Cognito
Date Handling date-fns
Build/Deploy S3 + CloudFront
CI/CD GitHub Actions

Project Structure

serverless-chat-frontend/
├── src/
│   ├── app/                    # Next.js App Router pages
│   │   ├── layout.tsx
│   │   ├── page.tsx            # Redirect to login
│   │   ├── login/page.tsx      # Login page
│   │   ├── signup/page.tsx     # Sign up page
│   │   ├── forgot-password/    # Password reset flow
│   │   └── chat/page.tsx       # Main chat interface
│   ├── components/
│   │   ├── ChatWindow.tsx      # Message display
│   │   ├── MessageInput.tsx    # Message composer
│   │   ├── Sidebar.tsx         # Friends list
│   │   └── ConnectionStatus.tsx
│   ├── lib/
│   │   ├── ws.ts               # WebSocket manager
│   │   ├── store.ts            # Zustand store
│   │   └── auth.ts             # Cognito auth helpers
│   └── types/
│       └── message.ts          # TypeScript types
├── .github/workflows/
│   ├── ci.yml                  # CI: typecheck, lint, build
│   └── deploy.yml              # CD: S3 sync, CloudFront invalidation
└── public/

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • AWS account (for deployment)

Local Development

  1. Clone and install:
git clone https://github.com/johnleonrive/serverless-chat-frontend.git
cd serverless-chat-frontend
npm install
  1. Configure environment:
cp .env.example .env

Edit .env:

NEXT_PUBLIC_WS_URL=wss://rnf7vtl93i.execute-api.us-east-1.amazonaws.com/prod
NEXT_PUBLIC_API_URL=https://gbctzghf5d.execute-api.us-east-1.amazonaws.com/prod
NEXT_PUBLIC_COGNITO_USER_POOL_ID=us-east-1_OncfX435Y
NEXT_PUBLIC_COGNITO_CLIENT_ID=<your-client-id>
  1. Run development server:
npm run dev

Open http://localhost:3000

Scripts

Command Description
npm run dev Start development server
npm run build Build for production
npm run export Build and export static site
npm run typecheck Run TypeScript type checking
npm run lint Run ESLint

Deployment

Automated (GitHub Actions)

Push to main triggers:

  1. CI workflow - typecheck, lint, build
  2. Deploy workflow - build, S3 sync, CloudFront cache invalidation

Manual

npm run export
aws s3 sync out/ s3://serverless-chat-frontend-676206934447 --delete
aws cloudfront create-invalidation --distribution-id E3OPTSYB9E4RWP --paths "/*"

AWS Resources

Resource Value
S3 Bucket serverless-chat-frontend-676206934447
CloudFront Distribution E3OPTSYB9E4RWP
Domain d57e9mww85f95.cloudfront.net
Cognito User Pool us-east-1_OncfX435Y

Test Accounts

Email Password
[email protected] Test123!
[email protected] Test123!
[email protected] Test123!
[email protected] Test123!
[email protected] Test123!

Related Repository

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages