code-wizard91 / Docker-MotorTrade

Created a complete CRUD based Flask web application using Python and Boostrap and an Azure Manged MySQL Database, whilst following an agile project management structure. Used Jenkins for CI//CD and Terraform, Ansible for creating and managing infrastructure, Docker and Kubernetes for mass container orchestration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Index

Brief

ERD and Diagrams

Sprints & Planning

Testing Methadology

My Deployment Method

Retrospective

Authors

Acknowledgements

How To Install

The Product Brief

To create:

  • OOP-based application
  • Utilisation of tools methodologies and technologies that encapsulate all core modules covered during training.
  • The application must manipulate two tables
  • Application must have full CRUD functionality.

Solution

I decided to create a website using Flask and Boostrap for the Front-End, the website is essentially a online marketplace where users can create Car Adverts that will take details such as; Images, Descriptions, Price, Mileage, Location and Phone numbers. Users will also have the ability to view cars for sale as well as update and delete their adverts. Users will have accounts which will be used to log them into the website..

ERD and Diagrams

Initial Entity Relationship Diagrams

Initial ERD

The ERD Diagram above was the initial structure, After careful consideration I decided that the table for posts is not needed and adds furthur complexity to the project. (Click image for higher quality image).

  • Instead I decided to create a table called Adverts that makes a more logical connection to my solution as the Users table will connect directly to the Adverts table (As users will create Adverts in which their cars will be posted) The relationship here will be a 1 to Many as each user can have many adverts.

Finally I removed a few fields that were redundant and added fields such as password, profile image and more specific user information such as First names and Last names.

Final Entity Relationship Diagrams

Final ERD

Risk Assessment

MosCoW Prioritization / Requirements / Product Backlog

As seen below I have created a MosCoW Prioritisation list where all the requirements of the project are listed, I used a colour labelling method On Trello to make sure that each requirement had its own importance category. (Full Trello Board Later in the Document) (Click image for higher quality image)

MosCow Labels

Risk Assessment Table

Risk Assessment Table Risk Assessment Table Part 2

User Stories (Users and Developers)

The User Stories was also done on Trello, I listed all the use-cases for the product in the perspective of a user and a developer. (Click image for higher quality image)

UserStories

Trello Board (Sprint 1)

Here is the First Sprint I did after defining the main requirements of the project. (Click image for higher quality image).

Trello Image

Trello Board (Sprint 2)

You can see tasks from the first Sprint have been moved to the Done list and further tasks have been actioned and moved to the second Sprint stage. (Click image for higher quality image).

Sprint 2 Image

Final Stages (Sprint 2....)

Most of the project requirements have been fullfilled at this point and the final touches are being made, as you can see the items that needed actioning have been moved to the done stage and the few optional requirements are being finalised. (Click image for higher quality image)

Sprint 2 Continued..

Last Sprint to completion

The project is now in the completion stage, all requirements have been met and optional features have been added, also some un-needed features were not implemented such as the search function and an additional DB table due to time restraints.

Completion..

Testing Methodology

Decided to use Pytest to create my tests, Mostly testing all my routes and request codes to see if everything was working correctly I automated the testing using Jenkins, making sure that the deployment would not go ahead unless the tests passed as the build/deploy process was a trigger I set up in Jenkins.

Testing Report (Pytest Generated HTML)

Below is the HTML Coverage Report that was generated after the automated testing completed which was done using Jenkins, also after the testing was complete the file was moved to the test_results folder which is also can be found on my github repo here

HTML Coverage Report

Testing Report (Generated after automated Jenkins Test)

Here is the coverage report which was generated on Jenkins after the automated Testing took place. You can also see that it triggers the build/deployment process if the tests pass and sends out a notification on Slack.

Jenkins Coverage Report

Deployment

Deployment Pipeline

The Deployment pipeline for this Flask application was done using Git/Github for source control and automating that process using webhooks with Jenkins, the process would then go into automatically triggering the testing phase which I did using Pytest on a VM running Jenkins, after the tests Jenkins will be triggered into the build/deployment process if the testing was successful, Jenkins will then build and Deploy the app on a seperate VM (APP VM) on Azure. Also a seperate instance of Azures MySql will be used and connected to this VM for data storage. (Click image for higher quality image)

How the process looks

Here is the actual test and building process taking place.

Jenkins Coverage Report

List of Technologies Used

  • MySQL for Application Database
  • Python - Coding in Flask
  • Flask - Framework
  • Jenkins - CI Server
  • Testing - Pytest
  • Github Project - Version Control System
  • Trello Board - Project Tracking Board
  • Azure Services (MySQL Azure DB, Azure VM)

Retrospect

Creating this application in an Agile way allowed me to understand and appreciate the benefits of this way of Project Mangement, I also enjoyed the process of putting Agile techniques into how the project was managed using Sprints, Product backlogs etc. Also using the CI/CD way of developing software played a key part in the success of this project as it allowed me to use tools such as Pycharm for testing and Jenkins to Automate the process that links everything together. I was also very happy with the way I was able to use Azure VMs (1 for Jenkins and 1 for the App) to split up processes that normally would happen on a single VM thus allowing for increased durability and extra contingencies to manage risk. The way the application was deployed using Jenkins and how a seperate Azure managed DB worked together was very satisfying to see as the end result was a process that had become very robust and impressive.

I faced many issues along the way, as I was learning the technologies whilst applying them but this ended up making the learning easier as I was able to fail fast and learn faster.

If I had to go back and change something I would improve the front end functionality more and add furthur features such as search filters and also a Gallery feature so users can upload more than one image.

All together the project was a success and I would definitely use these technologies again in the future.

Authors

Mahboob Ali

Acknowledgements

  • Jay Grindrod - A true motivation, he helped me in far too many ways to list here, Inspired me to push hard and learn things that were beyond the scope of what I needed to acheive. Thanks for your help Jay!

How to Run this App using Docker-Compose

  • Step 1:

Get Docker and Docker-Compose set up on your Machine. (I used Linux)

Make sure you have the port 5000 open on your pc.

  • Step 2:

Git Clone this repository

From inside the repository run "docker-compose up -d"

The app is now running on your localhost on port 5000

About

Created a complete CRUD based Flask web application using Python and Boostrap and an Azure Manged MySQL Database, whilst following an agile project management structure. Used Jenkins for CI//CD and Terraform, Ansible for creating and managing infrastructure, Docker and Kubernetes for mass container orchestration


Languages

Language:HTML 58.9%Language:Python 38.1%Language:CSS 2.4%Language:Dockerfile 0.5%