Skip to content

Pranaykarvi/Hackthrone_gdc_techno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ChatSmith - AI-Powered Chatbot Platform

Build Intelligent Chatbots from PDFs

A comprehensive AI chatbot platform that transforms documents into intelligent conversational agents. Upload PDFs, create custom chatbots, and deploy them instantly.

Next.js React TypeScript Express Supabase Cohere


πŸ“‹ Table of Contents


🎯 About ChatSmith

ChatSmith is an intelligent chatbot platform that allows you to create AI-powered chatbots from your PDF documents. Simply upload a PDF, and ChatSmith automatically:

  • πŸ“„ Extracts text content from your documents
  • 🧠 Processes and chunks the content intelligently
  • πŸ” Embeds content using advanced AI models
  • πŸ’¬ Creates a conversational AI chatbot
  • πŸš€ Deploys instantly for immediate use

Key Capabilities

  • RAG (Retrieval Augmented Generation) - Accurate, context-aware responses
  • Vector Search - Fast, semantic document retrieval
  • Multi-Chatbot Management - Create unlimited chatbots
  • Tone Customization - Adjust chatbot personality
  • Real-time Chat - Instant responses with conversation history
  • User & Admin Dashboards - Complete management interface

✨ Features

πŸ€– Core Platform Features

  • PDF Upload & Processing

    • Automatic text extraction from PDFs
    • Intelligent document chunking
    • Vector embedding generation
    • Metadata preservation
  • Chatbot Management

    • Create multiple chatbots
    • Edit chatbot details
    • Delete chatbots and associated data
    • View chatbot analytics
  • Advanced AI Chat

    • Context-aware responses
    • Conversation history tracking
    • Tone adjustment (professional, casual, friendly, etc.)
    • Real-time streaming responses
  • User Interface

    • Modern, responsive design
    • Dark mode support
    • Intuitive chat interface
    • Admin & user dashboards
    • File upload with progress tracking

πŸ” Security & Authentication

  • Role-based access control (Admin/User)
  • Secure API endpoints
  • Data encryption
  • Session management

πŸ›  Tech Stack

Frontend

  • Next.js 16.0.0 - React framework with Turbopack
  • React 19.2.0 - UI library
  • TypeScript 5.0 - Type safety
  • Tailwind CSS - Utility-first CSS
  • Radix UI - Accessible component primitives
  • Lucide Icons - Beautiful icon set

Backend

  • Express 5.1.0 - Node.js web framework
  • TypeScript - Type-safe backend
  • LangChain 0.3.x - AI orchestration framework
  • Cohere AI - Language models & embeddings
  • Multer - File upload handling
  • CORS - Cross-origin resource sharing

Database & Vector Store

  • Supabase - PostgreSQL database & authentication
  • pgvector - Vector similarity search
  • Supabase Vector Store - LangChain integration

AI & ML

  • Cohere Embeddings - Document vectorization (embed-english-v3.0)
  • Cohere Chat - Conversational AI
  • LangChain - RAG implementation
  • PDF Parse - Document processing

πŸ“ Project Structure

