ChatAadi is a full-stack AI chatbot application, for general purpose conversation, inspired by ChatGPT. It features Google-based authentication, persistent chat history, and token tracking β built with modern web technologies.
- Framework: Next.js (App Router, TypeScript)
- Authentication: NextAuth.js with Google OAuth
- Database: PostgreSQL via NeonDB
- ORM: Prisma
- UI: Tailwind CSS (optional)
- AI Integration: Ollama llama3.2 model as default for localhost and mistral-tiny model for production (both are free)
- π Google Sign-In via NextAuth
- π¬ Persistent chat history per user
- π§ Token usage tracking per message/session
- π Server-side chat streaming (optional)
- β‘ Fast, modern architecture with Prisma + Neon
git clone https://github.com/abchatterjee7/chat-aadi.git
cd chat-aadinpm install
# or
yarn installCreate a .env file in the root:
# PostgreSQL (NeonDB) connection
DATABASE_URL="postgresql://your_user:your_password@your_neon_host/dbname?sslmode=require"
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# NextAuth
NEXTAUTH_SECRET=your_random_secret
NEXTAUTH_URL=http://localhost:3000
# CORS
NEXT_PUBLIC_ALLOWED_ORIGINS=http://localhost:3000,https://chat-aadi.vercel.app
#AI Providers
#OLLAMA (localhost provider as default)
OLLAMA_URL=http://localhost:11434/api/generate
OLLAMA_MODEL=llama3.2
DISABLE_OLLAMA=false # Set to true to force using Mistral
#Mistral (fallback provider, will be used in live deploy)
MISTRAL_API_KEY=your_mistral_api_key
MISTRAL_API_URL=https://api.laplateforme.io/mistral/v1
MISTRAL_MODEL=mistral-tinyπ You can generate
NEXTAUTH_SECRETusing:openssl rand -base64 32
npx prisma migrate dev --name initOr if you prefer schema push without migrations:
npx prisma db push
npx prisma generatenpm run dev
# or
yarn devVisit: http://localhost:3000
/chat-aadi/src
βββ prisma/ # Prisma schema & migrations
βββ public/
βββ package.json
βββ .env
βββ .tsconfig.json
βββ README.md
βββ src/ You're using Google as the OAuth provider. Once logged in, user data is stored in the database (User, Account, Session models).
Make sure you've:
- Created a project on Google Cloud Console
- Enabled OAuth 2.0
- Added
http://localhost:3000as an authorized redirect URI
- Basic info, profile image, credits
- Relations: accounts, sessions, chats, token usage
- Belongs to a user
- Contains many messages
- Token usage tracking
- Long
contentusing@db.Text - Roles:
user,assistant
- Tracks token count per chat
You can deploy this to:
- Vercel (recommended for Next.js)
- Free serverless Postgres
- Optimized for edge functions
- Get started: https://neon.tech
- Integrate Mistral API (Mistral 7B free model) & Ollama llama3.2 (for localhost chat completion)
- Stream responses from the server
- Token counting (approximate & actual)
- User settings page
- Export chat history
- Mobile-first responsive UI
Q: Why use NeonDB? A: Itβs a modern, serverless Postgres DB perfect for Vercel or other edge-first platforms.
Q: What about Ollama and Mistral integration? A: This template lays the foundation. Youβll soon be able to hook it up with Mistral API (In localhost and default, using ollama llama3.2 model) to generate responses.
Q: How are messages stored?
A: Each message is stored in the Message model as a TEXT field, allowing for large content.
ChatAadi by [Aaditya B Chatterjee] Made with π and inspired by ChatGPT.
This project is licensed under the MIT License.
- Generating text to image and image to image like Ghibli images (say using stability.ai api)
- subscription monthly implementation with razorpay and token spent
- forgot/reset password & email verification with otp
- ollama not working.
- edit profile with image,name
- Mobile Compatable UI
- Ensure .env file. It must also have CORS as,
NEXT_PUBLIC_ALLOWED_ORIGINS=http://localhost:3000,https://chat-aadi.vercel.app
- Add .nvmrc file with 18 (for NodeJs version)
- Add .vercelignore file
- During build need
npm i
npx prisma generate (to generate prisma client)
npm run build
npm run start
- Under "Build & Development Settings":
Set "Build Command" to: npm run vercel-build
Set "Output Directory" to: .next
Set "Install Command" to: npm install
- In case it got deployed, find it live here:
- https://chat-aadi.vercel.app


