Giter Club home page Giter Club logo

auto-xkcd's Introduction

auto-xkcd

Query the XKCD API.

Description

This is a learning project. The XKCD web comic provides a JSON API for requesting comic strips. This app, while being intentionally over-engineered, demonstrates some technologies I want to understand better, and serves as a showcase/reference for tools like FastAPI, rabbitMQ, minio, Redis, and more.

The main app consists of:

  • An API (FastAPI)
  • A SQLite database for storing comics, images, and metadata
  • A rabbitMQ messaging service
  • A Redis backend for rabbitMQ job results
    • I am sticking with Redis for now, despite their recent license change. I have not tested running Celery with a different key/value store.
    • I would like to eventually switch to Valkey
  • A Celery app to handle background/async tasks with rabbitMQ and Redis

The API handles requests to the XKCD API, with a rate limit of 1 request per 5 seconds (to avoid sending a ton of requests to the wonderful Randall Monroe...he doesn't deserve that) when multiple comics are requested. In the case of multiple comic requests, requests are broken into "partitions" when >15 comics are requested at once, and the requests are run as background tasks with rabbitMQ; the results can be retrieved with the FastAPI app, which pulls the results from the Redis backend.

Usage

  • Edit environment variables in ./containers/env_files

  • From the project root, run python dockerctl.py

    • Because the docker-compose.yml and .env files are nested in ./containers, it's annoying having to prepend -f ./containers/docker-compose.[dev|prod].yml to ever command.
    • The dockerctl.py script uses the cross-platform subprocess module to run Docker commands on your behalf. Follow the prompts to control Docker operations
  • Visit the API, rabbitMQ management console, or Redis commander using the following (assumes default ports, substitute your own if you change them):

service port
FastAPI 8000
rabbitMQ Management Console 15672
redis-commander webUI 8081

Celery Usage

This app uses Celery for background & scheduled tasks. Because the code is in a src/ directory, the celery -A ... command needs to be modified. To change the working directory of celery, use the --workdir=src/app_name param:

celery --workdir=src/auto_xkcd -A ...

Links

auto-xkcd's People

Contributors

redjax avatar pyvirus avatar yazgoo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.