This repository Capstan-deploys the JAIP Backend, so that it is service-locatable by the JAIP frontend.
- We use yarn for dependency management. Install this tool before developing in this codebase.
- This project requires a postgres database. A Prisma schema is included. See the Database section of this guide for more information on identifying the appropriate
DATABASE_URL
. - Development in this project requires access to the ITHAKA CLI tool and the ITHAKA VPN in order to take advantage of the Polaris sidecar for service discovery.
$ yarn install
Check the example.env
file to see the required environment variables used in local development (e.g., for a database connection). Add a .env
file in the project's root directory containing appropriate values, as described in the example.
The database URL is kept in AWS Parameter Store, and is used to connect to the database. The correct values are available at /test/labs/jaip/jaip-backend/database_url
and /prod/labs/jaip/jaip-backend/database_url
. Generally, you should only need to use the test database, but it is occasionally useful to use production data locally, especially when handling bug reports. In that case change the ENVIRONMENT to prod
and the DATABASE_URL to the production database URL. Using production data will also require a change to the ITHAKA sidecar command used for service discovery (use ithaka sidecar polaris --env prod
). Obviously, be extremely cautious when working with production data.
There are only two databases for this application: test
and prod
. There is no development database at present. For most purposes, the test
database should be fine for local development.
- Start the Polaris sidecar. Generally, use
ithaka sidecar polaris
If it is necessary to work with production data, use
ithaka sidecar polaris --env prod
- Start the local server
yarn dev
- Verify the server is running at
localhost:8080/api/v2/healthcheck
. This should confirm that the server, Polaris service discovery, and the database connection are all running. Expected response:
{
"server":true,
"service_discovery":true,
"db":true
}
Jest unit tests are run in Gitlab as part of the CI/CD pipeline with the command yarn test:ci
. To test locally, use yarn test
.
Deployment is handled by Gitlab CI. There are test, deploy, and undeploy jobs defined in the .gitlab-ci.yml
file, found in the project root.
The application is deployed to the ITHAKA POW platform known as Capstan. Capstan is a POW sanctioned Kubernetes cluster with first-class support for logging (to captains-log), metrics via prometheus, viewed in grafana, and visual graphs (argo) of each deployed application on the platform. It also provides high reliability and scalability with the help of Kubernetes.
You can find these in the k8s directory at the project root.