This guide will help you get started with Vida backend.
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.
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.
docker-compose.ymlfile and in MYSQL, change
MYSQL_ROOT_PASSWORDvalue to your favourite password.
- Start mysql and phpmyadmin containers with
docker-compose up -d mysql phpmyadmin
- Your phpmyadmin will be deployed in port 8000, go to
http://serverip:8000and you will be able to login to phpmyadmin using the user root and password you set above at step 1
- Create your vida database and user. Grant this user access to vida database. Access to create, update, delete etc..
- go to
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
- save all changes and finalise deploying the rest containers. with
docker-compose up -d
- 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/shthen after you are in, issue
npm installthis will install all modules required by the app. Once complete, you have to exit container.
- At this point, you app will still not be live, you can confirm that by issuing
docker logs -f vidain your host, you will see a log saying you need to make file changes for the app to restart. Just edit any controller with
nanoadding comment like
//commentand save, your vida will restart and create tables and lift up. All this time, the
docker logs -f vidawill be showing logs on the lifting progress of your backend.
- Your vida will be deployed in port 1337, so you will have to go to
http://serverip:1337to 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.
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:
- Completion of PK feature
- Conversion of user videos uploaded to VOD(Videos On Demand).
- Images optimisation (esp. Profile Photos & Video Thumbnails)
- Performance improvement in mobile app
- 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
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.