Coder Social home page Coder Social logo

company-app's Introduction

Company App

Simple implementation of a programming challenge in which companies have many employees. Both companies and employees have a similar but slightly different unique token. Try it out on Heroku.

Requirements

This application requires:

  • Ruby 2.5.0
  • Postgres 9.x+

Getting Started

  1. Install the dependencies: bundle install
  2. Create the development and test databases: bin/rails db:create db:migrate db:test:prepare
  3. Run the specs to confirm everything is working: bundle exec rspec
  4. Start the web server: bin/rails server
  5. Point your browser to http://localhost:3000

Notes

I created a large chunk of the code with the following three commands:

  1. rails new company-app --skip-action-cable --skip-turbolinks --skip-coffee --skip-spring -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
  2. bin/rails g scaffold company name:string --no-routing-specs --no-helper-specs --no-view-specs
  3. bin/rails g nested_scaffold company/employee first_name:string last_name:string --no-routing-specs --no-helper-specs --no-view-specs

I chose to use scaffolds in this app, because the "main part" of the app is the token generation and not the UI.

Since this is a small app, I chose to implement the token generation as a mixin which uses ActiveRecord callbacks on the model. This is probably the simplest solution. If the project was larger, then I would recommend encapsulating the company/employee creation in service objects that call the token generator explicitly (i.e. instead of via callbacks). If the project would use CQRS and event sourcing (i.e. persist the events instead of just the latest state), then I would implement it asynchronously as a process manager.

This is not a production ready app. At least the following things are missing:

  • Use rubocop to enforce a common style guide
  • Everything must be localized
  • Consider using client side rendering (e.g. https://reactjs.org/) + server side API instead of server side rendering
  • Use UUIDs instead of integers for ids (especially if they are going to be exposed by an API)
  • Use foreman for starting the web server (and other processes)
  • Always soft-delete instead of hard-delete on destroy action
  • Paginate all results in views
  • Add request specs if the backend implements an API
  • Use namespaces for all modules/classes
  • Exception logging
  • Performance monitoring

company-app's People

Watchers

James Cloos avatar

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.