Skip to content

Latest commit

Β 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DocumentAI - Chat Application with AI Integration

A full-stack chat application that leverages AI (Google Gemini) to provide intelligent conversations with document analysis capabilities. Built with modern web technologies for scalability and performance.


πŸ“‹ Table of Contents


πŸ”— Project Links

Resource URL
GitHub Repository https://github.com/javeed141/Document
Live Frontend (Vercel) https://document-mi49.onrender.com
Live Backend API (Render) https://document-gold.vercel.app/

οΏ½ Project Structure

DOCUMENTAI/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ index.js                          # Main server file
β”‚   β”œβ”€β”€ package.json                      # Backend dependencies
β”‚   β”œβ”€β”€ .env                              # Environment variables (not in Git)
β”‚   β”œβ”€β”€ .env.example                      # Example environment file
β”‚   β”œβ”€β”€ readme.md                         # Backend-specific documentation
β”‚   β”‚
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── authMiddleware.js             # JWT authentication middleware
β”‚   β”‚
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ Chat.js                       # Chat schema & model
β”‚   β”‚   β”œβ”€β”€ Message.js                    # Message schema & model
β”‚   β”‚   └── Users.js                      # User schema & model
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.js                       # Authentication endpoints
β”‚   β”‚   └── chats.js                      # Chat & message endpoints
β”‚   β”‚
β”‚   └── services/
β”‚       └── ai_service.js                 # Google Gemini AI integration
β”‚
β”œβ”€β”€ fronted/
β”‚   β”œβ”€β”€ index.html                        # HTML entry point
β”‚   β”œβ”€β”€ package.json                      # Frontend dependencies
β”‚   β”œβ”€β”€ vite.config.ts                    # Vite configuration
β”‚   β”œβ”€β”€ tsconfig.json                     # TypeScript configuration
β”‚   β”œβ”€β”€ eslint.config.js                  # ESLint configuration
β”‚   β”œβ”€β”€ vercel.json                       # Vercel deployment config
β”‚   β”œβ”€β”€ components.json                   # UI components config
β”‚   β”œβ”€β”€ .env.example                      # Example environment file
β”‚   β”œβ”€β”€ .env.local                        # Local environment variables (not in Git)
β”‚   β”‚
β”‚   β”œβ”€β”€ public/                           # Static assets
β”‚   β”‚
β”‚   └── src/
β”‚       β”œβ”€β”€ main.tsx                      # React entry point
β”‚       β”œβ”€β”€ App.tsx                       # Main App component
β”‚       β”œβ”€β”€ App.css                       # Global styles
β”‚       β”œβ”€β”€ index.css                     # Base styles
β”‚       β”‚
β”‚       β”œβ”€β”€ api/
β”‚       β”‚   └── api.tsx                   # Axios instance & API config
β”‚       β”‚
β”‚       β”œβ”€β”€ assets/                       # Images, fonts, media
β”‚       β”‚
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ ChatSidebar.tsx           # Chat list sidebar
β”‚       β”‚   β”œβ”€β”€ ChatSidebar.css           # Sidebar styles
β”‚       β”‚   β”œβ”€β”€ EmptyState.tsx            # Empty state component
β”‚       β”‚   β”œβ”€β”€ LoadingState.tsx          # Loading skeleton
β”‚       β”‚   β”œβ”€β”€ MessageBubble.tsx         # Individual message bubble
β”‚       β”‚   β”œβ”€β”€ MessageInput.tsx          # Message input box
β”‚       β”‚   β”œβ”€β”€ MessageList.tsx           # Message list container
β”‚       β”‚   β”‚
β”‚       β”‚   β”œβ”€β”€ auth/
β”‚       β”‚   β”‚   β”œβ”€β”€ Home.tsx              # Landing/home page
β”‚       β”‚   β”‚   β”œβ”€β”€ login.tsx             # Login page
β”‚       β”‚   β”‚   └── register.tsx          # Registration page
β”‚       β”‚   β”‚
β”‚       β”‚   β”œβ”€β”€ roles/                    # Role-based components (future)
β”‚       β”‚   β”‚
β”‚       β”‚   └── ui/                       # Reusable UI components
β”‚       β”‚       β”œβ”€β”€ avatar.tsx
β”‚       β”‚       β”œβ”€β”€ button.tsx
β”‚       β”‚       β”œβ”€β”€ card.tsx
β”‚       β”‚       β”œβ”€β”€ dialog.tsx
β”‚       β”‚       β”œβ”€β”€ dropdown-menu.tsx
β”‚       β”‚       β”œβ”€β”€ input.tsx
β”‚       β”‚       β”œβ”€β”€ label.tsx
β”‚       β”‚       β”œβ”€β”€ skeleton.tsx
β”‚       β”‚       β”œβ”€β”€ sonner.tsx
β”‚       β”‚       β”œβ”€β”€ spinner.tsx
β”‚       β”‚       └── textarea.tsx
β”‚       β”‚
β”‚       β”œβ”€β”€ context/
β”‚       β”‚   └── ThemeContext.tsx          # Dark/light theme context
β”‚       β”‚
β”‚       β”œβ”€β”€ lib/
β”‚       β”‚   └── utils.ts                  # Utility functions
β”‚       β”‚
β”‚       └── pages/
β”‚           β”œβ”€β”€ ChatPage.tsx              # Main chat page
β”‚           └── NotFound.tsx              # 404 page
β”‚
β”œβ”€β”€ .git/                                 # Git repository
β”œβ”€β”€ .gitignore                            # Git ignore rules
β”œβ”€β”€ README.md                             # This file
└── REQUIREMENTS_ASSESSMENT.md            # Requirements check document

