Alternatives for Saral components

Alternatives for Saral components:

Saral uses a variety of components in order to enable a set of workflows. The choice of these has been driven by the needs for the initial set of workflows that the Saral reference solution enables. These choices however, are to be based on adopter needs and an adopter can choose to use alternative components, if that is what their requirements dictate. This section captures a few details on how two components can be replaced by alternatives.

Table of content

How to Migrate Saral backend to use Postgresql instead of MongoDB

This guide explains high level steps on how to switch from MongoDB to another alternative - PostgreSQL as the database for your Saral backend application using Sequelize. Sequelize is an ORM (Object-Relational Mapping) for Node.js, providing a higher-level abstraction over SQL databases.

Prerequisites

  • Node.js installed on your system

  • PostgreSQL installed and running on your system

Steps

1. Install Necessary dependency:

  • To use postgresql install node libraries like sequelize, pg, pg-hstore

2. Modify Mongoose models to sequelize models:

Saral Database Schema:

Schema details of different collections used in saral:

  • Brand

  • Classes

  • Counters

  • Exams

  • locks

  • Marks

  • Roi

  • Schools

  • Students

  • Users

  • Roisv2

  • Admissions

Note:

All the relationship/link between different collections is defined at Application level(code logic) since mongodb is NoSQL. We can either keep the same workflow using postgresql or feel free to move this to DB level and below is roughly how the ERD diagram would look like.

But make sure to recheck this against the code level logic and change accordingly

3. Setup proper indexes for DB query performance similar to once set in mongodb.

Refer to mongoose models for index details

https://github.com/Sunbird-Saral/Project-Saral/tree/main/v1.0/backend/src/models

4. Set up database connection

Create a connection to your PostgreSQL database using Sequelize. Modify code in file to allow connection pooling and DB connection logic to use postgresql.

https://github.com/Sunbird-Saral/Project-Saral/blob/main/v1.0/backend/src/db/mongoose.js

Or add a new connection setup file.

5. Modify middlewares, routes and controllers to use Sequelize

6. Modify Unit test cases to maintain code coverage and sonar gate quality checks.

https://github.com/Sunbird-Saral/Project-Saral/tree/main/v1.0/backend/test

7. Modify docker and docker-compose files to host Saral backend server to interact with postgresql DB.

Open-Source alternative for Firebase Analytics

Firebase Analytics is leveraged in order to understand basic user behavior on the Saral mobile application - including metrics such as number of logins, device profile etc. for the Saral mobile application. It allows for customization of all properties and events according to the application.

It also provides a simple dashboard for reporting.

Firebase is one of the options for basic measurement and tracking of the mobile application. There are many alternatives available, and the choice of tool should be driven by the reporting and measurement needs of the adopter

If an adopter chooses to not leverage Firebase, during the generation of the mobile app - they can skip the details on Firebase integration after the setup of the React native project.

A few open source alternatives for Firebase include:

Last updated