Skip to content

Architecture

Repository Structure

Open Data Capture is written in TypeScript, with all source code located in a monorepo managed by Turborepo. In the repository, there are three primary folders of interest:

  1. apps
  2. packages
  3. runtime

Applications

Within the apps directory, there are five independent applications:

  1. apps/api: A REST API built using NestJS (also referred to as “Core API”)
  2. apps/gateway: An Express application with React SSR
  3. apps/outreach: A static site built with Astro (this website)
  4. apps/playground: A React SPA for dynamically compile and run instruments in the browser
  5. apps/web: A React SPA that is the primary mechanism of accessing the platform

The outreach website and playground are not relevant to the general functionality of the platform as such and are not discussed further. The other three components are independent of each other, in so far as they could be replaced with an alternative providing equivalent interfaces without impacting the functioning of other components.

Internal Packages

Within the packages directory, there are a variety of different internal packages. A given package may depend on one or more other internal packages, which is indicated in the package.json file located in the root of the directory for that package.

Databases

Open Data Capture uses two databases:

  1. A MongoDB database (also referred to as “Core Database”)
  2. An SQLite database (also referred to as “Gateway Database”)

Predictably, the Core Database is used to store almost all application data and is accessed exclusively by the Core API, while the Gateway Database is used to store encrypted data stored on the gateway.

In both cases, schemas are defined using Prisma and stored in the packages/database folder. This package exports both schemas, which can later be consumed by the appropriate application. The purpose of this setup is to allow other libraries to consume the autogenerated type definitions for the database schemas, as well as to prevent clashing between the different prisma clients in node_modules.