{"id":13631599,"url":"https://github.com/CT83/The-Overly-Complicated-Random-Number-Generator","last_synced_at":"2025-04-17T22:31:15.178Z","repository":{"id":39095943,"uuid":"254286293","full_name":"CT83/The-Overly-Complicated-Random-Number-Generator","owner":"CT83","description":"An  Overly Complex Random Number Generator, created to demystify how containers work.","archived":false,"fork":false,"pushed_at":"2023-01-05T21:37:25.000Z","size":1989,"stargazers_count":24,"open_issues_count":24,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T10:17:14.576Z","etag":null,"topics":["devops","devops-implementation","docker","docker-compose","docker-compose-template","example-app","example-project","javascript","nginx","python","react","redis","redis-client","redis-server","tutorial","tutorial-code"],"latest_commit_sha":null,"homepage":"https://dev.to/rohansawant/i-built-an-overly-complex-random-number-generator-with-docker-compose-3c0h","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/CT83.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}},"created_at":"2020-04-09T06:09:53.000Z","updated_at":"2023-07-11T23:05:08.000Z","dependencies_parsed_at":"2023-02-04T16:45:40.355Z","dependency_job_id":null,"html_url":"https://github.com/CT83/The-Overly-Complicated-Random-Number-Generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CT83%2FThe-Overly-Complicated-Random-Number-Generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CT83%2FThe-Overly-Complicated-Random-Number-Generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CT83%2FThe-Overly-Complicated-Random-Number-Generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CT83%2FThe-Overly-Complicated-Random-Number-Generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CT83","download_url":"https://codeload.github.com/CT83/The-Overly-Complicated-Random-Number-Generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223768523,"owners_count":17199356,"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":["devops","devops-implementation","docker","docker-compose","docker-compose-template","example-app","example-project","javascript","nginx","python","react","redis","redis-client","redis-server","tutorial","tutorial-code"],"created_at":"2024-08-01T22:02:31.287Z","updated_at":"2024-11-08T23:31:04.637Z","avatar_url":"https://github.com/CT83.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# The-Overly-Complicated-Random-Number-Generator\n[![Build Status](https://travis-ci.org/CT83/The-Complicated-Simple-Container-App.svg?branch=master)](https://travis-ci.org/CT83/The-Complicated-Simple-Container-App)\n\nThis is an Overly Complex Random Number Generator, created to demystify how containers work. \n\n## How to Run?\n\nEasy peasy lemon squeezy. 🍋💦\n\n1. `docker-compose up --build`\n\n2. Visit `localhost`\n\n\u003e  Below is an excerpt from my Blog Post about this.\n\n## Demo\n\n1. User sets a Random Seed\n2. Clicks Generate a Random Number\n3. Random Number is generated\n\n![](./images/demo.gif)\n\n\n\n### Prerequisites\n\n* You have an understanding of Docker and Docker Compose\n* You have heard about Python, React and Redis\n\n### Aim \n\n* To illustrate how containerization actually looks in the wild\n* We will be skipping how the actual Python, JavaScript Apps work, as we want to focus on containerization here, you can find all of the code on [Github - CT83/The-Complicated-Simple-Container-App](https://github.com/CT83/The-Complicated-Simple-Container-App)\n\n\n\n## Architecture\n\n![](./images/arch.jpg)\n\n1. Nginx Proxy - Exposed on port 80, Manages networking\n2. React Dev Server - Accepts Input, Supports Live Reloading, Replaced with Nginx in Production\n3. Flask Server - Serves the API\n4. Redis Cache - To maintain the Task Queue\n5. Python Worker - Uses specified Seed to Generate Random Number, stores it in DB\n6. Database - PostGreSQL DB to store generated random numbers\n\n## Working\n\n1. React App is served, user inputs the random seed.\n2. Seed is sent to the Flask API through a POST\n3. Task is added to Queue\n4. Worker picks up the task, generates a random number and store result in the database\n5. Result is returned to the user.\n\n## Configuration\n\nHere, is the minified [docker-compose-prod.yml](https://github.com/CT83/The-Complicated-Simple-Container-App/blob/master/docker-compose-prod.yml)\n\n```yaml\nversion: \"3.3\"\n\nservices:\n  proxy:\n    container_name: proxy\n    build: \n      ...\n    ports:\n      - 80:80\n\n  database:\n    container_name: database\n    build: database/.\n    volumes:\n      - ./database/db_data:/var/lib/postgresql\n    ...\n\n  client:\n    container_name: client\n    build: \n      ...\n    environment:\n      ...\n\n  api:\n    container_name: api\n    build: \n    ...\n    volumes:\n      - ./api:/app\n\n  worker:\n    container_name: worker\n    build:\n    ...\n\n  redis:\n    container_name: redis\n    build: \n    ...\n```\n\nYou can find the development [docker-compose.yml here](https://github.com/CT83/The-Complicated-Simple-Container-App/blob/master/docker-compose.yml). It even supports Live Reloading for both, the Flask and React Container!\n\n## Next Steps\n\nYou could now move on to trying to push the built images to DockerHub, or add TravisCI integration!\n\n## Inspirations\n\n[Stephen Grider](https://twitter.com/ste_grider) in his Udemy Course [Docker and Kubernetes: The Complete Guide](https://www.udemy.com/course/docker-and-kubernetes-the-complete-guide/) built an overly complex simple app, that greatly inspired me.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCT83%2FThe-Overly-Complicated-Random-Number-Generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCT83%2FThe-Overly-Complicated-Random-Number-Generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCT83%2FThe-Overly-Complicated-Random-Number-Generator/lists"}