QuickChat AI is a premium, full-stack MERN (MongoDB, Express, React, Node.js) web application that empowers users with AI-driven text communication and custom image generation. Operating on a tiered credit system, users can converse with advanced LLMs, generate stunning images, publish creations to a community gallery, and purchase credit packages through a secure Stripe payment pipeline.
- π¬ Intelligent Chat Assistant β Interactive real-time conversation powered by OpenAI's
gpt-3.5-turbowith automated fallback to Google Gemini (gemini-2.5-flash) for unmatched service resilience. - π¨ AI Image Generation β Custom image generation using OpenAI DALL-E 2 (with LoremFlickr fallback). Generated images are optimized and stored in the cloud via ImageKit.
- πͺ Action-Based Credits System β Integrated credit validation mechanism (1 credit for text generations, 2 credits for image generations).
- π³ Stripe Checkout & Webhook Integration β Standard checkout flow for credit pack purchases (Basic, Pro, Premium) backed by secure Stripe Webhook event handlers.
- π€ Community Gallery β A public showcase feed where users can publish and browse AI-generated images.
- π» Syntax & Markdown Highlighting β Rendered AI chat responses support rich Markdown layout and programming syntax styling via PrismJS and React Markdown.
- π± Premium UI/UX Design β Responsive dashboard interface featuring glassmorphism, smooth CSS transitions, notifications via React Hot Toast, and a dedicated dark theme.
- React 19 β Component-based User Interface framework.
- Vite β Next-generation, high-performance frontend build tool.
- Tailwind CSS v4 β Modern utility-first CSS styling engine.
- React Router Dom v7 β Dynamic frontend client-side routing.
- Axios β Promise-based HTTP client for API communication.
- React Hot Toast β Aesthetic, responsive toast notifications.
- React Markdown & PrismJS β Content rendering with source code blocks syntax highlighting.
- Node.js & Express β High-throughput application framework.
- MongoDB & Mongoose β NoSQL database for flexible data modeling.
- OpenAI SDK β Standard wrapper for GPT and DALL-E endpoints.
- Google Generative AI SDK β API interface for Gemini models.
- Stripe SDK β Online payment processing suite.
- ImageKit SDK β Cloud image hosting, optimization, and transformation.
- JSON Web Tokens (JWT) & Bcryptjs β Secure token-based user authentication and salted password hashing.
QuickChat-OpenAI/
βββ client/ # React Frontend Application
β βββ src/
β β βββ assets/ # Icons, CSS styles (including Prism themes)
β β βββ components/ # ChatBox, Sidebar, Message components
β β βββ context/ # React AppContext (Global State & User Fetching)
β β βββ pages/ # Login, Credits, Community, Loading pages
β β βββ App.jsx # Main Application routing & view coordinator
β β βββ main.jsx # Application bootstrap entry point
β βββ package.json # Frontend dependency registry
β βββ vite.config.js # Vite configuration
β
βββ server/ # Express Backend Application
β βββ configs/ # MongoDB, OpenAI, Gemini, ImageKit connections
β βββ controllers/ # Request handlers (User, Chat, Message, Credits, Webhooks)
β βββ middlewares/ # Auth and request pre-processing
β βββ models/ # Mongoose schemas (User, Chat, Transaction)
β βββ routes/ # Express route entrypoints
β βββ testAllFlows.js # Integration and end-to-end testing script
β βββ server.js # Application entry point
β βββ package.json # Backend dependency registry
β
βββ TODO.md # Action items checklist
To run the project, you need to set up environment variables in both the client and server directories.
Create a .env file in the server/ directory and configure the following parameters:
# Server Running Environment
PORT=3000
JWT_SECRET=your_jwt_secret_key
# Database
MONGODB_URI=your_mongodb_connection_string
# AI Providers
OPENAI_API_KEY=your_openai_api_key
GEMINI_API_KEY=your_google_gemini_api_key
# Payment Processing (Stripe)
STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
# Image Management (ImageKit)
IMAGEKIT_PUBLIC_KEY=your_imagekit_public_key
IMAGEKIT_PRIVATE_KEY=your_imagekit_private_key
IMAGEKIT_URL_ENDPOINT=your_imagekit_url_endpointCreate a .env file in the client/ directory and configure:
VITE_SERVER_URL=http://localhost:3000Follow these steps to clone the repository and run QuickChat AI locally.
- Node.js (v18+ recommended)
- MongoDB Instance (Local or MongoDB Atlas)
- Stripe Account (For developer test keys)
- ImageKit Account (Free tier endpoint keys)
git clone https://github.com/Sg-2003/QuickChat-OpenAI.git
cd QuickChat-OpenAI- Navigate to the server folder:
cd server - Install dependencies:
npm install
- Configure the
.envfile based on the environment configuration section. - Start the development server (runs with nodemon):
npm run server
- Open a new terminal and navigate to the client folder:
cd ../client - Install dependencies:
npm install
- Configure the
.envfile. - Start the Vite development server:
npm run dev
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/api/user/register |
Register a new user | No |
POST |
/api/user/login |
Login user and return JWT | No |
GET |
/api/user/get |
Get authenticated user info | Yes (Bearer Token) |
GET |
/api/user/published-images |
Fetch shared community images | No |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/api/chat/create |
Open a new chat session | Yes (Bearer Token) |
GET |
/api/chat/get |
Get all chat sessions for user | Yes (Bearer Token) |
POST |
/api/chat/delete |
Delete a specific chat session | Yes (Bearer Token) |
| Method | Endpoint | Description | Auth Required | Cost |
|---|---|---|---|---|
POST |
/api/message/text |
Prompt text-based AI response | Yes (Bearer Token) | 1 Credit |
POST |
/api/message/image |
Trigger image generation | Yes (Bearer Token) | 2 Credits |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/api/credit/plans |
Fetch available credit plans | No |
POST |
/api/credit/purchase |
Initiate Stripe Checkout session | Yes (Bearer Token) |
POST |
/api/stripe |
Handle Stripe webhooks (raw JSON) | No |
QuickChat AI includes a comprehensive integration test suite that tests the end-to-end lifecycle.
To run the automated flows (registration, chat creation, message dispatch, image generation, community listing, and Stripe session generation):
- Make sure your local MongoDB and Server are running.
- Navigate to the
server/directory. - Execute:
node testAllFlows.js
Upon success, you should see logs validating each process step, culminating in:
--- ALL TESTS PASSED SUCCESSFULLY! ---