This guide will help you get started with Vida backend.

Architecture

Vida backend is built with nodejs framework known as Sailsjs, you have to understand sailsjs so you can have a full control or your backend including modifying and adding new features.

Deployment

Vida backend deployment is done via Docker. I created a docker-compose file that has all necessary requirements, you just need to have a docker and docker-compose installed in your server. with that in mind, a knowledge of docker and docker-compose is a plus in deploying and managing vida backend.

  1. Open docker-compose.yml file and in MYSQL, change MYSQL_ROOT_PASSWORD value to your favourite password.
  2. Start mysql and phpmyadmin containers with docker-compose up -d mysql phpmyadmin
  3. Your phpmyadmin will be deployed in port 8000, go to http://serverip:8000 and you will be able to login to phpmyadmin using the user root and password you set above at step 1
  4. Create your vida database and user. Grant this user access to vida database. Access to create, update, delete etc..
  5. go to server->data->vidabackend->config->datastores.js and update url:'mysql://user:password@host:port/database' in user, replace with user you created in phpmyadmin, in password replace with password you gave this user, in host, add mysql in port add 3306 in database replace with vida database name you created above
  6. save all changes and finalise deploying the rest containers. with docker-compose up -d
  7. Before accessing your app, you have to make sure node-modules are installed, you can do this after you enter into a running vida backend container by issuing docker exec -it vida /bin/sh then after you are in, issue npm install this will install all modules required by the app. Once complete, you have to exit container.
  8. At this point, you app will still not be live, you can confirm that by issuing docker logs -f vida in your host, you will see a log saying you need to make file changes for the app to restart. Just edit any controller with nano adding comment like //comment and save, your vida will restart and create tables and lift up. All this time, the docker logs -f vida will be showing logs on the lifting progress of your backend.
  9. Your vida will be deployed in port 1337, so you will have to go to http://serverip:1337 to access, Admin panel is available at http://serverip:1337/auth - during first login, you will be prompted to set your app, your app name, server address, admin email & password and once filled and submitted, you will be able to login and access your dashboard.

Your vida will be deployed in development mode, this mode is cpu intensive. To change to production, you need to edit your docker-compose.yml file, change environment to production then save, then delete the current docker container with docker rm -f vida then start again with docker-compose up -d vida then get into the container and install modules as above and do file changes and everything will be up in production - please note, to work well in production, you have to follow Sailsjs framework tips on production deployment. Will also provide easy to follow production deployment in your final version.

File Structure

To better understand vida backend file structure, please make sure you understand how sailsjs framework works, you can quickly see how it works if you create a sample sailsjs app and play with it. That way, you will quickly understand how this framework works and when you turn to vida backend, nothing will be strange to you.

I created this project in Sailsjs v1.2.2 which is latest version in the time i am writing this, so you get all the latest features of sailsjs.
The backend isn't completed yet, i am providing this so can be used to study and understand how vida backend works.

Tasks that are not completed and are in my plans to be included in the final version is:

BACKEND

  1. Completion of PK feature
  2. Conversion of user videos uploaded to VOD(Videos On Demand).
  3. Images optimisation (esp. Profile Photos & Video Thumbnails)

MOBILE APPS

  1. Performance improvement in mobile app
  2. Tweaking current app and create iOs app

I am currently finishing PK feature, once completed, will complete conversion of user videos to VOD as for now user videos are uploaded and played back without conversion and thus, viewers with slow network connection are having difficult in watching videos smoothly.

in Sailsjs, you can restrict certain actions unless certain conditions are met, you will find all those in api->policies so before saying something is not working, you should check a certain policy is tied to that action and so maybe conditions are not met. All policies are are enabled / disabled in config->policies.js

We have 4 controllers in our backend,
AuthController -> for backend authentication
FrontendController -> for frontend tasks
BackendController -> for all backend(dashboard) tasks
ClientController -> for all apps to backend and backend to apps tasks

In order to add fiends or table(model) in your database, modify a model you want to add or remove fields then you have to make sure in the ENVIROMENT section of vida backend docker container, NODE_ENV is set to development also in your config->models, you need to set migration:alter failure to do this, you won't see any table field modified.

For all other areas of vida backend, please understand Sailsjs framework.

This version is not yet ready for production, i will send you scalable version after completion.

In order to be able to send push notifications, you have to add your mobile apps to https://onesignal.com/ and copy keys and add in your backend settings.

The version sent to you is for you to study, you can modify to your liking or play with it the way you want.