Coder Social home page Coder Social logo

mbta-departure-board's Introduction

MBTA Departure Board

GitHub branch checks state

Shows live MBTA departure information about a given train station

screenshot

Install / Usage

To install:

npm install

To start:

npm run start

To run tests:

npm run test

Description

This React app uses the MBTA JSON API to fetch the current departures of commuter rail stations, including live predictions if the train is on time and what platform it is leaving from (if available).

Project setup

  • Create React App for bootstrapping React. This was straight forward for this, I don't need a more complex framework like next.js

  • prettier to format code reliably. I have configured my VSCode to automatically format on save.

  • eslint as a linter with some additional configuration for prettier and import ordering.

  • vercel for deployment. This is an easy setup and allows the app to be deployed automatically after every push.

  • renovate dependency bot. This regularly updates all NPM dependencies automatically, which makes maintenance easy.

Libraries

  • devour-client to consume the MBTA API. Although this is a JS library and doesn't have TypeScript types, it's enough to deserialize the JSON API, which is all I need.

  • mui (Material UI for react) as a component library. I just wanted to use some UI components like Inputs and cards to get started quickly.

  • emotion for CSS styling. I wanted to try out the "CSS-in-JS" with "styled components" approach, which I've never done before. I'm not sure I'm convinced, it makes the components longer and harder to read, but I'd need to see it in a bigger and more complex project.

  • date-fns for date parsing and formatting, as a more light-weight alternative to moment.js

Next Steps / Possible Improvements

  • Update the departure board automatically. The MBTA API supports streaming, which could be uses to fetch updates to current predictions. I'm not sure how well that would work with devour-client. As an alternative, I would probably start using a minimal state library like zustand and fetch data from the API every few seconds

  • More detailed information about departures. The API has much more information, like GPS coordinates of stations or specific vehicle information, which could be used to show more details about a specific departure.

  • Use an API token. Right now we're just accessing the API without a token, which is enough for these few requests. It would be easy to get an API token, but since this is an SPA, it would be hard to keep that token secure.

  • E2E testing. I would use Cypress for that, which I've had pretty good experiences with.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.