This guide introduces the codebase to new LiteFarm contributors.
The LiteFarm monorepo defines two packages: webapp
and api
. As we will see, there is a kind of a third package, embedded within the api folder, that provides a certification export service, variously known as "exports", "scheduler", or "job scheduler".
The webapp
package
We use React as our primary frontend library. If you haven't seen React before we strongly recommend you go through the React Documentation and the tutorial. They are both extremely helpful getting started sources.
We use Redux for state management. If you haven't heard about Redux before, we strongly recommend you study the materials on their site. Or if you are more of a visual learner, Redux creator Dan Abramov has a free tutorial.
The api
package
The API uses Node along with Express to run the backend and routing logic. You will need to be pretty familiar with Express routing before getting into any code.
To access the database and to query it we use Knex, a query builder for multiple SQL implementations; we use PostgreSQL. Please go through Knex documentation on migrations and the api/db/migration folder to get an understanding of both the library and how the project goes about using it. The migration folder contains all the project's migrations-- the evolving definitions of the database’s schema from day one.
We use ObjectionJS to define the models in api/src/models.
The exports “package”
Within the api folder, the file packages/api/src/jobs/index.js
defines a Node service that is run separately, as if it were a third package. This service monitors Redis-based work queues to receive and process requests for exports of certification information.
Deployments
Each of the three packages is deployed to the LiteFarm production environment, and to a pre-production environment generally known as “beta” (though it is not used for traditional beta testing).
These deployments share some components.
The production environment consists of:
litefarmapp
, a Digital Ocean Droplet that:runs the
webapp
package (behind an Nginx reverse proxy) in a Docker container assigned the hostnameapp.litefarm.org
runs the
api
package in a Docker container assigned the hostnameapi.app.litefarm.org
runs PostgreSQL in a Docker container
provides file storage for the database contents and backups
litefarm-imaginary
, a Digital Ocean Droplet that:provides file storage for ? images
runs the “exports package” jobs scheduler Node service
runs the Redis-based work queues used by the API server to submit export jobs to the scheduler
runs the image manipulation microservice imaginary in a Docker container
runs an Nginx web server, hostname
image.litefarm.org
, that:serves images ….?
reverse proxies access to a Docker container running the image manipulation microservice imaginary
Digital Ocean Spaces (object storage “buckets”) that provide storage for …
The pre-production environment consists of:
liteformbeta
, a Droplet that duplicates the services onlitefarmapp
, with hostnamesbeta.litefarm.org
andapi.beta.litefarm.org
export-beta
, a Droplet that duplicates the services of onlitefarm-imaginary
, with one exception 🗒Digital Ocean Spaces (object storage “buckets”) that provide storage for …
🗒 All deployments-- production, pre-production, and local development-- use the single instance of the imaginary microservice image.litefarm.org