Skip to content

Chat Application DocumentationΒΆ

Welcome to the comprehensive documentation for our production-grade AI chat application.

  • Quick Start

Get up and running in 5 minutes

Quick Start Guide

  • Development Guide

Complete development setup and workflows

Development

  • API Reference

HTTP and streaming endpoints

API Docs

  • Deployment

Deploy to Google Cloud Run

Deploy

πŸ“– About This ProjectΒΆ

This is a production-grade AI chat application built with:

  • Next.js 15 with App Router and Turbopack
  • React 19 with Server Components
  • TypeScript 5 in strict mode
  • Google Vertex AI (Gemini 2.5 models)
  • Tailwind CSS 4 with shadcn/ui v4
  • NextAuth.js for authentication

Key FeaturesΒΆ

βœ… Real-time AI Chat - Streaming responses with multimodal support (text + images) βœ… Server-First Architecture - React Server Components by default βœ… Type-Safe - TypeScript strict mode + Zod runtime validation βœ… Secure - OAuth, rate limiting, input validation, security headers βœ… Production-Ready - Deployed on Google Cloud Run with CI/CD βœ… Well-Documented - Comprehensive docs, JSDoc, and code patterns

πŸ—οΈ Architecture OverviewΒΆ

graph TB
    Browser[Browser] --> NextJS[Next.js 15 App]
    NextJS --> Middleware[Middleware Layer]
    Middleware --> Auth[Authentication]
    Middleware --> RateLimit[Rate Limiting]
    Middleware --> Security[Security Headers]
    NextJS --> API[API Routes]
    API --> Services[Service Layer]
    Services --> VertexAI[Google Vertex AI]
    NextJS --> Components[React Components]
    Components --> UI[shadcn/ui]

    style VertexAI fill:#4285f4,color:#fff
    style NextJS fill:#000,color:#fff
    style Components fill:#61dafb,color:#000

Detailed Architecture

🎯 Getting Started Paths¢

For New DevelopersΒΆ

  1. Quick Start - 5-minute setup guide
  2. Development Guide - Comprehensive setup
  3. Editor Setup - VS Code/Zed configuration
  4. Project Navigation - Find your way around

For ContributorsΒΆ

  1. Contributing Guidelines - How to contribute
  2. Code Patterns - Coding standards
  3. Common Mistakes - Avoid pitfalls
  4. Testing Guide - Test structure

For DevOps/DeploymentΒΆ

  1. Deployment Overview - Getting started
  2. Cloud Run Deployment - Step-by-step
  3. GitHub Actions - CI/CD setup
  4. Security - Security practices

πŸ“š Documentation StructureΒΆ

docs/
β”œβ”€β”€ guides/               # How-to guides and tutorials
β”œβ”€β”€ adr/                  # Architecture Decision Records
β”œβ”€β”€ deployment/           # Deployment guides
β”œβ”€β”€ security/             # Security documentation
β”œβ”€β”€ features/             # Feature-specific docs
└── .github/patterns/     # Code patterns and examples

πŸ”‘ Key ConceptsΒΆ

Server Components vs Client ComponentsΒΆ

This app uses React Server Components (RSC) by default:

  • βœ… Server Components - Default, no "use client" needed
  • πŸ”΅ Client Components - Add "use client" when you need interactivity

Server Component Pattern

Service Layer PatternΒΆ

Business logic lives in dedicated service classes:

export class ChatService {
  async streamChat(messages: Message[]): Promise<ReadableStream> {
    // Business logic here
  }
}

Service Layer Pattern

Input ValidationΒΆ

All external data is validated with Zod schemas:

const schema = z.object({
  messages: z.array(messageSchema),
  model: z.string().optional(),
});

const validated = schema.parse(body);

Validation Pattern

πŸ›‘οΈ SecurityΒΆ

Security is built-in with multiple layers:

  1. Security Headers - CSP, HSTS, X-Frame-Options
  2. Rate Limiting - 5 requests / 10 seconds per IP
  3. Authentication - Google OAuth + email allowlist
  4. Input Validation - Zod schemas for all inputs
  5. Secure Secrets - Google Secret Manager

Security Documentation

πŸš€ Tech StackΒΆ

Category Technology Version
Framework Next.js 15.5.4
UI Library React 19.1.0
Language TypeScript 5.x
Styling Tailwind CSS 4.x
Components shadcn/ui v4
AI Google Vertex AI Gemini 2.5
Auth NextAuth.js 4.24.11
Validation Zod 4.1.12
Testing Vitest 3.2.4
Platform Google Cloud Run -

πŸ“Š Project StatusΒΆ

Detailed Project Status

🀝 Contributing¢

We welcome contributions! Please see our Contributing Guidelines.

Quick Contribution StepsΒΆ

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Write tests
  5. Submit a pull request

Full Contributing Guide

πŸ“ Documentation StandardsΒΆ

This documentation follows these principles:

  • Searchable - Full-text search enabled
  • Visual - Diagrams and screenshots where helpful
  • Practical - Real code examples
  • Up-to-date - Maintained with the codebase
  • AI-friendly - Optimized for GitHub Copilot context

Documentation Guidelines

πŸ”— External ResourcesΒΆ


Last Updated: November 2025 Maintained by: Core Development Team Questions? Open an issue on GitHub