/pokebattle

Primary LanguageCSSMIT LicenseMIT

PokeBattle

A simple application to create and manage pokebattle with REST API!

API

API Authentication

This app use http token authentication to authenticate an user. To use any APIs you have to send authentication token in the http header.

  • Ssend a post request with username and password to http://localhost:8000/token-auth/, you will get authentication token in response.
  • Add the authentication token on the header of your subsequent API calls as bearer token to authenticate yourself.

Resources

This app leverages the following resources, but you don't need to worry about installing and configuring most of these. Just see prerequisites below for what you need on your machine to make this work:

  • Docker - for virtual development environment and easy deployment
  • Django - Python-based web framework
  • DRF - A powerful and flexible toolkit for building Web APIs.
  • VUE - The Progressive JavaScript Framework.
  • PostgreSQL - A powerful, open source object-relational database system.
  • Allauth - for user authentication
  • sbadmin2 - A Free Bootstrap Template from Start Bootstrap.

Prerequisites

As a prerequisite please make sure you have the following tools already installed on your machine:

  1. Git
  2. Docker
  3. Docker Compose

Setup in under 5 minutes!

  1. Clone this repo
git clone git@github.com:alihasanimam/pokebattle.git
  1. Build the Docker Container
cd pokebattle
docker-compose up --build

You should see all the resources including the web server startup in your terminal. When everything is complete, press Ctrl+C to exit from docker-compose.

  1. Populate Postgres DB
docker-compose exec web python manage.py migrate
  1. Seed initial data from fixutres (optional)
docker-compose exec web python manage.py loaddata user/fixtures/*

Demo

Lunch the application

docker-compose up

Now go to localhost:8000/. That should be enough for you to run the project locally.

  • Website: http://localhost:8000/
  • Default Admin: username: admin, password: adminadmin
  • Default User: username: user, password: useruser

Screenshots

Here is what your app should look like when you visit localhost:8000.

With this app you can:

  1. Create an account. Sign Up

  2. Login to an existing account if you've already created one. Login

  3. View your battle history. You can filter battles and delete any battle from the history. Home

  4. You can search any pokemon by its name. Search

  5. You can do a battle with two pokemons. Search

  6. After a battle, the app will show the winner and a record will be added in the battle history. Search

Helpful Docker + Django Commands

# rebuild docker container
docker build .
# start docker container
docker-compose up
# shutdown docker-container
docker-compose down


# generate db migrations
docker-compose exec web python manage.py makemigrations
# run db migrations
docker-compose exec web python manage.py migrate
# start new app
docker-compose exec web python manage.py startapp <app name>
# shell into docker container
docker-compose exec web python manage.py shell