{"id":20298389,"url":"https://github.com/dmytrovoytko/data-engineering-amazon-reviews","last_synced_at":"2025-07-31T02:14:09.413Z","repository":{"id":233800871,"uuid":"787829373","full_name":"dmytrovoytko/data-engineering-amazon-reviews","owner":"dmytrovoytko","description":"Data Engineering project for ZoomCamp`24: JSONL -\u003e PostgreSQL/BigQuery + Metabase + Mage.AI","archived":false,"fork":false,"pushed_at":"2024-05-05T21:11:28.000Z","size":1434,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T13:22:12.367Z","etag":null,"topics":["bash-script","bigquery","codespaces","data-analysis","data-visualization","etl","metabase","pipeline","python-script"],"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/dmytrovoytko.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,"zenodo":null}},"created_at":"2024-04-17T09:04:11.000Z","updated_at":"2024-11-22T04:36:28.000Z","dependencies_parsed_at":"2024-04-17T11:22:04.420Z","dependency_job_id":"c8368f01-ad98-40ee-8481-a0a7082dfe03","html_url":"https://github.com/dmytrovoytko/data-engineering-amazon-reviews","commit_stats":null,"previous_names":["dmytrovoytko/data-engineering-amazon-reviews"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dmytrovoytko/data-engineering-amazon-reviews","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrovoytko%2Fdata-engineering-amazon-reviews","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrovoytko%2Fdata-engineering-amazon-reviews/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrovoytko%2Fdata-engineering-amazon-reviews/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrovoytko%2Fdata-engineering-amazon-reviews/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmytrovoytko","download_url":"https://codeload.github.com/dmytrovoytko/data-engineering-amazon-reviews/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmytrovoytko%2Fdata-engineering-amazon-reviews/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267977557,"owners_count":24175184,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bash-script","bigquery","codespaces","data-analysis","data-visualization","etl","metabase","pipeline","python-script"],"created_at":"2024-11-14T16:09:25.360Z","updated_at":"2025-07-31T02:14:09.394Z","avatar_url":"https://github.com/dmytrovoytko.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Engineering project Amazon Reviews\n\nData Engineering project for ZoomCamp`24: JSONL -\u003e PostgreSQL + Metabase + Mage.AI\n\nETL for [Amazon Reviews'23` dataset](https://amazon-reviews-2023.github.io/).\n\n![Data Engineering project Amazon Reviews](/screenshots/amazon-reviews-data-engineering.png)\n\n‼️New [branch](https://github.com/dmytrovoytko/data-engineering-amazon-reviews/tree/feature/ingest-bigquery) with export to BigQuery (in progress, export works only via scripts, no Mage yet, stay tuned!)\n\nCloud environment: **GitHub CodeSpaces**, free and enough to test (120 core-hours of Codespaces compute for free monthly, 15GB of Codespaces storage for free monthly). \n\nTo reproduce and review this project it would be enough (hopefully) less than hour, and ~8GB total for described datasets. You don't need to use anything extra, like VS Code or trial accounts - just webrowser + GitHub account is totally enough.\n\nThis level of cloud resources allowed me to process and analyze-visualize datasets with at least 6 Mln reviews without issues.\n\n## 🎯 Goals\n\nThis is my Data Engineering project started during [DE ZoomCamp](https://github.com/DataTalksClub/data-engineering-zoomcamp)'24.\nAnd **the main goal** is straight-forward: **Extract - Transform - Load** data, then **visualize** some insights.  \n\nI chose to analyze [Amazon Reviews](https://amazon-reviews-2023.github.io/) dataset. Full dataset is huge, and it is available to download in parts - by product categories. There are some smaller and larger sub-datasets, some of them we would explore here (Digital_Music, Health_and_Personal_Care, All_Beauty, Software). Each subset includes 2 files: products (**meta**), ratings and user comments (**reviews**).\n\nSome time ago I became very interested in how much we can trust all those ratings on Amazon, including 'bestseller' statuses. But without proper data it was hard to investigate. Now, years later, I have more skills in data analytics and this huge dataset, thanks to [McAuley Lab](https://cseweb.ucsd.edu/~jmcauley/). I chose to use only part of the whole information: \n- **Products**: categories and average ratings \n- **Reviews**: user's ratings, review dates, was that verified purchase or not \n  (will analyze reviews texts later, awesome source for many insights I think)\n\nThanks to ZoomCamp for the reason to learn many new tools and get back to my 'reviews \u0026 trust' questions!\n\n### 🕵️ Questions that I chose to investigate during this project:\n\n- What are the trends in reviews ratings for verified/not purchases? Are they more negative or more positive than average?\n- As not verified purchase reviews can be manipulative, what is their ratio in total number?\n- As automated review submission is technically possible with more advanced tech last years, what are the not verified purchase rating trends over time?\n- Are there any significant differences in trends for product categories?\n\nLet's explore together! These categories (datasets) I played with so far.\n\n![Reviews by Main category](/screenshots/pie-chart-reviews-by-main-category.png)\n\n## ℹ️ Assets\n\n- dataset urls are defined in .csv files stored in `/data` - `dataset_urls0.csv`, `dataset_urls1.csv`, etc\n- my scripts (bash, python, sql)\n- pre-configured Metabase dashboard\n- pre-configured Mage AI pipelines \n\n## :toolbox: Tech stack\n\n- Docker and docker-compose. All dockerized apps use default bridge network (172.17.0.x). \n- PostgreSQL as a data base/warehouse - open source and free\n- [Metabase](https://www.metabase.com/) as an analitics platform - open source and free self-hosted\n- [Mage AI](https://www.mage.ai/) as an orchestration tool - open source and free self-hosted\n\n💡 Combination of CodeSpaces + PostgreSQL + Metabase + Mage AI would be a good choice for those who prefer/experiment with a simple and open source approach, or those who hesitate to deal with The BIG 3 cloud providers (AWS, Azure, GCP) with their serious payments. Looks like a good fit for early stage startups, developers, and those who learn Data Engineering as me (you?). ❕Find one more open source and free opportunity at the end of this instructiom.\n\n## 🚀 Instructions to deploy\n\n🙈 Oh, so many steps?! Please take a deep breath to calm down, they are all simple enough, that's why so many. One step at a time. I did it successfully many times to test it, you can do it too! **Let's go!**\n\nNB: and if you 'lost the track', you can always start from scratch - create new CodeSpace and go step by step. Good luck!\n\n- [Setup environment](#hammer_and_wrench-setup-environment)\n- [Download dataset and start PostgreSQL server](#arrow_heading_down-download-dataset-and-start-postgresql-server)\n- [Ingest data using CLI (bash \u0026 python)](#keyboard-ingest-data-using-cli-bash--python)\n- [Visualize data](#-visualize-data)\n- [Orchestration data ingestion (Mage AI)](#mage-orchestrate-data-ingestion-mage-ai)\n- [Instructions to stop the apps](#stop_button-instructions-to-stop-the-apps)\n\n### :hammer_and_wrench: Setup environment\n\n1. Fork this repo on GitHub.\n2. Create GitHub CodeSpace from the repo.\n3. **Start CodeSpace**, wait for `requirements.txt` installation to finish (it starts automatically, just watch \u0026 wait).\n4. Copy `dev.env` to `.env` - run `cp dev.env .env` in your CodeSpace terminal. You don't need to change anything to test the process. It contains **all key settings** (PostgreSQL etc).\n```bash\ncp dev.env .env\n```\n\n### :arrow_heading_down: Download dataset and start PostgreSQL server\n\n5. Run `bash download.sh` to download 1st dataset (smallest) - from `dataset_urls0.csv`. As a result you will have 2 files in your `data` directory: `meta_Digital_Music.jsonl.gz` and `meta_Digital_Music.jsonl.gz`. Cool! ✅\n```bash\nbash download.sh\n```\n6. Start PostgreSQL docker: `bash start_postgres.sh`. It will automatically download postgres container and start it.\n```bash\nbash start_postgres.sh\n```\n7. Wait until you see the message `database system is ready to accept connections` - PostgreSQL is ready to serve you. \n\n![PostgreSQL is ready](/screenshots/postgresql-is-ready.png)\n\nLet it run in this terminal so you can see logs and easily stop it later (with just Ctrl-C). CodeSpace will pop-up the notification that `Your application running on port 5432 is available.` - just ignore it (close that pop-up).\n\n8. Start 2nd terminal (click `+` button on the panel in the right corner above terminal) and switch to it. \n9. You can check database connection by running `pgcli -h 172.17.0.2 -p 5432 -u postg -d amzn_reviews`, password `postg`. All dockerized apps of this setup are suppose to run in default `bridge` network, `172.17.0.x`, with `172.17.0.2` for PostgreSQL. If this step fails you're in trouble 😅 But, when you run it in a CodeSpace and follow the instruction it should work fine, I tested multiple times. Type `quit` to return to terminal CLI. Ok, PostgreSQL is running. ✅\n```bash\npgcli -h 172.17.0.2 -p 5432 -u postg -d amzn_reviews\n```\n\n### :keyboard: Ingest data using CLI (bash \u0026 python)\n\nDataset files have been downloaded, PostgreSQL is running - time to ingest your data!\n\n10. Run `bash process.sh` to ingest dataset files into PostgreSQL database. \n```bash\nbash process.sh\n```\nIt executes python script `process_jsonl.py` with default parameters from your `.env` settings. By default (without parameter) it processes the 1st dataset files. As the result of successful loading you will see some progress messages and finally `Finished ingesting data/... into the PostgreSQL database! Total time ... second(s) +++ PROCESSING finished: OK!`. \n\n![Processing successful](/screenshots/processing-successful.png)\n\nCongratulations, the first approach to load data accomplished and you have records in 2 tables of your database: `meta` with products, `reviews` with ratings. ✅ \n\n11. Now you can ingest the next dataset with the same approach: \n- download 2nd dataset: run `bash download.sh dataset_urls1.csv` (Health_and_Personal_Care files)\n```bash\nbash download.sh dataset_urls1.csv\n```\n- process 2nd dataset: run `bash process.sh dataset_urls1.csv` \n```bash\nbash process.sh dataset_urls1.csv\n```\n- download 3rd dataset: run `bash download.sh dataset_urls2.csv` (All_Beauty files)\n```bash\nbash download.sh dataset_urls2.csv\n```\n\nIf you want to try data workflow orchestration have some patience and follow to [Visualize data](#-visualize-data) step. If you don't want (or have no time) to play with Mage.AI, just process similarly `dataset_urls2.csv` for All_Beauty, and download then process `dataset_urls3.csv` for Software.\n\n### 📊 Visualize data\n\nFinally, probably the most interesting part, let's see our data using Metabase - open sourse and free self-hosted Business Intelligence, Dashboards and Data Visualization tool. \n\n![Reviews by Verified purchase](/screenshots/reviews-by-verified-purchase-monthly.png)\n\n12. Start it in Docker - run \n```bash\nbash start_metabase.sh\n```\nIt will automatically download Metabase container and start it.\n\n13. CodeSpace will pop-up the notification that `Your application running on port 3000 is available.` - click `Open in Browser`. \n\n![Metabase app pop-up](/screenshots/metabase-app-pop-up.png)\n\nNew page would probably open white. Please wait a couple of seconds to let it start, then refresh the page. Now you will see login screen. Just login with `john@mailinator.com`, pass: `Jj123456` (no worries, it's self-hosted, all safe). Pre-configured dashboard with reports is already there for you! ✅🎉\n\n💡 In case you accidentally close that pop-up or Metabase page and you need it later (after ingesting new datasets), you can always open that page from `Ports` tab:\n\n![Metabase app Ports](/screenshots/metabase-app-ports.png)\n\n14. Explore the dashboard on the main screen. There are 2 tabs: `Products` and `Reviews`.\n15. **Products**: you can see 2 reports:\n- pie chart with number of Products by Main category\n- Products number distribution by Average rating \n16. **Reviews**: you can see 4 reports:\n- pie chart with Reviews number by Verified/not purchase\n- Reviews rating number distribution by Verified/not purchase over time (by months)  \n- pie chart with Reviews number by Main category\n- Reviews rating number distribution by Main category over time (by months) \n\nYou can see some [screenshots](/screenshots) below.\n\n17. The more datasets you load, the more categories you can see. That's why I offer you to download and process at least 2 datasets. You can process 3rd dataset by following familiar steps in [Ingest data using CLI (bash \u0026 python)](#keyboard-ingest-data-using-cli-bash--python) or go ahead and discover [Mage AI](#mage-orchestrate-data-ingestion-mage-ai).\n\n### :mage: Orchestrate data ingestion (Mage AI)\n\nI wouldn't say it was so simple and easy as Matt showed us in videos, but with some time and effort I managed to find the way to convert the logic of my `process_jsonl.py` script into `Mage` pipelines and bricks. Why is it worth my/your time? Because larger datasets (like Kindle_Store) will probably demand a serious cloud storage, database and compute than free CodeSpace playground. And I (you?) need to learn how to deal with them with a more scalable system, providing long job execution, partitioning, monitoring and logs. So let's see 2 pipelines I managed to setup with Mage. \n\n💡 In case something goes wrong or complicated, you can still ingest more datasets with step 11 [Ingest data using CLI (bash \u0026 python)](#keyboard-ingest-data-using-cli-bash--python) and then reload Metabase dashboard page.\n\n18. Run `unzip mage.zip` to extract pre-configured Mage AI workflow.\n```bash\nunzip mage.zip\n```\n19. Run `docker-compose build` to automatically download and prepare Docker container with Mage AI.\n```bash\ndocker-compose build\n```\n20. Run `docker-compose up` to start Docker container with Mage AI.\n```bash\ndocker-compose up\n```\n21. CodeSpace will pop-up the notification that `Your application running on port 6789 is available.` - click `Open in Browser`.\n\n![Open Mage AI page](/screenshots/open-mage-ai-page.png)\n\nThat new page would probably open white. Please wait a couple of seconds to let Mage AI start, then refresh the page. Now you will see Mage dashboard. Your orchestration center is ready to serve you! ✅\n\n22. Go to `Pipelines` - move mouse to the left edge of the window, it will open menu slider, click on `Pipelines`.\n\n![Open Mage AI pipelines](/screenshots/mage-pipelines.png)\n\nYou will see 2 pipelines I configured: \n\n![Mage AI pipelines list](/screenshots/mage-pipelines-list.png)\n\n23. Click `load_run_dataset`. It will open current pipeline triggers. Then click `Run@once` button.\n\n![Mage AI pipeline trigger](/screenshots/mage-run-pipeline-trigger.png)\n\n24. In the `Run pipeline now` dialogue you can define a variable, in this case it will be the file name of dataset.  \n\n![Mage AI pipeline run variable](/screenshots/mage-run-pipeline-variable.png)\n\nEnter `dataset_urls2.csv` (that you downloaded but not processed yet) and click `Run now` button. Ingestion process started. You can see the progress on `Pipeline runs` page. It appears with a little delay, no worries.\n\n![Mage AI pipeline run progress](/screenshots/mage-ai-pipeline-runs-running.png)\n\n25. After ingesting new dataset you can switch to Metabase page, update it and see new data in the dashboard reports. Congratulations! ✅🎉\n\n![Metabase dashboard products](/screenshots/metabase-dashboard-products.png)\n\n![Metabase dashboard reviews by verified monthly](/screenshots/reviews-by-verified-purchase-monthly.png)\n\n![Metabase dashboard reviews by category monthly](/screenshots/reviews-by-main-category-monthly.png)\n\n26. If you get to this point, please ⭐️star⭐️ my repo! 🙌\n\n## :gift: One more open source opportunity\n\nBonus for those who survived reading instructions! \n\nIn addition to using PostgreSQL in docker (local on your computer or as described in GitHub CodeSpace) you can use/experiment with Supabase - an open source Firebase alternative.\n\nIt provides a quite generous free plan (not a trial, no credit card required): 500 MB database space, 2 Core shared CPU, 1GB RAM, 5 GB bandwidth, 1 GB file storage. Free projects are paused after 1 week of inactivity. Limit of 2 active projects.\n\nI tested it, it works with my scripts, and with Metabase as well. You just need to: \n- register free account \n- get access credentials (host, port, user, password, database)\n- put new values to `.env` file \n- create in Supabase 2 tables - `meta` and `reviews`, then define structure (according to my python script)\n- and finally use my `process.sh` (or Mage AI pipelines) to ingest data there\n- Metabase works with Supabase as with any PostgreSQL database - create dashboard for your new database.\n  \nLet me [know](/issues) how it worked for you!  \n\n## :stop_button: Instructions to stop the apps\n\n- Simple way - stop all together by stopping your CodeSpace. Remember, this will leave all downloaded data in your CodeSpace - you can start it later and continue playing with tools and data. You can also delete CodeSpace with all the data.\n- Stop all active Docker containers - run this command in terminal\n```bash\ndocker stop $(docker ps -a -q)\n```\n* Stop Mage AI \n\t- switch to 2nd terminal and press `Ctrl-C`\n\t- then run `docker-compose down` in terminal\n* Stop PostgreSQL - switch to 1st terminal and press `Ctrl-C`\n* You can delete downloaded dataset .jsonl.gz files from `/data` folder. \n\n## Roadmap\n\n- [x] Refactor python code\n- [x] Export to .parquet\n- [x] Export to **BigQuery**\n- [/] **BigQuery**: update Mage orchestration, visualization and instructions \n- [/] Load more data to analyze `Kindle Store` dataset\n- [ ] Visualize using **Apache Superset** (as an alternative to Metabase)\n- [ ] Visualize using **Looker Studio**\n- [ ] Orchestrate with **Prefect** (as an alternative to Mage)\n- [ ] Orchestrate with **Apache Airflow** (as an alternative to Mage)\n\nStay tuned!\n\n## Support\n\n🙏 Thank you for your attention and time!\n\n- If you experience any issue while following this instruction (or something left unclear), please add it to [Issues](/issues), I'll be glad to help/fix. And your feedback, questions \u0026 suggestions are welcome as well!\n- Feel free to fork and submit pull requests.\n\nIf you find this project helpful, please ⭐️star⭐️ my repo https://github.com/dmytrovoytko/data-engineering-amazon-reviews to help other people discover it 🙏\n\nMade with ❤️ in Ukraine 🇺🇦 Dmytro Voytko","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmytrovoytko%2Fdata-engineering-amazon-reviews","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmytrovoytko%2Fdata-engineering-amazon-reviews","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmytrovoytko%2Fdata-engineering-amazon-reviews/lists"}