Key Directories

Directory Purpose
backend/ Express.js REST API with MongoDB integration
fronted/ React + TypeScript frontend application
backend/models/ Mongoose schemas for database entities
backend/routes/ API route handlers
backend/services/ Business logic (AI integration)
fronted/src/components/ Reusable React components
fronted/src/pages/ Page-level components
fronted/src/context/ React Context for state management

πŸ”— Project Links

Frontend

  • React 19.2 - UI library for building interactive interfaces
  • TypeScript 5.9 - Type-safe JavaScript for better development experience
  • Vite 7.2 - Next-generation frontend build tool (fast dev server & optimized builds)
  • React Router v7 - Client-side routing
  • Tailwind CSS 4.1 - Utility-first CSS framework
  • Radix UI - Headless UI components
  • Lucide React - Icon library
  • Axios - HTTP client for API communication
  • Sonner - Toast notifications
  • Next Themes - Dark mode support

Backend

  • Node.js with Express 5.2 - REST API framework
  • MongoDB 9.1 - Document database with Mongoose ORM
  • Google Generative AI (Gemini 2.5 Flash) - AI model for generating responses
  • JWT (jsonwebtoken 9.0) - Authentication & authorization
  • Bcrypt 6.0 - Password hashing
  • CORS - Cross-origin resource sharing for frontend communication
  • dotenv - Environment variable management

DevOps & Deployment

  • Vercel - Frontend hosting & deployment
  • Render - Backend API hosting
  • MongoDB Atlas - Cloud database hosting

✨ Features

  • User Authentication - Secure login/register with JWT and password hashing
  • Real-time Chat - Send and receive messages with AI assistance
  • AI-Powered Responses - Google Gemini integration for intelligent conversations
  • User Management - MongoDB-based user profiles and session management
  • Dark Mode Support - Theme switching capability
  • Responsive Design - Mobile-friendly UI with Tailwind CSS
  • Error Handling - Comprehensive error management with toast notifications

πŸš€ Setup Instructions

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn package manager
  • MongoDB Atlas account (for cloud database) or local MongoDB instance
  • Google Generative AI API key (from Google AI Studio)
  • Git

Clone the Repository

git clone [YOUR_GITHUB_REPOSITORY_URL]
cd DOCUMENTAI

Backend Setup

  1. Navigate to backend directory

    cd backend
  2. Install dependencies

    npm install
  3. Create .env file (see Environment Variables section)

  4. Start the server

    npm start

    Server will run on http://localhost:5000

    For development with auto-reload:

    npx nodemon index.js

Frontend Setup

  1. Navigate to frontend directory

    cd fronted
  2. Install dependencies

    npm install
  3. Create .env.local file (see Environment Variables section)

  4. Start the development server

    npm run dev

    Frontend will run on http://localhost:5173

  5. Build for production

    npm run build
  6. Preview production build

    npm run preview

πŸ”‘ Environment Variables

Backend (.env file in /backend)

# Server Configuration
PORT=5000

# Database
MONGODB_URI=mongodb+srv://[username]:[password]@[cluster].mongodb.net/[database]?retryWrites=true&w=majority

# AI Model
GEMINI_API_KEY=your_google_generative_ai_key_here

# Frontend URL (for CORS)
FRONTEND_URL=http://localhost:5173

# JWT (Optional - add if implementing JWT)
JWT_SECRET=your_jwt_secret_key_here

Frontend (.env.local file in /fronted)

# API Configuration
VITE_API_URL=http://localhost:5000/api

πŸ“¦ API Endpoints

Authentication Routes (/api/auth)

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout

Chat Routes (/api/chats)

  • GET /api/chats - Get all chats for user
  • POST /api/chats - Create new chat
  • GET /api/chats/:id - Get specific chat
  • POST /api/chats/:id/messages - Send message (triggers AI response)
  • DELETE /api/chats/:id - Delete chat

Health Check

  • GET /health - API health status

Environment Variables in Production

Update these variables in your deployment platform's dashboard:

Vercel (Frontend)

  • VITE_API_URL - Your Render API URL

Render (Backend)

  • MONGODB_URI - MongoDB Atlas connection string
  • GEMINI_API_KEY - Google Generative AI key
  • FRONTEND_URL - Your Vercel frontend URL
  • JWT_SECRET - Secure random string for JWT signing
  • NODE_ENV - Set to production

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages