Event Calendar using MEAN stack
First of all, it was fun. Specially when finally real time ‘event’ updates from differnt browser, all hard work paid off :) This is my first project with MEAN stack, I have tried to separate folder structure for relevant files. Used Socket.io to maintain realtime update accross all browser, used mongoose to use Mongodb.
- Real time event add/edit/delete with monthly/daily view.
- mobile view, desktop view. (Monthly and column style day view)
Folder names are self explanatory. Still more description given below.
- Server : nodejs express as backend server. Providing Rest API for ‘Events’ with Mongodb using Mongooes.
- Server/routes: used to store all route files, currently all ‘events’ routes stored here.
- Server/database : have db related stuff, like ‘Models’ , our only ‘Event’ Model.
- Connection.js: have db connection module , e.g ‘connect’, ‘disconnect’.
- App: Frontend with angular.
- bower_components -> all requiered bower components for bower packages.
- js/facotry -> all factory services, socketio, events
- app.js -> main file with all controller, app related stuff.
- partials -> folder contains partial templats, main calendar and event add/edit/delete template.
- index.html -> loads required js,partial etc.
-
prerequisite:
- node , npm , git
- database: mongodb locally installed and running. (my local version v3.4.5) Run the following in your Terminal to check , this should return at least 1: > ps -ef | grep mongod | grep -v grep | wc -l | tr -d ' '
- modern web browser.
-
clone to locally by : git clone https://github.com/iktiar/Event-Calendar.git
-
Install node packages, run follwoing from root of project folder(folder with 'package.json' file):
npm install //for build npm build
-
Install Bower packages
bower install
- if following message come ‘Unable to find a suitable version for angular..’, choose option 3 (angular#~1.4.x)
-
From ‘server’ folder,run in terminal:
node index.js
-
go to http://localhost:3000
[you should see ‘db connection ok!’ in terminal, if message ’error in db connection!’ shown, check DB is running, or db connection url in ‘database/models/’] -
now click on any date box to add Event, and click on ‘event’ in date box to edit event.
- npm run test
Rest API implemented in Backend in following
HTTP | API End point | Description |
---|---|---|
GET | /events/:startdate/:enddate | get events by date range |
GET | /events | get all events |
POST | /events | create new event |
GET | /events/:eventid | get event by event id |
PUT | /events/:eventid | update event by event id |
DELETE | /events/:eventid | delete event by event id |
- In backend nodejs, for event ‘post/put/delete’, socket.io enables bidirectional communication between server and client.
- we have one Mongodb collection 'events_test', holds all 'Event' collection.
- we have one Schema 'EventsSchema' used model Event.[location: /server/database/models/events.js]