Skip to content

Engine-User/Terminal-Chat-App

Repository files navigation

AI-Terminal-Chatbot

image

A privacy-first, multi-user chat app built with FastAPI + React + Groq. It streams LLM responses in real time, persists conversation history, and is architected for easy extension into RAG and vector-store workflows.


What Makes It Good?

Feature Why It Matters
Super-fast inference Powered by Groq — sub-second token generation across a wide range of Llama and open models.
Multi-user, multi-session Switch between users and conversations for different use cases; UUID-based sessions keep everything isolated.
Real-time streaming Server-Sent Events (SSE) deliver assistant responses word-by-word, no polling needed.
Persistent history Every message is saved locally in SQLite via SQLAlchemy — durable, portable, and easy to backup.
Privacy by design Only API calls leave the machine. No chat data is fed back to Groq or any third party for training.
RAG / Vector-ready Clean service layer and schema make it straightforward to plug in embeddings and a vector DB later.
Docker + cloud ready One-command Docker deployment and Terraform scaffolding for GCP.

Quick Start

Prerequisites: Python 3.11+, Node.js 18+, a Groq API key.

# 1. One-time setup
cd Chatbot
.\setup.ps1          # creates venv, installs deps, sets up .env

# 2. Start backend
.\run-backend.ps1

# 3. Start frontend (new terminal)
.\run-frontend.ps1

Open http://localhost:5173. image

Manual alternative

# Backend
cd backend
..\venv\Scripts\Activate.ps1
uvicorn app.main:app --reload --port 8000

# Frontend
cd frontend
npm run dev

🔧 Configuration

Edit .env in the project root:

GROQ_API_KEY=gsk_your_actual_key
GROQ_MODEL=llama-3.3-70b-versatile   # swap for any Groq-supported model
DATABASE_URL=sqlite:///./chatbot.db

🐳 Docker

docker compose up --build

📡 API Endpoints

Method Path Description
GET /health Health check
GET /chat/users List users
GET /chat/users/{id}/conversations List user conversations
GET /chat/{session_id}/history Load messages
POST /chat/{session_id}/stream Send message, stream SSE response
DELETE /chat/{session_id} Clear conversation
image

Project Structure

Chatbot/
├── backend/              # FastAPI + SQLAlchemy + Groq
│   ├── app/
│   │   ├── main.py
│   │   ├── database.py
│   │   ├── models.py
│   │   ├── schemas.py
│   │   ├── core/config.py
│   │   ├── routers/chat.py
│   │   └── services/groq_service.py
│   └── requirements.txt
├── frontend/             # React + Vite
│   ├── src/
│   │   ├── App.jsx
│   │   ├── components/
│   │   └── services/api.js
│   └── package.json
├── docker-compose.yml
├── terraform/            # GCP secret manager scaffold
└── .env

Privacy & Data

  • Closed system: Chats are stored locally in your own SQLite database.
  • No data leakage: Messages are sent only to Groq for inference; they are not used to train or improve models.
  • Self-hostable: Run it entirely on your machine, a VPS, or your own cloud project.

Extending the App

The modular structure makes it easy to add:

  • Vector DB / RAG: plug in embeddings and a vector store for semantic search over chat history or documents.
  • Auth layer: add JWT or OAuth to protect user sessions.
  • Additional models: switch models via GROQ_MODEL or add a model-selection UI.
  • Export / import: backup conversations to JSON or markdown.

📎 Useful Links

About

A Chatbot that is fast and localized

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages