AlienDB is an analytics platform for trending Reddit threads. It stores historical data for the top threads on Reddit at any given time, including karma trends and comment stats. More information is available at https://aliendb.info/about.
AlienDB is structured as 4 Docker services. 3 of these, PostgreSQL
, Redis
, and RabbitMQ
, use images from the public Docker repository. The final one, web
is built manually. The project makes use of docker-compose to handle service definitions.
The web container is overseen by supervisor
, which ensures that the following backend services are kept active:
- Gunicorn, the WSGI server for the Django application.
- Nginx, the public-facing web server.
- Celery, a task manager used to periodically scrape Reddit data.
- Flower, a small non-public web server for monitoring Celery tasks.
The web app itself uses Django as a backend, with the majority of the application code in the analytics
app which is found in web/aliendb/apps/analytics
.
It is recommended that you create copies of the config files for development and production environments. For example, for a development environment:
cp docker-compose.yml docker-compose-dev.yml
cp .env .env-dev
You will need to update any references from .env to .env-dev in the docker-compose-dev.yml file.
Most settings given in the provided .env file are suitable for development use. However, you will need to configure the Praw settings in order for the app to retrieve data from Reddit.
- Register a Reddit application. You should use the "script" classification.
- Identify the client_id and client_secret keys from the app's information panel.
- Fill in the necessary information in your env file.
- Install Docker and docker-compose.
- Build the Docker services:
docker-compose -f docker-compose-dev.yml build --no-cache
- Create and start the Docker containers:
docker-compose -f docker-compose-dev.yml up [-d]
- Connect to the website at
http://localhost
- Make any necessary changes to the code.
- Stop and remove the
web
container.
docker-compose -f docker-compose-dev.yml stop web
docker-compose -f docker-compose-dev.yml rm web
- Build the new image and create+start a new container.
docker-compose -f docker-compose-dev.yml up [-d] --build
This project generally uses the generic testing framework provided by Django, which is itself based on Python's built-in unittest
module. For general information about writing tests, see Django's documentation on the subject.
- Start the containers using the above Building instructions.
- Run the appropriate
manage.py test
command on the runningweb
container:
docker-compose -f docker-compose-dev.yml run --rm web \
python manage.py test aliendb.apps.analytics.tests