A production-grade ChatGPT-like clone built with Next.js, Supabase, Together.ai, Tailwind CSS, and modern best practices. Real-time chat, file attachments, model selection, user settings, and more.
- Authentication: Email/password signup & login, protected routes, session management
- Chat Interface: Real-time streaming, markdown/code, reactions, editing, mobile-responsive
- Conversation Management: Create, rename, delete, search, filter, optimistic UI
- File Attachments: Drag & drop, preview, validation, secure storage
- Model Selection: Switch Together.ai models, per-conversation, token/cost tracking
- Frontend: Next.js 14 (App Router, RSC), TypeScript, Tailwind CSS, shadcn/ui
- Backend: Next.js API Routes (Edge), Supabase (Postgres, Auth, Storage)
- State: Zustand, TanStack Query, React Hook Form, Zod
- LLM: Together.ai API
- Testing: Vitest
git clone https://github.com/your-org/chatgpt-clone.git
cd chatgpt-clone
npm install # or yarn or pnpm
Copy .env.example
to .env.local
and fill in:
NEXT_PUBLIC_SUPABASE_URL=...
NEXT_PUBLIC_SUPABASE_ANON_KEY=...
SUPABASE_SERVICE_ROLE_KEY=...
TOGETHER_API_KEY=...
- Run the SQL in
knowledge_base/context.md
to create tables:users
,conversations
,messages
,attachments
. - Set up Supabase Storage bucket for file uploads.
npm run dev
Visit http://localhost:3000
npm run dev
— Start dev servernpm run build
— Build for productionnpm start
— Start production servernpm run lint
— Lint codenpm test
— Run all tests (Jest/Vitest)
- Unit/Integration:
npm test
(Jest/Vitest) - E2E: See
integration/e2e-chat-auth-flow.test.tsx
- Tests cover auth, chat, file upload, and more
- Set
NODE_ENV=production
in your deployment platform (Vercel does this automatically) - Use Node.js 18+ runtime
- Set all required environment variables (see
.env.example
) - Enable HTTPS (Vercel/most hosts do this by default)
- Configure Supabase CORS for your domain
- Set up Supabase Storage bucket for file uploads
- Set JWT expiration and security settings in Supabase Auth
- Review rate limits and security headers in
middleware.ts
and API routes
- Push your code to GitHub
- Import your repo to Vercel
- Set all environment variables in Vercel dashboard
- Click Deploy
- Build:
npm run build
- Start:
npm start
- Set all env vars from
.env.example
- Input validation (Zod, server-side checks)
- XSS/CSRF/CORS protection (Next.js, Supabase)
- Rate limiting on API routes
- Use HTTPS in production
- Store Together.ai API keys securely (never commit to repo)
- PRs welcome! Follow conventional commits and run lint/tests before submitting.
- See
knowledge_base/tasks.md
for roadmap and features.
MIT. Not affiliated with OpenAI or ChatGPT. For educational/research use.