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/dopplerInstall the Doppler CLI:
# See https://docs.doppler.com/docs/install-cli for other operating systems
brew install dopplerhq/cli/dopplerLogin and create your free Doppler account on the Developer plan:
doppler loginCreate chatgpt-webapp Project:
doppler projects create chatgpt-webappUse the Development environment:
doppler setup --project chatgpt-webapp --config devImport the secrets and config from sample.env:
doppler secrets upload sample.envVerify the CLI can fetch secrets:
doppler secretsCreate virtual environment and install dependencies:
task dev:venvActivate virtual environment:
source ~/.virtualenvs/django-chatgpt-clone/bin/activateInitialize the database:
task dev:init-local-dbPerform the required database migrations:
task dev:migrationsThen run the dev server:
task django:serverIt'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 mkcertmkcert -install- Generate the TLS certificate:
mkcert chatgptclone.localThis 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 serverMoved 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.