Skip to content

Latest commit

 

History

216 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Chat Assistant

Production-grade multimodal chat with Next.js 15, TypeScript, and Google Vertex AI
Live: chat.daza.arRepo: github.com/roofsonfire/chat

Deploy to Cloud Run TypeScript Next.js


🚀 Quick Start

5-minute setup: docs/guides/QUICKSTART.md

git clone https://github.com/roofsonfire/chat.git
cd chat
npm install
cp .env.example .env.local
# Edit .env.local with your credentials
npm run dev

Full setup guide: docs/DEVELOPMENT.md


✨ Features

Core Capabilities

  • 🤖 Multimodal AI Chat - Text + image inputs with Gemini 2.5
  • Real-time Streaming - Instant response streaming
  • 🎨 Image Generation - AI-powered image creation
  • 🔐 Secure Auth - Google OAuth + invite-only access
  • 🛡️ Production-Ready - Rate limiting, security headers, error handling

Tech Stack

  • Frontend: Next.js 15 (App Router), React 19, TypeScript 5, Tailwind CSS 4
  • Backend: Next.js API Routes, Google Vertex AI, NextAuth.js
  • Infrastructure: Google Cloud Run, Cloud Secret Manager
  • Testing: Vitest, React Testing Library, Storybook

📂 Project Structure

chat/
├── src/
│   ├── app/              # Next.js App Router (pages, API routes)
│   ├── components/       # React components (ui/, chat/, auth/)
│   ├── lib/             # Core utilities (services/, hooks/, types/)
│   └── middleware.ts    # Auth, rate limiting, security
├── tests/               # Unit, integration, manual tests
├── docs/                # Comprehensive documentation
└── .github/
    ├── copilot-instructions.md   # AI pairing context
    ├── copilot-quick-reference.md # Fast reference card
    └── patterns/                  # Code pattern library

Full navigation: docs/PROJECT-NAVIGATION.md


📚 Documentation

Getting Started

Deployment

Architecture & Code

Operations

Complete index: docs/README.md


🧪 Testing

npm run test              # Run all tests
npm run test:coverage     # With coverage report
npm run test:ui           # Interactive test UI
npm run lint              # ESLint check
npm run format            # Prettier format

Test structure: Unit tests • Integration tests • Storybook tests • Manual smoke tests
Coverage target: >80% on critical paths


🔐 Security

  • Authentication: NextAuth.js with Google OAuth (invite-only)
  • Rate Limiting: 5 requests per 10 seconds per IP
  • Input Validation: Zod schemas on all endpoints
  • Security Headers: CSP, HSTS, X-Frame-Options, etc.
  • Secrets Management: Google Cloud Secret Manager
  • Password Hashing: bcrypt with 10 rounds

Security policy: docs/SECURITY.md


🤝 Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Follow our patterns: See .github/patterns/
  4. Write tests: Maintain >80% coverage
  5. Submit a PR: Use our PR template

Guidelines: docs/CONTRIBUTING.md


🛠️ Development

Commands

npm run dev              # Development server (localhost:3000)
npm run build            # Production build
npm run start            # Start production server
npm run lint             # Lint code
npm run format           # Format code
npm run type-check       # TypeScript validation
npm run hash-password    # Generate password hash

Environment Variables

Required variables (see .env.example):

# NextAuth
NEXTAUTH_SECRET=          # openssl rand -base64 32
NEXTAUTH_URL=             # http://localhost:3000

# Google Cloud
GOOGLE_PROJECT_ID=        # Your GCP project ID
GOOGLE_CLIENT_ID=         # OAuth client ID
GOOGLE_CLIENT_SECRET=     # OAuth client secret

# Auth User
AUTH_USER_EMAIL=          # Authorized email
AUTH_USER_PASSWORD_HASH=  # bcrypt hash

Complete setup: docs/DEVELOPMENT.md


📊 Performance

  • Server Components by default for reduced JavaScript
  • Streaming responses for real-time AI chat
  • Automatic code splitting with Next.js
  • Image optimization with next/image
  • Turbopack for faster development builds
  • Edge middleware for rate limiting

Metrics: docs/PERFORMANCE.md


🌍 Deployment

Production: chat.daza.ar (Google Cloud Run, us-central1)
Branch strategy: develop (testing) → main (production)

Deploy to Cloud Run

# One-command deploy
./scripts/deployment/deploy-production.sh

# Or manual deploy
gcloud run deploy chat-production \
  --source . \
  --region us-central1 \
  --platform managed

Full guide: docs/deployment/CLOUD-RUN-DEPLOYMENT.md


💰 Cost Estimation

Google Cloud Run (Monthly)

  • Low usage (~1K requests): $2-5
  • Medium usage (~10K requests): $10-20
  • High usage (~50K requests): $30-50

Vertex AI

  • Text generation: ~$0.0001 per request
  • Image generation: ~$0.001 per request

🆘 Support


📄 License

MIT License - see LICENSE file for details.


🙏 Acknowledgments

Built with Next.js, Google Vertex AI, shadcn/ui, and ❤️ by the community.


⭐ Star us on GitHub if this project helps you!

🏠 Home📚 Docs🌐 Demo💬 Discuss

About

Production-grade multimodal chat with Next.js 15, TypeScript, and Google Vertex AI Live: chat.daza.ar • Repo: github.com/roofsonfire/chat

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages