Skip to content

Dragon-Huang0403/thsr-auto-buy

Repository files navigation

THSR Auto Buy

Features

  • Implement both frontend and serverless backend for reserving booking ticket
  • Managing discounts and train searching
  • Auto calculate ticket start booking date
  • Update train discounts and special days everyday with cron-job
  • Booking Ticket at every exactly 00:00:00 and retry until 2 AM

Apps and Packages

Apps

  • web: Full-stack app for reserving ticket and searching trains with discounts
  • functions: Serverless backend for crawling and booking tickets with

Packages

  • crawler: crawling discounts and special days from thsr website
  • database: database models
  • taiwan-id: taiwanese id validator and generator
  • tdx-api: tdx api
  • ticket-flow: booking thsr ticket flow
  • eslint-config-custom: eslint configurations (includes eslint-config-next and eslint-config-prettier)
  • tsconfig: tsconfig.jsons used throughout the monorepo

Each package/app is 100% TypeScript.

Setup

Build

To build all apps and packages, run the following command:

pnpm run build

Develop

To develop frontend, run the following command:

pnpm run dev

Difficulties and Experience

  • Handled deploy firebase functions
    • Firebase not support monorepo
    • Prisma needed to set binaryTargets for running on Firebase functions
  • Handled booking ticket flow with cookies validation
  • Handled cleaning crawled data
  • Handled retry mechanism
  • Handled locale timezone (firebase cloud functions is run at utc+0 and frontend is utc+8)
  • Tried many free databases, finally choose PostgreSQL with Supabase due to:
    • Firebase firestore: it's not type safe enough and it is annoying to handle TimeStamp in firestore and convert it to Date
    • MySQL with PlanetScale: Planet doesn't support foreign keys
    • PostgreSQL with fly.io: it is a mistake..., it is not supported outside applications to connect

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published