The UI is clone of ChatGPT and LLM model used is gemini-1.5-flash
with the help of @google/generative-ai
sdk.
To get a local copy up and running, follow these simple steps:
-
Clone the repository:
git clone https://github.com/Shoebtamboli/chatGPT-clone.git cd chatGPT-clone
-
Create a
.env
file in the root directory of the project and add the following environment variables:NODE_ENV=development PORT=5000 MONGO_URI=mongodb://mongo:27017/mydatabase JWT_SECRET=your_jwt_secret API_KEY=YOUR_API_KEY GOOGLE_CLIENT_ID=YOUR_GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET=YOUR_GOOGLE_CLIENT_SECRET SESSION_SECRET=your-secret-key FRONTEND_URI=http://localhost:3000 BACKEND_URI=http://localhost:5000
-
Start the development environment:
docker-compose up --build
This command will build and start the containers defined in the docker-compose.yml file.
-
Once the containers are up and running, you can access:
Frontend: http://localhost:3000 Backend: http://localhost:5000
-
To stop the development environment, run:
docker-compose down
To enable Google OAuth for your application, you need to obtain a Client ID and Client Secret from the Google Cloud Console. Follow these steps:
-
Go to the Google Cloud Console
- Visit https://console.cloud.google.com/
- Sign in with your Google account
-
Create a New Project (or select an existing one)
- Click on the project dropdown at the top of the page
- Select "New Project"
- Give your project a name and click "Create"
-
Enable the Google+ API
- In the left sidebar, click on "APIs & Services" > "Library"
- Search for "Google+ API" and click on it
- Click "Enable"
-
Configure the OAuth Consent Screen
- In the left sidebar, click on "APIs & Services" > "OAuth consent screen"
- Choose "External" as the user type (unless your application is for internal use only)
- Fill in the required fields (App name, User support email, Developer contact information)
- Add the necessary scopes (e.g.,
./auth/userinfo.email
,./auth/userinfo.profile
) - Add your authorized domains
- Save and continue
-
Create OAuth Client ID
- In the left sidebar, click on "APIs & Services" > "Credentials"
- Click "Create Credentials" and select "OAuth client ID"
- Choose "Web application" as the application type
- Set a name for your OAuth 2.0 client
- Add authorized JavaScript origins (e.g.,
http://localhost:3000
for development) - Add authorized redirect URIs (e.g.,
http://localhost:3000/auth/google/callback
) - Click "Create"
-
Obtain Client ID and Client Secret
- After creation, you'll see a modal with your Client ID and Client Secret
- Copy these values and store them securely
- You can always view these later in the Credentials section
-
Update Your .env File
- Add your Client ID and Client Secret to your
.env
file:GOOGLE_CLIENT_ID=your_client_id_here GOOGLE_CLIENT_SECRET=your_client_secret_here
- Add your Client ID and Client Secret to your
- Keep your Client Secret confidential. Never commit it to version control or share it publicly.
- For production, make sure to update the authorized origins and redirect URIs with your production URLs.
- Regularly rotate your Client Secret for enhanced security.