Skip to content

Latest commit

Β 

History

8 Commits

Folders and files

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

Repository files navigation

πŸ€– Perplexity AI

An AI-powered intelligent chat assistant with real-time web search, Gmail integration, and autonomous email capabilities.


πŸš€ AI Chat β€’ 🌐 Internet Search β€’ πŸ“§ Gmail Integration β€’ πŸ€– Autonomous Email Assistant


πŸ“– Overview

Perplexity AI is a full-stack AI-powered chat application that combines the reasoning capabilities of Mistral AI, real-time internet access using Tavily AI, and Gmail integration through Google OAuth + Nodemailer.

Unlike a traditional chatbot, Perplexity AI can:

  • πŸ’¬ Hold contextual conversations
  • 🌐 Search the internet before answering
  • πŸ“§ Verify Gmail accounts securely
  • βœ‰οΈ Send emails on behalf of authenticated users
  • 🧠 Decide when internet search is required
  • ⚑ Stream AI responses with typing animations
  • πŸ“‚ Manage multiple chat sessions

✨ Features

πŸ€– AI Features

  • Mistral AI powered conversations
  • Intelligent response generation
  • Context-aware conversations
  • AI Thinking Indicator
  • Typing Animation Effect
  • Multiple chat sessions
  • Persistent chat history

🌍 Internet Access

Integrated with Tavily AI, allowing the AI model to search the web whenever additional information is required.

Features include:

  • Real-time web search
  • Latest news retrieval
  • Current events
  • Research assistance
  • Fact verification

πŸ“§ Gmail Integration

Users authenticate using their Gmail account.

The application securely stores OAuth credentials allowing the AI assistant to send emails on behalf of the user.

Features:

  • Gmail OAuth Authentication
  • Secure Token Storage
  • Email Verification
  • AI Generated Emails
  • AI Sends Emails Automatically
  • Personalized Email Drafts

πŸ’¬ Chat Features

  • Sidebar Chat Navigation
  • Create New Chats
  • Switch Between Chats
  • Persistent Chat History
  • Loading States
  • AI Thinking Animation
  • Smooth Typing Effect
  • Responsive Dashboard

🎨 User Experience

  • Beautiful Modern UI
  • Responsive Design
  • Toast Notifications
  • Redux State Management
  • Tailwind CSS Styling
  • Fast Vite Development

πŸ›  Tech Stack

Frontend

  • React
  • Vite
  • Redux Toolkit
  • Tailwind CSS
  • Axios
  • React Router
  • React Toastify

Backend

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • JWT Authentication

AI Services

  • Mistral AI
  • Tavily AI

Email Services

  • Gmail API
  • Google OAuth2
  • Nodemailer

πŸ“‚ Project Structure

Perplexity/
β”‚
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ node_modules/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/           # Database & application configuration
β”‚   β”‚   β”œβ”€β”€ controllers/      # Business logic
β”‚   β”‚   β”œβ”€β”€ middlewares/      # Authentication & request middlewares
β”‚   β”‚   β”œβ”€β”€ models/           # Mongoose models
β”‚   β”‚   β”œβ”€β”€ routes/           # Express API routes
β”‚   β”‚   β”œβ”€β”€ services/         # AI, Gmail & external service integrations
β”‚   β”‚   β”œβ”€β”€ validators/       # Request validation schemas
β”‚   β”‚   └── app.js            # Express application
β”‚   β”‚
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ .gitignore
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ package-lock.json
β”‚   └── server.js             # Backend entry point
β”‚
β”œβ”€β”€ FrontEnd/
β”‚   β”œβ”€β”€ node_modules/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ hooks/            # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ layouts/          # Application layouts
β”‚   β”‚   β”œβ”€β”€ pages/            # Application pages
β”‚   β”‚   β”œβ”€β”€ redux/            # Redux Toolkit store & slices
β”‚   β”‚   β”œβ”€β”€ routes/           # React Router configuration
β”‚   β”‚   β”œβ”€β”€ services/         # API communication
β”‚   β”‚   β”œβ”€β”€ utils/            # Helper utilities
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   └── main.jsx
β”‚   β”‚
β”‚   β”œβ”€β”€ .gitignore
β”‚   β”œβ”€β”€ eslint.config.js
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ package-lock.json
β”‚   β”œβ”€β”€ README.md
β”‚   └── vite.config.js
β”‚
└── README.md

βš™οΈ Installation

1 Clone Repository

git clone https://github.com/DibyanshuChauhan/Perplexity.git
cd Perplexity

2 Install Backend Dependencies

cd Backend

npm install

3 Install Frontend Dependencies

cd ../FrontEnd

npm install

πŸ” Environment Variables

Create a .env file inside the Backend directory and add the following variables.

# ===============================
# Database Configuration
# ===============================
MONGO_URI=your_mongodb_connection_string

# ===============================
# Server Configuration
# ===============================
PORT=3000
NODE_ENV=development

# ===============================
# JWT Authentication
# ===============================
JWT_SECRET=your_super_secret_jwt_key

# ===============================
# AI Services
# ===============================
MISTRAL_API_KEY=your_mistral_api_key
TAVILY_API_KEY=your_tavily_api_key
GEMINI_API_KEY=your_gemini_api_key    # Optional

