Skip to content

ryan-blunden/django-chatgpt-clone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django ChatGPT Clone

Django version of the chatgpt-clone.

Built with Cookiecutter Django Black code style

License: GPLv3

Requirements

You can install all required dependencies using homebrew by running:

brew install python node postgresql@14 git go-task dopplerhq/cli/doppler

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

Local Development Environment

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

Optional: Local Development with TLS

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
  1. Install mkcert by running
brew install mkcert
mkcert -install
  1. 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.

  1. Then run the server using Gunicorn:
task server

Cookiecutter Django Settings

Moved to settings.

Basic Commands

Setting Up Your Users

  • 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.

Type checks

Running type checks with mypy:

$ mypy chatgpt_clone

Test coverage

To run the tests, check your test coverage, and generate an HTML coverage report:

$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html

Running tests with pytest

$ pytest

Sentry

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.

Deployment

The following details how to deploy this application.

Heroku

See detailed cookiecutter-django Heroku documentation.

Languages

  • Python 57.6%
  • JavaScript 17.8%
  • CSS 17.5%
  • HTML 4.9%
  • Makefile 2.0%
  • Shell 0.1%
  • Procfile 0.1%