-
Notifications
You must be signed in to change notification settings - Fork 1
Overview of platform
- Backend is for data only, not UI.
- Technologies are selected based on need, simplicity and resource availability.
- Frontend apps decide what features they want to use.
- Moving data and code from pendrive to Raspberry Pi and back should be seamless.
- Creating distribution for pendrive might not be seamless (until some time anyways :)
There are two implementations of the server available, both having the same codebase but functionality is changed based on the mode of operation
-
Central: The central server, with it's MySQL database, provides the management interface and central storage of all of user's and application's data. This is where new modules and content can be added, user data can be migrated and a distribution can be generated for the pendrive. This server is also useful for hosting the APIs on web so that same applications deployed on Raspberry Pi can be made available to the world on internet too.
-
Pi: The pi server is the one that will run on Raspberry Pi. It uses Sqlite3 as an embedded database since this server will run in a resource constrained environment.
On the Central server, the Pi server and on the Pendrive, there will always be a defined directory structure as follows
liberry/
├── code
│ ├── central-admin-app
│ ├── pi-admin-app
│ └── platform
├── content
└── output
├── central
└── pi
The liberry
directory may be named anything. This is the directory which will be referred as LIBERRY_ROOT
.
The code directory will contain all the repositories from Github.
The content directory will have all the videos, files, etc. There is no structure enforced within this directory. Each entry in the Content table of the database will point to the path in this directory. This directory will be referred as CONTENT_ROOT
.
All the information about the categories, modules, content, etc is stored in the database. The database is populate through the central admin app. The data is then dumped into the pendrive through which it is imported into the Sqlite3 database running on the Pi. The tables migrated are Category, Module, Content, Playlist, PlaylistContent.
The actual content, though, is never stored within the database, and is instead served from the filesystem. The content is also moved from the Central server to the Pi through the Pendrive.
There is a reverse migration of database entries that happens from Pi to Central through Pendrive as well. That is needed because the user and user activity information is captured on the Pi and that needs to be made available on the Central server so that any meaningful insights can be gained from them. The tables migrated are User and Activity.
- Log into the central admin app.
- If there are new categories, modules or playlists to be added, then create entries for them.
- If there is new content available, upload it on the server where it is available for download by all. Place the content somewhere within the
CONTENT_ROOT
directory on the Central server. - Create new entries for the uploaded content through the admin app. The path field must be relative to the
LIBERRY_ROOT
. Hence paths would look likecontent/primary/khan-academy/maths/video1.mp4
. - Go to the
Sync
tab on the admin app and click onCreate Pendrive Content
. Now if you go to theLIBERRY_ROOT/output/central
directory, you should see.sql
files for each table. - Ensure that the code in
LIBERRY_ROOT/code
directory is up-to-date. Go to each directory and rungit pull
andnpm install
. - Now download the entire
LIBERRY_ROOT
directory from the server to your pendrive. This can be done usingscp
command or any other tool that you might prefer.
- Plug in your pendrive into Raspberry Pi
- Log in into the pi admin app
- Select your pendrive from the directory tree displayed
- Click on
Sync
button
Clicking on Sync
button does all of the following:
- Copies everything in
code
andcontent
directories on Pendrive to Pi - Drops all tables from the database except User and Activity.
- Imports all data from sql files present in
output/central
directory. - Dumps User and Activity tables into sql files in
output/pi
directory on Pendrive. - Restarts the server so that any code changes that might have happened get picked.
Once the pendrive is back from the field, the data in sql files present in output/pi
directory need to be imported into central database.
- Log into the central admin app.
- Connect your pendrive to your computer.
- Go to the
Sync
tab. - Click on
Select SQL File
button and uploadoutput/pi/user.sql
file. - Repeat the same for
output/pi/activity.sql
file.
- Enable updation on nginx config on the Pi server.
- Enable reconfiguration of device.
- Enable auto-startup of server in event of power failure.