# ===============================
# Gmail OAuth Configuration
# ===============================
GOOGLE_USER=your_email@gmail.com
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_REFRESH_TOKEN=your_google_refresh_token

πŸ“– Environment Variables Explained

Variable Description
MONGO_URI MongoDB Atlas connection string.
PORT Port on which the backend server runs.
NODE_ENV Application environment (development or production).
JWT_SECRET Secret key used to sign JWT authentication tokens.
MISTRAL_API_KEY API key used for generating AI responses via Mistral AI.
TAVILY_API_KEY API key enabling real-time internet search through Tavily AI.
GEMINI_API_KEY Optional Google Gemini API key for future AI integrations.
GOOGLE_USER Gmail account used for sending emails.
GOOGLE_CLIENT_ID OAuth Client ID obtained from Google Cloud Console.
GOOGLE_CLIENT_SECRET OAuth Client Secret obtained from Google Cloud Console.
GOOGLE_REFRESH_TOKEN Refresh token used by Nodemailer to send emails without requiring the user to log in again.

πŸ“§ Generating Google OAuth Credentials

To enable Gmail integration:

1. Create a Google Cloud Project

  • Visit Google Cloud Console
  • Create a new project
  • Enable the Gmail API

2. Configure OAuth Consent Screen

  • Select External
  • Fill in the required application details
  • Add your Gmail account as a Test User

3. Create OAuth Credentials

Create an OAuth 2.0 Client ID and copy:

  • Client ID
  • Client Secret

4. Generate a Refresh Token

Visit:

https://developers.google.com/oauthplayground/

Then:

  1. Click the βš™οΈ Settings icon.
  2. Enable Use your own OAuth credentials.
  3. Paste your Google Client ID and Client Secret.
  4. Select the Gmail API.
  5. Authorize access with your Google account.
  6. Exchange the authorization code for tokens.
  7. Copy the generated Refresh Token into your .env file.

⚠️ Security Notice

Never commit your .env file or API keys to GitHub. Always add .env to your .gitignore to protect sensitive credentials.


▢️ Running the Project

Start Backend

cd Backend

npm run dev

Start Frontend

cd FrontEnd

npm run dev

Visit

http://localhost:5173

πŸ”„ Application Workflow

                    User
                      β”‚
                      β–Ό
             React Frontend
                      β”‚
                      β–Ό
               Express Backend
                      β”‚
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β–Ό               β–Ό                β–Ό
  Mistral AI      Tavily AI       Gmail OAuth
      β”‚               β”‚                β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β–Ό
             Intelligent AI Response
                      β”‚
                      β–Ό
            Email Sent (If Required)

🧠 AI Workflow

User Message
      β”‚
      β–Ό
Backend receives prompt
      β”‚
      β–Ό
Mistral analyzes request
      β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚Need Internet?β”‚
      β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚Yes
             β–Ό
        Tavily Search
             β”‚
             β–Ό
 Search Results Returned
             β”‚
             β–Ό
 Mistral Generates Final Answer
             β”‚
             β–Ό
Display to User

πŸ“§ Email Workflow

User connects Gmail
        β”‚
        β–Ό
Google OAuth Verification
        β”‚
        β–Ό
Access Token Generated
        β”‚
        β–Ό
Encrypted Storage
        β”‚
        β–Ό
User asks AI to send email
        β”‚
        β–Ό
AI drafts email
        β”‚
        β–Ό
Nodemailer sends email
        β”‚
        β–Ό
Recipient receives email

πŸš€ Latest Update

Added

  • βœ… Loader Component
  • βœ… Sidebar Navigation
  • βœ… Dashboard Chat Interface
  • βœ… Thinking Indicator
  • βœ… Typing Animation Effect
  • βœ… Custom useChat Hook
  • βœ… Email Integration Component
  • βœ… Chat API Service
  • βœ… Redux Store Configuration
  • βœ… Toast Notifications
  • βœ… Tailwind CSS Setup

AI Improvements

  • πŸ€– Integrated Mistral AI
  • 🌍 Connected Tavily AI for real-time internet access
  • πŸ“§ Gmail OAuth Authentication
  • βœ‰οΈ AI can send emails on behalf of authenticated users
  • πŸ” Secure Gmail verification using Google OAuth + Nodemailer


πŸ”’ Security

  • JWT Authentication
  • Protected Routes
  • Google OAuth2 Authentication
  • Secure Access Tokens
  • Environment Variables
  • API Key Protection

πŸ“ˆ Future Improvements

  • Voice Conversations
  • Streaming Responses
  • Image Generation
  • File Upload Support
  • Conversation Export
  • AI Memory
  • Markdown Rendering
  • Code Syntax Highlighting
  • Multi-Model Support
  • Dark/Light Theme

🀝 Contributing

Contributions are welcome.

  1. Fork the repository

  2. Create a new branch

git checkout -b feature/your-feature
  1. Commit changes
git commit -m "feat: add new feature"
  1. Push branch
git push origin feature/your-feature
  1. Open a Pull Request

πŸ“œ License

This project is licensed under the MIT License.


⭐ If you found this project useful, consider giving it a Star.

Built with ❀️ using React, Node.js, Mistral AI, Tavily AI and Gmail API

About

AI-powered chat assistant built with React, Node.js, Mistral AI, Tavily AI, and Gmail API for intelligent conversations, real-time web search, and AI-powered email automation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages