Getting started with React.Js using NPM

My assumptions: You have prior experience of Web framework like 
  Ruby on Rails, Django, Phoenix, etc. 
Please refer to this React.js style guide for community comprehensible source code.

Hey, its not mandatory to use NPM to build applications with ReactJs; but, it will be alot easier to build, maintain, share codes using NPM. Firstly you should have NodeJs installed in your development machine.

Installation for Development Environment

$ sudo apt-get install nodejs
# try 
$ node -v
# v4.2.6
# if its says command not found: node then try 
$ nodejs
# If it shows up, it means due no some name conflicts 
# the name/command node is already taken by some binary. 
# So, its get it back.
$ sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

Probable Issues: NPM not found

Continue reading

Advertisements

Developer’s checklist: Production deployment

One has to be very careful for shipping new changes/features to the production server.

When feature is said to be done

Assumption: Proper development processes have been followed

  1. Smoke Test in local machine
  2. Production Database backups
    • Generate snapshots or database-dumps
    • Store the backups in safe places
    • In case of Heroku, you will be provided with backup-tools
  3. Codebase versioning in Github / Diffusion
    • Create tags with proper naming conventions followed
    • eg V 0.1.1 or V 1.0.0 pre
  4. Deployment to production
    • Deploy the changes to the server
    • Make sure you run rake db:migrate is any migration pending
  5. Do data migrations if required
    • Already existing Production data might not co-op with your new code changes
      • reasons: there might be some data-fields manipulations or
        • new cols might have been added and data need to be filled in; data to be gathered from existing fields
    • Document the migration code you wrote for data-migrations [remember I am not taking about schema migrations]
    • eg
TransactionHistory.recurring_rewards.each do |tx|
   charge = Stripe::Charge.retrieve(tx.charge_id)
   invoice = Stripe::Invoice.retrieve(charge.invoice)
   subscription_id = invoice.subscription
   metadata = tx.transaction_additional_detail.metadata
   tx.transaction_additional_detail.update metadata: metadata.deep_merge(
                                           {
                                               subscription_id: subscription_id,
                                               invoice_id: invoice.id
                                           })
end
  1. Smoke test in production

Tips : for developers working in complex projects with extensive features

Export database when you have optimum data in database to use all the features

  • In my project I have different users with different roles; like recruiters, managers, supervisor, customer super admin and above all the ‘Super Admin’
  • They work on entities like ‘jobs’, ‘Applicants’, ‘Leads’, ‘Organization/user/locations/performances’ (only admins)
  • The flow is like,
    • Super Admin creates Organization and CSA
    • CSA creates
      • Locations
      • Users with different¬†roles and assigns Location
        • namely(Manager) then
          • creates Jobs for that particular locations; jobs belong to locations
          • shares/posts jobs to media
          • Applicants apply to those jobs and Applicants are created in the system
        • Then Recruiters can process the Applicants

Conclusion:

There is dependency; you cannot create applicant without fulfilling the prior requirements as described in the tree above.

So, when you have a level of data fulfilling the requirements like tree above (in your context its different) you export the database and save it safe so that whenever you system corrupts or you need to reset the database to test some feature you can restore the database to get back to work.

Create appropriate rake tasks

You can leverage full features of Rake to make your tasks easy. For example:

I have created well documented rake tasks to do some of the tasks like

  • Create Organization (Independent task)
  • Create Applicant (depends on Job)
  • Create Job(depends on location, User)
  • Run sidekiq in QA server (EC2 instance) from development environment
  • Seeding specific set of data

Note: Dependencies need to be supplied by user via CLI


$ rake applicant:create job_id=5