Backend for image classification tool using Django, Celery and RabbitMQ.
Email huhenry50@gmail.com for any questions.
To interact with the server, make sure the frontend is running as well.
Table of Contents
The server can be run using Docker and without Docker.
The images are built locally. For the curious, details are in Dockerfile and docker-compose.yml.
-
From a new terminal, in your local cloned repository directory, execute:
$ docker-compose build
-
$ docker-compose up -d $ docker-compose run web manage.py makemigrations $ docker-compose run web manage.py migrate
-
$ docker-compose down
If you do not wish to use the Docker image, this section provides instructions on how to run the server manually.
Note: this section still uses Docker for RabbitMQ. You can follow the below RabbitMQ setup or set up RabbitMQ locally without a RabbitMQ image.
In your local repo, create a .env file and place these contents inside:
PRODUCTION=False
DEBUG=True
DB_ENGINE=django.db.backends.sqlite3
DB_NAME={place your desired sqlite file path here}
# Frontend host and port
CORS_ALLOWED_ORIGINS=http://localhost:3000
# OPTIONAL email configuration, check the SMTP servers and ports
EMAIL_HOST={email server host here, ex. smtp.gmail.com}
EMAIL_PORT={email server port here, ex. 587}
EMAIL_HOST_USER={your email here}
EMAIL_HOST_PASSWORD={your email password here}
# RabbitMQ host and port
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672//BE CAREFUL: DO NOT SHARE THIS .env FILE.
This setup uses pipenv as the Python virtual environment.
From a new terminal, in your local cloned repository directory, execute:
$ pipenv shell
$ pipenv install
$ cd uClassify/
$ python manage.py makemigrations
$ python manage.py migrateContinuing from above, execute:
$ python manage.py runserverFor every fresh run, execute:
$ pipenv shell
$ cd uClassify/
$ python manage.py runserverBy default, the RabbitMQ image is used by celery. You can pull any RabbitMQ image you like from Docker Hub.
ex.
$ docker pull rabbitmqThen run RabbitMQ (either through the Docker desktop app or from your command line).
IMPORTANT: make sure the CELERY_BROKER_URL is pointing to the RabbitMQ port, by default it is 5672
From a new terminal, in your local cloned repository directory, execute:
$ pipenv shell
$ cd uClassify
$ celery -A uClassify worker -l INFO -P soloThe EC2 instance is currently down.
AWS powers the server hosted on my domain, utilizing EC2, RDS and S3.
- code cleanup
- improve error handling
- (prod) provide classification model downloads