Skip to content

Architecture

Repository Structure

Open Data Capture is written in TypeScript, with all source code located in a monorepo managed by Turborepo.

  • Directory.bruno/
  • Directory.github/
  • Directory.husky/
  • Directoryapps/
    • Directoryapi/ A REST API built using NestJS (“Core API”)
    • Directorygateway/ An Express application with React SSR
    • Directoryoutreach/ A static site built with Astro (this website)
    • Directoryplayground/ A React SPA for building instruments
    • Directoryweb/ A React SPA for internal platform access
  • Directoryblog/
  • Directorydocs/
  • Directorypackages/
    • Directorycrypto/
    • Directorydemo/
    • Directoryesbuild-plugin-runtime/
    • Directoryi18next/
    • Directoryinstrument-bundler/
    • Directoryinstrument-interpreter/
    • Directoryinstrument-library/
    • Directoryinstrument-renderer/
    • Directoryinstrument-runtime-env/
    • Directoryinstrument-stubs/
    • Directoryinstrument-utils/
    • Directoryjson-utils/
    • Directorylicenses/
    • Directoryprisma-client/
    • Directoryreact-core/
    • Directoryruntime-resolve/
    • Directoryschemas/
    • Directorystats/
    • Directorysubject-utils/
    • Directorytailwindcss/
    • Directoryvite-plugin-plausible/
    • Directoryvite-plugin-runtime/
  • Directoryruntime/
    • Directoryv1/
  • Directoryscripts/
  • Directorytesting/
    • Directoryk6/

Applications

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 services.

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/prisma-client 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.