Hackthrone_gdc_techno/
β”œβ”€β”€ backend/                    # Express.js backend server
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ chat.ts            # Chat endpoint with RAG
β”‚   β”‚   β”œβ”€β”€ chatbots.ts        # Chatbot CRUD operations
β”‚   β”‚   β”œβ”€β”€ upload.ts          # PDF upload & processing
β”‚   β”‚   └── tone.ts            # Tone analysis
β”‚   β”œβ”€β”€ langchain/
β”‚   β”‚   β”œβ”€β”€ chains.ts          # LangChain RAG chains
β”‚   β”‚   β”œβ”€β”€ embeddings.ts      # Cohere embeddings
β”‚   β”‚   β”œβ”€β”€ loader.ts          # Document loaders
β”‚   β”‚   └── vectorStore.ts     # Vector store setup
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ memory.ts          # Conversation memory
β”‚   β”‚   └── supabase.ts        # Supabase client
β”‚   β”œβ”€β”€ uploads/               # Temporary PDF storage
β”‚   β”œβ”€β”€ main.ts                # Server entry point
β”‚   └── package.json
β”‚
β”œβ”€β”€ main_frontend/             # Main Next.js application
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Root layout
β”‚   β”‚   β”œβ”€β”€ page.tsx           # Home page
β”‚   β”‚   └── globals.css        # Global styles
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ admin-dashboard.tsx
β”‚   β”‚   β”œβ”€β”€ admin-header.tsx
β”‚   β”‚   β”œβ”€β”€ chat-interface.tsx      # βœ… Integrated with backend
β”‚   β”‚   β”œβ”€β”€ chatbot-list.tsx        # βœ… Integrated with backend
β”‚   β”‚   β”œβ”€β”€ chatbot-card.tsx
β”‚   β”‚   β”œβ”€β”€ dashboard.tsx
β”‚   β”‚   β”œβ”€β”€ login-page.tsx
β”‚   β”‚   β”œβ”€β”€ sidebar.tsx
β”‚   β”‚   β”œβ”€β”€ user-profile.tsx
β”‚   β”‚   β”œβ”€β”€ settings-page.tsx
β”‚   β”‚   └── dark-toggle.tsx
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ auth-context.tsx   # Authentication context
β”‚   β”‚   └── utils.ts           # Utility functions
β”‚   └── package.json
β”‚
β”œβ”€β”€ frontend/                  # Alternative frontend (legacy)
β”‚   β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ components/
β”‚   └── lib/
β”‚
β”œβ”€β”€ .env                       # Environment variables (create this)
β”œβ”€β”€ SETUP_GUIDE.md            # Detailed setup instructions
β”œβ”€β”€ BACKEND_INTEGRATION_SETUP.md
└── README.md                 # This file

πŸš€ Getting Started

Prerequisites

  • Node.js 16.x or higher
  • npm or yarn package manager
  • Supabase account (free tier available)
  • Cohere API account (free trial with credits)

Quick Start

  1. Clone the repository

    git clone <repository-url>
    cd Hackthrone_gdc_techno
  2. Install dependencies

    Backend:

    cd backend
    npm install

    Frontend:

    cd main_frontend
    npm install
  3. Set up environment variables

    Create backend/.env:

    # Supabase Configuration
    SUPABASE_URL=your_supabase_project_url
    SUPABASE_ANON_KEY=your_supabase_anon_key
    
    # Cohere API Key
    COHERE_API_KEY=your_cohere_api_key
    
    # Server Port
    PORT=8000
  4. Set up Supabase Database

    See Database Configuration section below.

  5. Start the servers

    Backend (in one terminal):

    cd backend
    npm run dev

    Frontend (in another terminal):

    cd main_frontend
    npm run dev
  6. Access the application


πŸ”§ Environment Setup

Backend Environment Variables

Create a backend/.env file with:

Variable Description Required Example
SUPABASE_URL Supabase project URL βœ… Yes https://xxx.supabase.co
SUPABASE_ANON_KEY Supabase anonymous key βœ… Yes eyJhbGciOiJIUzI1NiIs...
COHERE_API_KEY Cohere API key βœ… Yes your_api_key_here
PORT Backend server port ❌ No 8000 (default)

Frontend Environment Variables

Create a main_frontend/.env.local file (optional):

Variable Description Required Example
NEXT_PUBLIC_BACKEND_API_URL Backend API URL ❌ No http://localhost:8000

Note: The frontend automatically falls back to http://localhost:8000 if not set.

Getting API Keys

Supabase Setup

  1. Go to supabase.com
  2. Create a new project (free tier available)
  3. Navigate to Settings β†’ API
  4. Copy:
    • Project URL β†’ SUPABASE_URL
    • anon/public key β†’ SUPABASE_ANON_KEY

