A full-stack ChatGPT-style app that runs locally using open-source LLMs via Ollama, built with Next.js, Node.js, Prisma, and PostgreSQL.
- ✅ ChatGPT-style UI with streaming response
- ✅ Chat history stored in PostgreSQL
- ✅ "New Chat", auto-title, and session view
- ✅ Ollama integration with
gemma:2bmodel - ✅ Interrupt generation with "Stop" button
- ✅ Clean, minimal UI with Tailwind CSS
- ✅ Local-only setup (no external APIs)
| Layer | Technology |
|---|---|
| Frontend | Next.js + React + Tailwind CSS |
| Backend | Node.js + Express |
| LLM | Ollama with gemma:2b |
| Database | PostgreSQL (via Prisma) |
| ORM | Prisma ORM |
| Styling | Tailwind CSS |
project/
├── app/ # Next.js App Router
├── backend/ # Node.js + Express backend
├── components/ # React components
├── prisma/ # Prisma schema & migrations
├── .env # Environment config
├── package.json # Scripts & dependencies
git clone <your-repo-url>
cd projectnpm installMake sure PostgreSQL is installed and running on your system.
Create a new database:
CREATE DATABASE localchat;Update your .env:
DATABASE_URL="postgresql://postgres:<your_password>@localhost:5432/localchat"npx prisma generate
npx prisma migrate dev --name initMake sure Ollama is installed. Then run:
ollama run gemma:2bIf not installed, get it here: https://ollama.com/download
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- Database: PostgreSQL (view via pgAdmin)
- Chats and messages are stored persistently in PostgreSQL
- You don’t need to rerun
prisma migrateunless the schema changes - PostgreSQL runs as a service: only start manually if it doesn’t auto-start
- Use pgAdmin to view or query tables (
Chat,Message)
- Ollama startup may be slow the first time
- Stream interruption ("Stop" button) works only mid-generation
Chat UI, Sidebar, and History stored in PostgreSQL via Prisma.
![]()
Screen.Recording.2025-07-30.003433.mp4
MIT License

