Table of Contents
Note: This project has been taken offline as it was only live for demonstration purposes.
This project is a SvelteKit MongoDB WebApp that aggregates the latest popular PC parts and prices from popular Malaysian E-Commerce sites for users to configure and create their own PC parts lists. If you've heard of PCPartPicker, it's very similar to that though on a hobby scale.
Note: This is just one of multiple repositories that contribute to the PCPartsTool project. Here are all the related repositories:
Repository | Built With | Description |
---|---|---|
PCPartsTool | SvelteKit, TypeScript, Tailwind CSS, MongoDB, Jenkins, Docker, Playwright | The SvelteKit MongoDB WebApp |
PCPartsTool-Scraper | JavaScript, Jenkins, Docker | Scraping Script to Gather E-commerce Item Data |
terraform-infra | Terraform, Cloudflare, AWS | Terraform IaC for PCPartsTool Cloud Infrastructure |
ansible-ec2 | Ansible, Prometheus, Grafana, Nginx, AWS | Ansible CaC for AWS EC2 Bootstraping, Observability and Maintenance |
- Authentication
- Savings Parts Lists to Account
- Sharing Parts Lists through Unique URLs
- Learning Centre for PC Parts
There are some prerequisites before you can start working on this project:
Consult their official websites for advice on how to install them on your system.
This installation guide walks you through how to completely mimic my setup for development and deployment.
-
Fork this repo.
-
In your desired project folder, run the following command in your terminal:
git clone https://github.com/yourUsername/PCPartsTool
-
Add a
.env
file to the root directory of your project. You may refer to.env.example
. It's for the app to point to the desired database. -
Ensure
pnpm
is installed globally on your dev system. If not, run the following command in your terminal:npm i -g pnpm
-
Finally, install all dependencies:
pnpm i
Before you can develop, you'll need to get a Dockerized MongoDB instance running. Run the following command in your terminal:
sudo docker run -p 4600:27017 -v /your/database/path/here/:/data/db --name mongodb -d mongo
where the -v flag specifies the path of your MongoDB on your host system. Place the backup files here if you have one.
If you need data for MongoDB, use PCPartsTool-Scraper - refer to its README.
To start a development server:
pnpm dev
PCPartsTools uses Playwright as its E2E testing framework.
Tests are configured to run on port 4173
, the port that pnpm preview
uses.
To run tests:
pnpm test # you will need to have a preview server running
# run tests without having to start up a preview server
pnpm test:ci
# show test results
pnpm test-report
To compile the app, run the following:
pnpm build
# you can preview the production build
pnpm preview
To create a Docker container, you may use the included Dockerfile:
sudo docker build -t PCPartsTool .
This section talks about deploying the Dockerised app to a domain using Jenkins CI/CD and Ansible.
Since my infrastructure has two servers (a build server and a web server), the included Jenkinsfile, Docker Compose files and Ansible Playbooks are catered towards that. As such, these instructions are catered towards my infrastructure.
If other repositories are mentioned, refer to their READMEs on how to set up and use them.
- Provision AWS and Cloudflare resources using terraform-infra's
.tf
files. - Configure AWS EC2 servers using ansible-ec2's Playbooks.
- Modify
ansible/inventory
's target web server to the IP address of your own web server. - Setup a GitHub Webhook on your forked repository to point to your Jenkins instance.
- Add a new Jenkins Pipeline job and point it to your forked repo with the following enabled:
- Do not allow concurrent builds
- GITScm polling
- Pipeline Script from SCM
- Repository URL should be whatever your forked repository's URL is
- Branches to build:
*/main
- Additional Behaviours:
- Polling ignores commits in certain paths:
README.md
in Excluded regions
- Polling ignores commits in certain paths:
If all was configured well, a new Docker Compose build should automatically be deployed from your CICD build server to your Web server after each push or merge to the main
branch.
This section details how to locally deploy the Docker Compose on your own dev machine.
- First, you will need to Dockerize and create and image for the PCPartsTool-Scraper. Refer to its README for instructions.
- Ensure the PCPartsTool-Scraper image is locally stored in your Docker Engine - you can verify with the
docker images
command. - Run the build command to compile the source code, as detailed in the Building section.
- Run the following command in the root directory of this project:
What this command does is instruct
docker compose -f docker-compose.local.yml up -d --build
docker compose
to use thedocker-compose.local.yml
file and simultaneously build the PCPartsTool app before composing and starting the MongoDB container, PCPartsTool-Scraper and PCPartsTool web app itself.