Cohere Setup

  1. Go to cohere.ai
  2. Sign up (free trial with credits)
  3. Navigate to API Keys
  4. Copy your API key β†’ COHERE_API_KEY

πŸ’Ύ Database Configuration

Supabase Database Setup

  1. Enable pgvector extension

    In Supabase SQL Editor:

    CREATE EXTENSION IF NOT EXISTS vector;
  2. Create chatbots table

    CREATE TABLE chatbots (
      id UUID PRIMARY KEY,
      name TEXT NOT NULL,
      description TEXT,
      pdf_name TEXT,
      created_at TIMESTAMP DEFAULT NOW(),
      message_count INTEGER DEFAULT 0
    );
  3. Create documents table (vector embeddings)

    CREATE TABLE documents (
      id BIGSERIAL PRIMARY KEY,
      content TEXT,
      metadata JSONB,
      embedding VECTOR(1024),
      chatbot_id UUID REFERENCES chatbots(id) ON DELETE CASCADE
    );
    
    -- Create index for faster similarity search
    CREATE INDEX ON documents 
    USING ivfflat (embedding vector_cosine_ops)
    WITH (lists = 100);
  4. Create chat_messages table

    CREATE TABLE chat_messages (
      id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
      chatbot_id UUID REFERENCES chatbots(id) ON DELETE CASCADE,
      role TEXT NOT NULL,
      content TEXT NOT NULL,
      created_at TIMESTAMP DEFAULT NOW()
    );
  5. Create vector search function

    CREATE OR REPLACE FUNCTION match_documents(
      query_embedding VECTOR(1024),
      match_chatbot_id UUID,
      match_count INT DEFAULT 5
    )
    RETURNS TABLE (
      id BIGINT,
      content TEXT,
      metadata JSONB,
      similarity FLOAT
    )
    LANGUAGE plpgsql
    AS $$
    BEGIN
      RETURN QUERY
      SELECT
        documents.id,
        documents.content,
        documents.metadata,
        1 - (documents.embedding <=> query_embedding) AS similarity
      FROM documents
      WHERE documents.chatbot_id = match_chatbot_id
      ORDER BY documents.embedding <=> query_embedding
      LIMIT match_count;
    END;
    $$;

For detailed setup instructions, see SETUP_GUIDE.md.


πŸ“Έ ChatSmith Platform Screenshots

Login & Authentication

ChatSmith Login Page

Secure login with role-based authentication (Admin/User)

User Chatbot Management

User Chatbots Dashboard

Manage your AI chatbots - create, edit, and organize all in one place

Live Chat Interface

Chat Interface

Real-time chat with AI chatbots powered by RAG technology

User Profile

User Profile

Manage your account and preferences

Analytics Dashboard

Analytics Dashboard

Track chatbot performance and usage metrics

Settings Panel

Settings Page

Configure chatbot behavior, appearance, and integrations

Admin Dashboard

Admin Dashboard

Comprehensive admin panel for managing users and chatbots


🎯 Use Cases

ChatSmith can be used to build various AI-powered applications:

1. VitaData - Healthcare Platform πŸ₯

An integrated healthcare platform built using ChatSmith's chatbot technology.

Features:

  • Patient portal with AI health assistant
  • Doctor dashboard with clinical decision support
  • Guardian access for family health monitoring
  • Pharmacy integration with prescription chatbots
  • Health records Q&A
  • Medication adherence tracking with AI reminders

Tech Stack:

  • React + Vite + TypeScript
  • MongoDB for patient data
  • ChatSmith chatbots for health consultations
  • Real-time notifications

Learn More: See the VitaData section at the end of this README.

2. Customer Support Bot

  • Upload product manuals and documentation
  • Instant customer support responses
  • 24/7 availability

3. Educational Assistant

  • Upload textbooks and study materials
  • Interactive learning experience
  • Question answering system

4. Legal Document Assistant

  • Upload legal documents and contracts
  • Quick document search
  • Legal Q&A

