IoT-SaaS: Web App using ReactJS, MongoDB Atlas & Realm
Tags: atlashackathon, mongodb, javascript, serverless
Published: 2022-01-11 12:41:56

### Overview of My Submission
Nowadays, SaaS platforms & IoT devices are gaining popularity in a variety of use-cases. I built a prototype for IoT based SaaS platform for aquaculture. Users can register to the platform, subscribe to a device and get Real-Time alerts and Dashboards on the fly. Importantly, Pay-as-you-use.

Though IoT use cases primarily focus on Timeseries collections, I tried to include random features as much as possible to experience different MongoDB features with this proto-type project.

### Submission Category: 
Prime Time

### Link to Code
https://github.com/tagorenathv/iot-saas

### Tool Stack Used
- All data stored in `MongoDB Atlas`
- `Timeseries collection` for storing sensor_data with granularity and expireAfterSeconds defined
- `Atlas Search`: Search Index on device collection for fields: title with analyzers & mapping defined for Autocompletition functianality
- Text Index on device collection for fields: title and description for `Full-Text search` functionality, including spell corrections
- `Scheduled-Triggers` for:
 - simulating data 
 - calculating aggregated sensor data values 
 - generating bills every month
- `Database-Triggers` on every aggregated-value to check alert condition and insert into alert collection if any
- Used `Realm-Functions` for performing data manipulations present in MongoDB Atlas collections
- Frontend made with React JS, ant.design UI library and used `Realm-Web-Client` SDK for calling Realm-Functions
- Used Email/Password provider of `Realm-Authentication` for UI authentication
- Applied `Realm-DataAccess Rules` for added layer of Authorization for each collection
- Hosted react application on `Realm-Hosting`

### Demo
To Watch: [Link-1](https://watch.screencastify.com/v/GIhh6PDvAx6WIoXJ1K6g) or [Link-2](https://drive.google.com/file/d/1WX0zJvo65LyWddyfbZUBdVFOW58BaP7f/view?usp=sharing)
To Experience: [iot-saas](https://iot-saas-user-umzdm.mongodbstitch.com/)

### Wana Try?
Please follow [README](https://github.com/tagorenathv/iot-saas#setup-guide) file for setup details and also to understand how different MongoDB services are combined together to perform some action in this project

### Take-Aways
My Take-Aways on MongoDB ecosystem after this project
- MongoDB ecosystem has evolved at its best, making developers life easy and bringing ideas into existance with matter of clicks! Importantly, no need to go for other services. One stop solution for all your usecases.
- Want Autocomplete feature? Use Atlas-Search. No more replicating data to Elasticsearch
- Want Timeseries feature? Use Timeseries collection. Utilize granularity and expireAfterSeconds for data archivals and performance enhacement Out-of-the-box. (P.S: Use Atlas cluster from v5.0 for Timeseries collections)
- Want Full-Text search feature? Create Text-Index on collection. No more replicating data to Elasticsearch
- Want Authentication? Use Realm-Authentication
- Want Authorization? Use Realm-Rules
- Want Event-Driven triggers both Scheduled & Database? - Use Realm-Triggers
- Want to access data Serverlessly without backend? Use Realm-Client SDKs or Enable HTTP Endpoints
- Want to host your application? Use Realm-Hosting
- and lot lot lot more out-of-the-box

### What else could be better?
PS.: In my opinion
- Times I felt, documentation is misleading. Navigations could be more clear
- Folders uploading not available at Realm-Hosting UI. Need to create folders and upload files individually if needed. Would save time if this is available from UI
- At Realm-Deployment,  it would be helpful to modify all json configuration files and deploy from UI itself. External & Github actions are quite helpful thought.
- Eagerly waiting for Flutter Realm-SDK GA. Can't wait to use two best things for a project 🔥🔥🔥

### Additional Resources / Info
- React UI library - [ant.design](https://ant.design/components/overview/)
- [MongoDB Atlas](https://docs.atlas.mongodb.com/getting-started/)
- [Realm-Functions](https://docs.mongodb.com/realm/functions/)
- [Realm-Triggers](https://docs.mongodb.com/realm/triggers/trigger-types/)
- [Realm-Web Client SDK](https://docs.mongodb.com/realm/web/)
- [Realm-Rules](https://docs.mongodb.com/realm/rules/)
- [Realm-Authentication](https://docs.mongodb.com/realm/authentication/)
- [Realm-Hosting](https://docs.mongodb.com/realm/hosting/)
- [Realm Github CI/CD](https://www.mongodb.com/developer/how-to/build-ci-cd-pipelines-realm-apps-github-actions/)


**PS:** Project is built and hosted with MongoDB ecosystem and ❤️