derbious / dndapi

Dungeons and Donations rest api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dndonations Web App

Description

This is a basic python(flask) CRUD app that uses sqlite. It serves up the API endpoints and the static html that runs our dndonations logging system

Development

Requirements

To get the development environment up and running you need docker installed.

Testing workflow

  1. Do some editing
  2. Rebuild the container with the command docker build . -t dndapi
  3. Run the newly built container: docker run -it -p 8080:8080 -v ${PWD}/development.db:/data/sqlite.db dndapi This binds to port 8080 to serve up the web frontend and mounts a development database file.
  4. Point your browser to http://localhost:8080/ to see your changes in action.

The terminal output should show python logging info, and the browser developer console shows the javascript related debug info.

Notable files

  • __init__.py: This kicks off the webserver.
  • auth.py: This handles the authentication. we are using JWT to do the API auth
  • database.py: This is the database controller. it contains all of the sqlite3 code
  • endpoints/*.py: These run all of the api endpoints. They are separated out by function

Techical Details

DB Schema

+------------------------------+          +-------------------------+
|Donors                        |          |Characters               |
+------------------------------+          +-------------------------+
|id               INTEGER pkey +<-+-+-+   |id          INTEGER pkey <--+
|first_name       TEXT         |  | | |   |name        TEXT UNIQUE  |  |
|last_name        TEXT         |  | | |   |race        TEXT         |  |
|physical_address TEXT         |  | | |   |class       TEXT         |  |
|dci_number       TEXT         |  | | |   |state       TEXT         |  |
+------------------------------+  | | |   |num_resses  INTEGER      |  |
                                  | | +---+player_id   INTEGER      |  |
+-----------------------+         | |     |start_time  TIMESTAMP    |  |
|Donations              |         | |     |end_time    TIMESTAMP    |  |
+-----------------------+         | |     +-------------------------+  |
|id        INTEGER pkey |         | |                                  |
|timestamp TIMESTAMP    |         | |     +-------------------------+  |
|amount    INTEGER      |         | |     |Queue                    |  |
|method    TEXT         |         | |     |                         |  |
|donor_id  INTEGER      +---------+ |     |id           INTEGER pkey|  |
+-----------------------+           |     |position     INTEGER     |  |
                                    |     |character_id INTEGER     +--+
+------------------------+          |     +-------------------------+
|Purchases               |          |
+------------------------+          |     +-----------------------+
|id        INTEGER pkey  |          |     |Dms                    |
|timestamp TIMESTAMP     |          |     +-----------------------+
|amount    INTEGER       |          |     |id        INTEGER pkey |
|reason    TEXT          |          |     |name      TEXT         |
|donor_id  INTEGER       +----------+     |team      TEXT         |
+------------------------+                |numkills  INTEGER      |
                                          |current   INTEGER      |
                                          +-----------------------+

About

Dungeons and Donations rest api


Languages

Language:Python 44.8%Language:HTML 22.4%Language:JavaScript 16.8%Language:CSS 15.5%Language:Dockerfile 0.4%Language:Shell 0.2%