5. HR Knowledge Base

  • Company policies and procedures
  • Employee handbook chatbot
  • Onboarding assistant

πŸ“š API Documentation

Base URL

http://localhost:8000

Endpoints

1. Upload PDF & Create Chatbot

POST /upload
Content-Type: multipart/form-data

Body:
- file: PDF file
- name: Chatbot name

Response:
{
  "message": "PDF processed and chatbot created",
  "chatbotId": "uuid",
  "name": "Chatbot Name",
  "createdAt": "ISO timestamp"
}

2. Get All Chatbots

GET /chatbots

Response:
[
  {
    "id": "uuid",
    "name": "Chatbot Name",
    "description": "Description",
    "pdf_name": "document.pdf",
    "created_at": "timestamp",
    "message_count": 0
  }
]

3. Delete Chatbot

DELETE /chatbots/:chatbotId

Response:
{
  "message": "Chatbot and all related data deleted."
}

4. Chat with Chatbot

POST /chat
Content-Type: application/json

Body:
{
  "chatbotId": "uuid",
  "message": "Your question here",
  "history": [
    { "role": "user", "content": "Previous question" },
    { "role": "ai", "content": "Previous answer" }
  ],
  "tone": "professional" // optional
}

Response:
{
  "id": "message-id",
  "content": "AI response here",
  "sources": [...] // optional
}

5. Analyze Tone

POST /tone
Content-Type: application/json

Body:
{
  "text": "Text to analyze"
}

Response:
{
  "tone": "professional",
  "confidence": 0.95
}

πŸ“œ Available Scripts

Backend

# Development server with hot reload
npm run dev

# Build TypeScript
npm run build

# Start production server
npm start

# Type checking
npm run lint

Frontend

# Development server
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Linting
npm run lint

🚒 Deployment

Backend Deployment (Railway/Render)

  1. Push code to GitHub
  2. Connect repository to Railway/Render
  3. Add environment variables in dashboard
  4. Deploy automatically

Frontend Deployment (Vercel)

  1. Push code to GitHub
  2. Import project in Vercel
  3. Set environment variables
  4. Deploy automatically

Environment Variables for Production

Make sure to set all required environment variables in your deployment platform:

  • SUPABASE_URL
  • SUPABASE_ANON_KEY
  • COHERE_API_KEY
  • NEXT_PUBLIC_BACKEND_API_URL (frontend only)

🎨 Features Implemented

βœ… Backend Integration Complete

  • PDF upload and processing
  • Vector embeddings with Cohere
  • Chatbot CRUD operations
  • RAG-based chat with context
  • Conversation history
  • Tone customization
  • Supabase vector store integration

βœ… Frontend Integration Complete

  • Chatbot list with real data
  • Create chatbot with PDF upload
  • Delete chatbot functionality
  • Chat interface with backend
  • Loading states and error handling
  • Responsive design
  • Dark mode support
  • User authentication (mock)
  • Admin dashboard

πŸ› Troubleshooting

Common Issues

Backend fails to start

  • Check if .env file exists in backend/ folder
  • Verify all required environment variables are set
  • Ensure Supabase URL and key are correct

Frontend can't connect to backend

  • Ensure backend is running on port 8000
  • Check CORS settings in backend
  • Verify API URL in frontend

Chatbot creation fails

  • Check Cohere API key is valid
  • Ensure Supabase tables are created
  • Check PDF file size (should be < 10MB)
  • Verify pgvector extension is enabled

Vector search not working

  • Run the match_documents function creation SQL
  • Ensure embeddings dimension is 1024
  • Check index creation on documents table

For detailed troubleshooting, see SETUP_GUIDE.md.


πŸ”’ Security Best Practices

  1. Never commit .env files - Add to .gitignore
  2. Use environment variables - For all sensitive data
  3. Validate file uploads - Check file types and sizes
  4. Sanitize user inputs - Prevent injection attacks
  5. Use HTTPS in production - Secure all connections
  6. Implement rate limiting - Prevent abuse
  7. Regular security audits - Keep dependencies updated

