Skip to content

Self Hosted ChatGPT Clone: A Full-Stack Conversational AI Platform powered by React, Django REST Framework, and PostgreSQL and OpenAI's GPT-3.5 Model. Most of the code is written by GPT-4 model.

License

fatihbaltaci/chatgpt-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Self Hosted ChatGPT Clone

ChatGPT Clone: Self Hosted, Full-Stack Conversational AI Platform powered by React, Django REST Framework, and PostgreSQL and OpenAI's GPT-3.5 API. Most of the code is written by GPT-4 model.

ChatGPT Clone - It uses GPT-3.5 to generate responses to messages.

πŸ“– Table of Contents

πŸš€ Features

  • Self Hosted: You can host the project on your own server or local machine. All the data and OpenAI API Key are stored on your server.
  • Full-Stack: The project is a full-stack project that includes a React frontend, Django REST Framework backend, and PostgreSQL database.
  • Conversational AI: The project uses OpenAI's GPT-3.5 API to generate responses to user inputs.
  • Docker Compose: The project uses Docker Compose to run the project in containers.
  • Django Admin Panel: The project includes a Django Admin Panel to manage the project.
  • Supported OS: The project is tested on Ubuntu and MacOS.

πŸ›  Prerequisites

⚑️ Quick Start (Recommended)

You can quickly deploy ChatGPT Clone by running the following command. This script ask you for your OpenAI API Key. Your OpenAI API Key is only stored in your .envs/.env file and is never sent to any other server. Please check the install.sh file to see what it does.

This script clones the project to your $HOME directory, updates the .envs/.env file with your OpenAI API Key, and runs the project using Docker Compose.

curl -sSL https://raw.githubusercontent.com/fatihbaltaci/chatgpt-clone/main/install.sh | bash

πŸ”§ Installation (Manual)

Clone the Repository

git clone https://github.com/fatihbaltaci/chatgpt-clone.git
cd chatgpt-clone

Update .env File

Update the OPENAI_API_KEY key in the .envs/.env file with your OpenAI API Key. You can also update the other environment variables in this file.

πŸš€Β Run the Project

docker-compose build
docker-compose up -d

🌐 Access the Project

The project will be available at http://localhost:8090/

🧐 Access the Django Admin Panel

The admin panel will be available at http://localhost:8090/admin/ and you can login with the superuser credentials you set in the .envs/.env file.

🧹 Clean Up

If you installed the project using the install.sh script, you must first change the directory to the $HOME/chatgpt-clone directory before running the commands below.

cd $HOME/chatgpt-clone
docker-compose down

(Optional) Delete Postgres Volume (Warning: This will delete all data in the database)

docker volume rm chatgpt-clone_postgres

πŸ›  Development (Contributing)

If you want to contribute to this project, you can follow the instructions below to set up a development environment.

Backend

Create Postgres

Docker is required to run the Postgres database. If you don't have Docker installed, you can install it from here.

POSTGRES_VERSION=13.6
POSTGRES_PASSWORD=changeme
docker run -d --name chatgptpostgres \
    -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
    -p 5532:5432 \
    --hostname chatgptpostgres \
    --restart always \
    -v $HOME/BACKUP/chatgptpostgres:/var/lib/postgresql/data \
    postgres:$POSTGRES_VERSION

Installation

Create a virtual environment and install the dependencies.

cd chatgpt_backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Running

cd chatgpt_backend
./migrate_run_server.sh

To access Django Admin, go to http://localhost:8090/admin/ and login with the superuser credentials you set in the .env.dev file

🐘 Access the Database Shell

Sometimes you may want to access the Django database shell. You can do so by running the following command:

cd chatgpt_backend
./db_shell.sh

##Β Frontend

Installation

cd chatgpt_frontend
npm install

Running

You can update the REACT_APP_BACKEND_URL key in the .env file with the URL of the backend server. Default value is http://localhost:8090/api. If your backend server is running on a different server or port, you must update this value. Do not forget to add /api at the end of the URL.

cd chatgpt_frontend
npm start

πŸ› Known Issues

If you get Error: pg_config executable not found. when running pip install -r requirements.txt, you must install PostgreSQL development libraries on your system.

On MacOS, you can install them with Homebrew:

brew install postgresql

On Ubuntu, you can install them with apt:

sudo apt update
sudo apt-get install libpq-dev python3-dev

πŸ“„ License

This project is licensed under the terms of the MIT license.

πŸ™Œ Credits

About

Self Hosted ChatGPT Clone: A Full-Stack Conversational AI Platform powered by React, Django REST Framework, and PostgreSQL and OpenAI's GPT-3.5 Model. Most of the code is written by GPT-4 model.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published