A production-ready AI Chat application featuring tool usage (Google Slides, etc.), Vercel AI SDK for chat streaming, and NextAuth v5 for authentication.
- AI Chat: Powered by Vercel AI SDK (supports OpenAI, Anthropic, Google).
- Tool Integration: Connect with external tools like Google Slides.
- Authentication: Custom authentication flow with NextAuth sessions.
- Database: PostgreSQL with Drizzle ORM.
- Infrastructure: Next.js 15 (App Router), Tailwind CSS.
- Security: Request validation, environment validation, and secure auth flows.
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Database: PostgreSQL
- ORM: Drizzle ORM
- Auth: NextAuth.js (Auth.js v5)
- AI: Vercel AI SDK + Composio
- Styling: Tailwind CSS
- Validation: Zod (Env vars & Schema)
- Linting: ESLint + Prettier
- Node.js 18+
- PostgreSQL database (local or cloud like Neon/Supabase)
Create a .env file in the root directory:
# Database
DATABASE_URL="postgres://user:pass@localhost:5432/open_gamma"
# NextAuth
AUTH_SECRET="your_generated_secret" # generate with `npx auth secret` or `openssl rand -base64 32`
AUTH_URL="http://localhost:3000" # Deployment URL
# Composio (Tools & Auth)
COMPOSIO_API_KEY="your_composio_api_key"
AUTH_CONFIG_ID="your_auth_config_id" # From Composio Dashboard at platform.composio.dev
# AI Providers (At least one required)
OPENAI_API_KEY="sk-..."
ANTHROPIC_API_KEY="sk-..."
GEMINI_API_KEY="sk-..."npm installPush the schema to your database (for local dev):
npm run db:pushFor production migrations:
npm run db:generate
npm run db:migratenpm run devOpen http://localhost:3000.
- User clicks "Sign in with Composio".
- App generates a unique
userIdand calls the Composio link API. - User authenticates with the external provider (e.g., Google/GitHub).
- Composio redirects back to
/auth/callback. - App verifies the
userIdand creates a NextAuth session.
The chat interface (app/page.tsx) uses the Vercel AI SDK useChat hook.
Tools are executed via Composio on the server (app/api/chat/route.ts).
Rate limiting is applied per user session.
Drizzle commands require DATABASE_URL to be set. Either export it or prefix the command:
# Option 1: Export in shell
export DATABASE_URL="postgres://..."
npm run db:push
# Option 2: Inline
DATABASE_URL="postgres://..." npm run db:pushnpm run db:push: Push schema changes directly (prototyping only).npm run db:generate: Generate SQL migration files (production).npm run db:migrate: Apply migration files to the DB.npm run db:studio: Open Drizzle Studio to view data.
- Build:
npm run build - Environment: Ensure all
.envvariables are set in your provider (Vercel/Railway). - Database: Run
npm run db:migrateduring the build process or as a post-deploy step.
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Push to the branch.
- Open a Pull Request.
This project uses Composio for tool integrations and authentication.