πŸ“ˆ Roadmap

Upcoming Features

  • Real-time streaming responses
  • Multi-language support
  • Voice input/output
  • Advanced analytics dashboard
  • Chatbot sharing and embedding
  • Custom branding options
  • Webhook integrations
  • API key management
  • Usage metrics and billing
  • Team collaboration features

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘₯ Team & Support

For questions, issues, or support:

  • Create an issue in the repository
  • Contact the development team
  • Check documentation files

πŸ₯ VitaData Use Case - Healthcare Platform

VitaData is a comprehensive healthcare platform built using ChatSmith's AI chatbot technology as its core conversational engine.

Overview

VitaData demonstrates ChatSmith's versatility by implementing:

  • AI-powered health consultations
  • Medical document Q&A
  • Medication reminders and tracking
  • Multi-stakeholder platform (patients, doctors, guardians, pharmacies)

Tech Stack

  • Frontend: React 18.2 + Vite + TypeScript
  • Backend: MongoDB Atlas + Firebase/Supabase
  • AI Engine: ChatSmith chatbot platform
  • Styling: Tailwind CSS + Framer Motion

Key Features

Four Specialized Portals

  1. Patient Portal - Health dashboard, appointments, prescriptions
  2. Doctor Dashboard - Patient management, clinical workflows
  3. Guardian Portal - Family health monitoring
  4. Pharmacy Hub - Prescription processing, delivery

AI-Powered Features (Using ChatSmith)

  • Health consultation chatbots
  • Medication adherence AI assistant
  • Symptom checker
  • Medical document Q&A
  • Prescription interpretation

Data Management

  • Digital health records
  • Vitals tracking (BP, blood sugar, temperature)
  • Lab reports management
  • Appointment scheduling
  • Prescription management

VitaData Architecture

VitaData Application
β”œβ”€β”€ Patient/Doctor/Guardian/Pharmacy Portals
β”œβ”€β”€ MongoDB (Patient data, appointments, prescriptions)
β”œβ”€β”€ ChatSmith Integration
β”‚   β”œβ”€β”€ Medical knowledge chatbots
β”‚   β”œβ”€β”€ Prescription Q&A bots
β”‚   β”œβ”€β”€ Health guidance assistants
β”‚   └── Medication tracking bots
└── Real-time Notifications & Reminders

Setup for VitaData

  1. Set up ChatSmith platform (this repository)
  2. Create medical knowledge chatbots:
    • Upload medical guidelines PDFs
    • Upload medication information
    • Upload hospital procedures
  3. Configure VitaData frontend to use ChatSmith API
  4. Set up MongoDB for patient data
  5. Deploy both applications

Use Case Benefits

βœ… 24/7 Health Assistance - AI chatbots always available
βœ… Reduced Wait Times - Instant answers to common questions
βœ… Better Patient Engagement - Interactive health management
βœ… Knowledge Accessibility - Complex medical info simplified
βœ… Scalable Solution - Serve unlimited patients simultaneously


πŸ“Έ VitaData Screenshots

Patient Portal & Health Dashboard

VitaData Patient Portal

Comprehensive patient health management interface

Doctor Dashboard

VitaData Doctor Dashboard

Clinical workflow and patient management system

Guardian Portal

VitaData Guardian Portal

Family health monitoring and care coordination

Pharmacy Hub

VitaData Pharmacy Hub

Prescription processing and delivery management

Additional Features

VitaData Additional Features

Advanced healthcare platform capabilities


Built with ❀️ by the ChatSmith Team

ChatSmith - Transforming Documents into Intelligent Conversations

Documentation β€’ API Docs β€’ Use Cases

About

this is the main repo for the hackthrone conducted by gdc during techno-vit 2025. The domain for the same is AI/ML & Web-Dev, our topic is SaaS provider in form of chatbots for individual users

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors