Skip to content

Instantly share code, notes, and snippets.

@ericso
Last active January 28, 2019 17:24
Show Gist options
  • Save ericso/9aa48eefd2e31e7456bf2b24d6bc52f4 to your computer and use it in GitHub Desktop.
Save ericso/9aa48eefd2e31e7456bf2b24d6bc52f4 to your computer and use it in GitHub Desktop.
Haus Homework Assignment

I decided to break the work into two git repositories: a frontend and a backend repo.

Backend:

https://github.com/ericso/haus-backend

Deployed at: https://es-haus-backend.herokuapp.com/

There is no root resolver for the backend.

Frontend:

https://github.com/ericso/haus-frontend

Deployed at: https://es-haus-frontend.herokuapp.com/

The frontend app is functional to the specifics of the homework.

Discussion

I decided to do two different repositories because it's how I've organized my projects in the past. I've also found the tooling to get both nodejs/express backend and a React frontend app running in the same codebase troublesome.

You can create a new user account, submit feedback, and logout by reloading the page. The login persists via a token set on a cookie. As long as the cookie is set, and the token hasn't expired, the user is logged in. Reloading the page removes the cookie.

Mongodb was chosen for the datastore for no particular reason other than it was the simplest to bootstrap. I would not use Mongodb in production, as it's relational mechanisms are weird. For example, a users feedback entities are read from an array of IDs that must be manually pushed onto the array. If we were to delete an entity, we'd have to manually remove that id from the array. We wouldn't get that for free. I'd feel much more comfortable implementing a SQL database for our datastore here.

It is also not easy to swap out the datastores, as the models are specific to Mongo, and the Controller code is not modular either. If I were to rewrite this, I would probably design a datastore interface and build the controllers to talk to that interface. Then in the future we'd write a datastore layer with that interface.

Caching is also a consideration for further development. The app makes a lot of GET requests; one every time a Feedback request is posted. Some system of fetching the feedback and storing locally could be done. On a POST request to create a new Feedback record, we could just appendend the feedback object to the local store instead of requesting it each time.

The frontend could also use a lot of love. Other than the glaring omission of CSS, there's no logout button. The user is also logged out on page reload.

That's an overview of the app. You can visit the running app at https://es-haus-frontend.herokuapp.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment