henry-wrightman / togggle_project

togggle's project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requirements

  • node v16.13.0
  • docker (technically not entirely needed; postgres can be ran locally, with the .env creds updated as such)

Run Everything

  1. via /backend, run docker-compose up to get postgres up & running through docker
  2. create a backend/.env and MinuteBets/.env. see .env.example for reference, or cp .env.example .env to create a local env file for both. If running postgres via Docker and the default ports, both should be accurate for local testing!
  3. configure db migrations by navigating to /backend and running yarn followed byyarn typeorm.
  4. from root dir: yarn start to run both applications! note: you may need to refresh the web-page once Nest is fully deployed, could take ~10 seconds

Tests

  1. via /backend, run yarn typeorm:test to prepare the testdb migrations for testing
  2. from root dir: yarn test to run all tests (or individually in each if desired)

MinuteBets

  • Through the web-app, one is able to select a desired "bet" for BTC's future price, judging from it's current price on whether or not it will be higher/lower in the next minute.
  • To select a bet, use the Select Dropdown. (UP: betting the price will be higher; DOWN: price being lower)
  • Then click "Place" to submit the bet
  • One is able to see their current score, number of past guesses, BTC's current price, and time until their current guess expires. When the guess does expire, the final results will be shown
  • User authentication/sessions are managed with basic uuids stored via cookies. Some of the technologies leveraged for the entire stack are listed below:

image

NestJS

  • Nest really brings finesse into building backends with typescript. The decorators are also very simple & keep things explicit, and it pairs nicely with Typeorm

TypeORM

  • Database model translations & fits very nicely with NestJS. Very simple to use query interface as well, and (personally) enjoy it's querybuilder over Sequelizer

i18n

  • Ease of global localization/translations

sass

  • Simplifies styling, and personally is my favorite for styling readibility inline with React

yarn

  • Faster then npm & has yarn workspaces

Additional Thoughts/Todos

  • consider sockets as they would likely improve any latency issues / the real-time experience for users (require paid APIs)
    • realtime price updates while the wager is active, especially for longer bets (e.g hourly)
  • improve UI test coverage (with invocations)
  • convert frontend to TS
  • consolidate backend entities/services into their own personal modules (vs. single, shared "database.service"). probably better for maintainability & decoupling

About

togggle's project

License:MIT License


Languages

Language:TypeScript 51.7%Language:JavaScript 44.0%Language:SCSS 3.3%Language:HTML 0.7%Language:Shell 0.3%