A CRUD App for Car Ride Sharing...
Deployed at http://carzilla.mybluemix.net/
CarZilla app which allows users to perform Create/Read/Update/Delete operations on Car Entity. It uses OAuth 2 with Devise for authentication, A access_token is passed in the Header of every HTTP request. The API end point is /api/v1/cars. It returns response is in JSON format. The database that I have used is MongoDB for storing Users as well as Cars.
Technology wise, I have used Restful and MVC architectures for developing App. The Model(M) and Controller(C) part in Rails and View(V) part is in Angular. So we can easily decouple our consumer application from producers if required. Every request is authenticated on the server side using devise_token_auth
gem, Which checks for access_token in HTTP Header.
- Frontend: AngularJS and Bootstrap
- API: Ruby on Rails and mongoid ODM
- Database: MongoDB
- Auth: devise, devise_token_auth, and ng_token_auth
- Misc.: SendGrid, toaster(for notifications)
The technology stack is as follows:
AngularJS + UI -------> Rails Server -------> MongoDB
- End user interact with rails server on
localhost:3000
which serves a Single Page Application(SPA) in AngularJS. - It prompts us with Registration/Login page, After email confirmation and login, we will be redirected to our app.
- It initially makes a call (
/api/v1/cars
) to rails server for getting all the Cars. - Rails controller handles this routes and makes a call MongoDB. It Uses 'mongoid' ODM to get documents from MongoDB.
- All the HTTP API calls are Restful in nature.
- User can Register and Confirm his/her email.
- User can Login and Logout.
- User can Reset his/her password via email.
- After Login, User can perform CRUD on Cars.
- Clone CarZilla app using
git clone https://github.com/vs4vijay/carzilla/
- go to carzilla directory using
cd carzilla
. - Do a
bundle install
. - Start MongoDB server using
mongod
on another terminal. - Run carzilla rails app using
rails s
. - Now open rails server
localhost:3000
on browser.
- Right now we are using default WEBrick server, we can use Puma or Passenger.
- UI can be more Intuitive.
- Can remove Hash(#) from URL, caused by AngularJS.
- Errors can be handled in batter way on Client side.
- Export
SENDGRID_PASSWORD
to environment.
rails new carzilla -o
bundle install
rails g mongoid:config
rails g model car model:string year:integer desc:text
rails g controller cars
- Add methods/actions on controller
- Add route to routes.rb
resources :cars
- Add frontend using AngularJS and Bootstrap
- Add Bootstrap gem
bootstrap-sass
- Add AngularJS gem and dependencies
- Add
ui-router
,toaser
- Add
- Add Bootstrap gem
- Add token based authentication via
devise_token_auth
gem (on rails side) andng-token-auth
(on angular side)