Skip to content

Latest commit

 

History

History
198 lines (144 loc) · 6.59 KB

README.md

File metadata and controls

198 lines (144 loc) · 6.59 KB

Screenshot

made-with-python Build Status Code style: black Checked with pylint Checked with flake8 Checked with pydocstyle Checked with mypy License EO principles respected here CodeFactor Docker pulls Website

Quotes

Simple web application to show quotes of famous people.

It is built with django python web framework.

Note: please take into account that it is built for demo purpose but not for actual usage.

Tools

Production

  • front-end
    • html5
    • css3
  • back-end
    • python 3.7, 3.8
    • django web framework
  • docker >= 18.0
  • k8s >= 1.21.1

Development

Usage

Usage

Quick start

Please discover app via:

Docker

docker run --rm -it -p 3000:5001 vyahello/quotes:<version> quotes

Please access an application via http://0.0.0.0:3000 endpoint

K8S

kubectl create deployment quotes --image=vyahello/quotes 
kubectl expose deployment quotes --type=LoadBalancer --port=3000

Please access an application via http://0.0.0.0:3000 endpoint

Source code

git clone [email protected]:vyahello/quotes.git
cd quotes 
python3 -m venv venv 
. venv/bin/activate
pip install -r requirements.txt 
pip install -r requirements-dev.txt 
python quotes/manage.py runserver

Please access an application via http://127.0.0.1:8000 endpoint

⬆ back to top

Development notes

REST API

Rest api is build with djangorestframework and drf-yasg (swagger) libraries.

Here are available api endpoints:

  • /api:
    • GET: Retrieves all quotes
    • POST: Creates a new quote
  • /api/<id>:
    • GET: Retrieves a single quote by it's id
    • PUT: Updates a single quote by it's id
    • DELETE: Deletes a quote by it's id

Please refer to /api/docs endpoint which provides a neat swagger REST API documentation.

Setup

Please use it as a reference to create/manage fresh django application

django-admin startproject manager  # create application manager
django-admin startapp app  # create application source
python quotes/manage.py makemigrations  # add new model (if exists) to database
python quotes/manage.py migrate  # sync models with database
python quotes/manage.py shell  # start interactive shell
python quotes/manage.py createsuperuser  # create user for administration

To manage an application please use /admin endpoint.

Please use admin superuser for management.

Docker

Please use the following example notes to proceed with docker image provisioning.

K8S

It is possible to orchestrate app via kubernetes, the following command will launch 3 instances of app.

kubectl apply -f k8s/deployment.yaml
kubectl get pods
NAME                      READY   STATUS    RESTARTS   AGE
quotes-6f64474dc5-7ct8t   1/1     Running   0          4m49s
quotes-6f64474dc5-95cx8   1/1     Running   0          4m49s
quotes-6f64474dc5-dg5n8   1/1     Running   0          4m49s

Testing

Generally, pytest tool is used to organize testing procedure.

Please follow next command to run only unit tests:

pytest -m unit

Or only api tests:

pytest -m api

Or only web tests, eventually:

pytest -m web

CI

Project has Travis CI integration using .travis.yml file thus code analysis (black, pylint, flake8, mypy, pydocstyle) and unittests (pytest) will be run automatically after every made change to the repository.

To be able to run code analysis, please execute command below:

./analyse-source-code.sh

Release notes

Please check changelog file to get more details about actual versions and it's release notes.

Meta

Author – Volodymyr Yahello. Please check authors file for more details.

Distributed under the MIT license. See license for more information.

You can reach out me at:

Contributing

I would highly appreciate any contribution and support. If you are interested to add your ideas into project please follow next simple steps:

  1. Clone the repository
  2. Configure git for the first time after cloning with your name and email
  3. pip install -r requirements.txt to install all project dependencies
  4. pip install -r requirements-dev.txt to install all development project dependencies
  5. Create your feature branch (git checkout -b feature/fooBar)
  6. Commit your changes (git commit -am 'Add some fooBar')
  7. Push to the branch (git push origin feature/fooBar)
  8. Create a new Pull Request

What's next

All recent activities and ideas are described at project issues page. If you have ideas you want to change/implement please do not hesitate and create an issue.

⬆ back to top