Django version of the chatgpt-clone.
License: GPLv3
- Python 3.9+
- Node
- PostgreSQL
- Git
- Task.dev
- Doppler CLI
- OpenAPI API Key: https://platform.openai.com/account/api-keys
You can install all required dependencies using homebrew by running:
brew install python node postgresql@14 git go-task dopplerhq/cli/doppler
Install the Doppler CLI:
# See https://docs.doppler.com/docs/install-cli for other operating systems
brew install dopplerhq/cli/doppler
Login and create your free Doppler account on the Developer plan:
doppler login
Create chatgpt-webapp
Project:
doppler projects create chatgpt-webapp
Use the Development
environment:
doppler setup --project chatgpt-webapp --config dev
Import the secrets and config from sample.env
:
doppler secrets upload sample.env
Verify the CLI can fetch secrets:
doppler secrets
Create virtual environment and install dependencies:
task dev:venv
Activate virtual environment:
source ~/.virtualenvs/django-chatgpt-clone/bin/activate
Initialize the database:
task dev:init-local-db
Perform the required database migrations:
task dev:migrations
Then run the dev server:
task django:server
It's recommended to run the development server in TLS mode with a locally trusted certificate using mkcert
.
Add the chatgptclone.local
host to your hosts file:
echo -e "\n127.0.0.1\tchatgptclone.local" | sudo tee -a /etc/hosts > /dev/null
- Install mkcert by running
brew install mkcert
mkcert -install
- Generate the TLS certificate:
mkcert chatgptclone.local
This will generate two files: chatgptclone.local.pem
(certificate) and chatgptclone.local-key.pem
(private key), both signed by the local CA.
- Then run the server using Gunicorn:
task server
Moved to settings.
-
To create a normal user account, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
-
To create a superuser account, use this command:
$ python manage.py createsuperuser
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
Running type checks with mypy:
$ mypy chatgpt_clone
To run the tests, check your test coverage, and generate an HTML coverage report:
$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html
$ pytest
Sentry is an error logging aggregator service. You can sign up for a free account at https://sentry.io/signup/?code=cookiecutter or download and host it yourself. The system is set up with reasonable defaults, including 404 logging and integration with the WSGI application.
You must set the DSN url in production.
The following details how to deploy this application.
See detailed cookiecutter-django Heroku documentation.