For this project I was given the brief to design, produce, and deploy a flask web app of my choosing. The app must include integration with a MySQL database, and CRUD functionality. It must contain at least two tables sharing a one-to-many relationship. The structure of this app is shown in the diagram below.
The app must be hosted and deployed using containers, and a CI/CD pipeline must be used to automatically test, build, and delpoy the application.
I have built a python flask app for use in a board games cafe. Current board games can be added to the database, as can customers with their name, table number, and board game reservation (create functionality). The index page shows the current games and reservations (read functionality). Both games and reservations can be edited (update functionality), and removed from the database (delete functionality).
The two tables created are “Board Games” and “Customers”, with each game associated with multiple customers (one-to-many relationship). The ERD for these databases is shown below.
This project requires the integration of a CI pipeline, including version control, virtual environment, containers, and a build server.
Git was used as version control, with the project repository hosted on Github. This allows changes to be made and committed, while keeping the commit history for other versions. I began by committing a working flask app to the main branch. Changes used for tests and containerisation were implemented on separate branches. A .gitignore file is used to prevent the upload of the created database, and unnecessary information.
The application was originally created in Visual Studio Code, using a virtual environment. The develop environment was created using a python3 virtual environment hosted on a virtual machine using Ubuntu 20.04. This allows pip installs, and ensures that running the app will not conflict with any other pip installs on the same machine.
Docker containers were used in this project to create 3 packages: the flask application, the MySQL database, and Nginx. Deploying these 3 containers hosts the application on the local public IP, connects it to the database, and allows access via a reverse proxy. These were uploaded to Dockerhub for use with the Dockercompose and Dockerswarm. A docker compose file was used to define and run these containers using a single command. This was further expanded by using docker swarm deployment. Using two virtual machines (master and worker nodes), I am able to run the containers as a service, and deploy them across two machines. I can access my app via the public IP addresses of the machines.
Jenkins was used as a CI server. It was connected to the git repository, and automatically tested, built, and deployed the application using the docker compose file. It connected to a webhook, which triggered an automatic Jenkins build when a change is made to the code.
This pipeline is shown in the diagram below.
For this project, I used two virtual machines, one Master, and one Worker. The Master requires: Docker, Dockercompose, Jenkins, Python, Pip. The Worker requires: Docker, Python, Pip. Port 80 must be open on both machines to access the application.
Below is the risk assessment for the project. It has been updated with issues I encountered while developing the project.
Testing is required for the project. In this case, unit testing using pycharm was implemented. This tests the functionality of the app. Unit tests were written for the create, read, update, and delete functionality. These tests feed in a test game, and a test reservation. Using this information, we are testing that the routes of my app return a 200 response.
The tests I have written currently have poor coverage, as they encounter import error. This has been added to my list of work for the future. The coverage is shown below, with test_.py only reaching 5% coverage. The tests have not been integrated into the Jenkins pipeline.
Below is a video demonstrating the CRUD functionality of my app, as well as the automatic deployment via Jenkins after a push is made to the Git repository.
https://drive.google.com/file/d/1yXqljGwLAESJnlBbVreiWp5QkTXdaO-Q/view?usp=sharing https://drive.google.com/file/d/1tmEVO2GMUJaY8GaQmUVrEOQw2jqxZVgi/view?usp=sharing
My first priority is creating functioning tests. This will ensure that my application is functional before deploying it from Jenkins.
Currently, I am using two virtual machine. The master node is also hosting Jenkins. In the future I will run Jenkins on a third separate machine.
I will implement environment variables to ensure that sensitive information is not uploaded to GitHub.
I would like to implement a queue system for board game reservations. As two customers can reserve one board game, it would be useful to see who reserved it first, and at what time.
Finally, I will improve the layout and aesthetics of the application. I will create a traditional table display for the board games and reservations.




