{"id":23044806,"url":"https://github.com/sarakhild/capstone-project","last_synced_at":"2026-04-12T04:33:26.358Z","repository":{"id":263183916,"uuid":"879639831","full_name":"SaraKhild/capstone-project","owner":"SaraKhild","description":"This Flask application serves as a simple web interface for adding users and viewing user details","archived":false,"fork":false,"pushed_at":"2024-11-16T19:08:33.000Z","size":562,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-08T16:12:52.756Z","etag":null,"topics":["docker-compose","dockerfile","flask","mysql","python","redis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SaraKhild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-28T09:35:41.000Z","updated_at":"2024-11-16T19:16:51.000Z","dependencies_parsed_at":"2024-11-16T20:17:42.249Z","dependency_job_id":"5a0c106b-51b6-499a-af50-4b5481f51d9c","html_url":"https://github.com/SaraKhild/capstone-project","commit_stats":null,"previous_names":["sarakhild/capstone-project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraKhild%2Fcapstone-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraKhild%2Fcapstone-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraKhild%2Fcapstone-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraKhild%2Fcapstone-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SaraKhild","download_url":"https://codeload.github.com/SaraKhild/capstone-project/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246922234,"owners_count":20855343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-compose","dockerfile","flask","mysql","python","redis"],"created_at":"2024-12-15T21:16:11.930Z","updated_at":"2025-12-30T23:09:57.824Z","avatar_url":"https://github.com/SaraKhild.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Capstone Project Description\nThis Flask application serves as a simple web interface for adding users and viewing user details. Below is a brief description of the files and functionalities:\n\n- **app.py**: \n  - The main Flask application file.\n  - It integrates with **Redis** for caching and **MySQL** for persistent data storage.\n  - Provides routes for:\n    - The homepage (`/`) that renders a form to add new users.\n    - A `/add_user` route for submitting new users, which stores the data in both MySQL and Redis.\n    - A `/user/\u003cuser_id\u003e` route for fetching user information, first checking Redis (cache) and then falling back to MySQL if the data isn't found in the cache.\n  - It also contains a function to initialize the MySQL database table for users.\n\n- **requirements.txt**: \n  - This file lists the necessary Python packages for the Flask application.\n\n- **test_app.py**: \n  - Contains unit test to verify that the Flask application is working correctly.\n  - Tests the home page route (`/`) to ensure it returns a successful response.\n  - The test can be run using command: `python test_app.py`\n\n- **templates/index.html**: \n  - The homepage HTML template.\n  - Displays a form that allows users to input and submit a username.\n\n- **templates/user.html**: \n  - The user information HTML template.\n  - Displays the user’s ID, name, and the source (either Redis or MySQL) where the information was retrieved from.\n\nThis application demonstrates basic operations with integration between a relational database (MySQL) and an in-memory store (Redis) for faster data retrieval. Bellow is a screenshoot of the Homepage, I'll add a new user\n\nNotice that after visiting `/user/\u003cuser_id\u003e` the Source shows that data came from Redis\n\n\n### Now if I kill and re-run Redis Container the Source will show that data are fetched from MySQL:\n\n- Get Redis container id:\n```\n➜  capstone git:(main) ✗ docker ps\nCONTAINER ID   IMAGE                COMMAND                  CREATED         STATUS              PORTS                               NAMES\nf2d98ffdfc18   redis:latest         \"docker-entrypoint.s…\"   2 minutes ago   Up 2 minutes        0.0.0.0:6379-\u003e6379/tcp              capstone-redis-1\nc3511a9f6c4f   mysql:latest         \"docker-entrypoint.s…\"   2 minutes ago   Up 2 minutes        0.0.0.0:3306-\u003e3306/tcp, 33060/tcp   capstone-db-1\n2fee8a71e0fc   capstone-flask-app   \"python app.py\"          9 minutes ago   Up About a minute   0.0.0.0:80-\u003e5000/tcp                capstone-flask-app-1\n```\n\n\n- Kill Redis container:\n  \n```\n➜  capstone git:(main) ✗ docker kill f2d98ffdfc18\nf2d98ffdfc18\n```\n\n- Re-run Redis container:\n\n```\n➜  capstone git:(main) ✗ docker compose up redis\n[+] Running 1/0\n ⠿ Container capstone-redis-1  Created                                                                                                                            0.0s\nAttaching to capstone-redis-1\ncapstone-redis-1  | 1:C 22 Oct 2024 10:44:06.942 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo\ncapstone-redis-1  | 1:C 22 Oct 2024 10:44:06.942 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=1, just started\ncapstone-redis-1  | 1:C 22 Oct 2024 10:44:06.942 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf\ncapstone-redis-1  | 1:M 22 Oct 2024 10:44:06.943 * monotonic clock: POSIX clock_gettime\ncapstone-redis-1  | 1:M 22 Oct 2024 10:44:06.944 * Running mode=standalone, port=6379.\ncapstone-redis-1  | 1:M 22 Oct 2024 10:44:06.944 * Server initialized\ncapstone-redis-1  | 1:M 22 Oct 2024 10:44:06.944 * Ready to accept connections tcp\n```\n- Notince that Source changed to MySQL\n\n# Project Requirements:\n\n### Project Requirements\n\n#### 1. **Dockerfile for Flask Application**:\n   - A `Dockerfile` is required to containerize the Flask application.\n\n#### 2. **Docker Compose Configuration**:\n   - A `compose.yml` file should be created to handle the multi-service setup, which includes:\n     - **Flask Application**:\n       - The service should build the Flask application image using the `Dockerfile`.\n     - **Redis Service**:\n       - Use the official `redis` image.\n     - **MySQL Service**:\n       - Use the official `mysql` image.\n   - Environment Variables:\n       - Ensure that the Flask application can access Redis and MySQL using environment variables.\n    \n\n#### 3. **CI/CD Pipeline using GitHub Actions**: \n- Write a workflow that triggers on **Push** to test the app, build the Docker image, and push it to a public repository in your Docker Hub account. [TAKE A SCREENSHOT 01]\n- The same workflow should trigger on a **Pull Request** to the **main** branch to test the app. [TAKE A SCREENSHOT 02]\n\n\n- Write another workflow that triggers on **Push** to the **main** branch to pull the Docker image from your public repository and deploy it to the HTTP servers. [TAKE A SCREENSHOT 03]\n\n\n#### 4. **Infrastructure as Code Using Terraform**:\n   - Create another GitHub Repository and Write a Terraform file to create an infrastructure on Alibaba Cloud that meets the following requirements:\n     - **Redis Server**: Redis server in the private vSwitch which accepts connections from Http Servers.\n     - **MySQL Server**: MySQL server in the private vSwitch which accepts connections from Http Servers.\n     - **Http Servers**: a total of 2 Http servers in the private vSwitch.\n     - **Load Balancer**: a Network Load Balancer which distribute traffic to the http server group.\n     - **Runner Server**: a bastion/runner server which can be used to ssh to the servers in the private vSwitches. and can be used as a self-hosted runner later in the GitHub Actions Workflows.\n     - **Nat Gateway**: NatGatway server that allow servers in the private vSwitch to access the internet.\n     - **Outputs**: Outputs of neccessary values, such as: Load Balancer domain name, Bastion/Runner server public ip, Http servers private ip, MySQL server private ip and Redis server private ip.\n       \nThe following sketch demonstrates the infrastructure design:\n\n\n#### 5. Functional Application\n\n- Take a screenshot of a functional application accessed through the load balancer [TAKE A SCREENSHOT 04]\n\n#### 6. **Application Directory Structure**:\n\nThe final application directory files structure should be something similar to the following:\n```\n📦capstone\n ┣ 📂.github\n ┃ ┗ 📂workflows\n ┃ ┃ ┣ 📜cd.yml\n ┃ ┃ ┗ 📜ci.yml\n ┣ 📂templates\n ┃ ┣ 📜index.html\n ┃ ┗ 📜user.html\n ┣ 📜.gitignore\n ┣ 📜Dockerfile\n ┣ 📜compose.yml\n ┣ 📜app.py\n ┣ 📜test_app.py\n ┣ 📜requirements.txt\n ┣ 📂screenshots\n ┃ ┣ 📜SCREENSHOT01.PNG\n ┃ ┣ 📜SCREENSHOT02.PNG \n ┃ ┣ 📜SCREENSHOT03.PNG\n ┃ ┗ 📜SCREENSHOT04.PNG\n ┗ 📜README.md\n```\n\n#### 7. Submission\nTo complete your project submission, please provide the URLs for the following repositories:\n\n1. **Application Repository URL**: Contains all files related to the Flask application, such as `app.py`, `templates`, `Dockerfile`, and GitHub Actions workflows. It should also include all required screenshots in the `screenshots` folder as proof of the application’s functionality.\n\n2. **Infrastructure Repository URL**: Contains Terraform configuration files for setting up the infrastructure on Alibaba Cloud. This should include all necessary configuration files to provision the Redis, MySQL, and HTTP servers, along with the load balancer, NAT gateway, and any other components.\n\n\n### Bonus Section\nCreate an additional Terraform file to deploy the application on AWS Cloud.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarakhild%2Fcapstone-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsarakhild%2Fcapstone-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarakhild%2Fcapstone-project/lists"}