Skip to content

Lectern documentation update #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions docs/overview/01-lectern.md → docs/01-overview.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# Lectern

Lectern is Overture's Data Dictionary Schema Manager, designed to validate, store, and manage collections of data dictionaries. These dictionaries define schemas that specify expected data structure and syntax for tabular (TSV) data submissions. With built-in version control capabilities, Lectern can track schema evolution and compute differences between versions, while integrating with the [Lyric](https://docs.overture.bio/docs/under-development/lyric/) data submission service.
# Overview

Data dictionaries are organized collections of schemas that define the structure, constraints, and relationships of data models. Overture's Data Dictionary Manager, Lectern, is designed to manage collections of data dictionaries and can be integrated into any data platform. Lectern typically works with Overture's tabular data submission service, [Lyric](https://docs.overture.bio/docs/under-development/lyric/), to ensure data quality and consistency throughout the submission workflow.

## Key Features

- **Schema Definition:** Define comprehensive schemas specifying structure, constraints, and relationships of data elements.
- **Dictionary Management:** Maintain collections of schemas (data dictionaries) with multiple versions.
- **Version Control:** Track changes and evolution of data structures over time.
- **Schema Definition:** Define schemas that specify the structure, constraints, and relationships of data elements
- **Version Control:** Track changes of data structures over time.
- **Difference Computation:** Compare versions to understand changes in data requirements.
- **Schema Validation:** Validate the structure and syntax of data dictionary schema against Lecterns base meta-schema.
- **Schema Validation:** Validate the structure and syntax of data dictionary schema against the Lectern base meta-schema.
- **Integration:** includes a RESTful API (Swagger) for integration with larger data management systems.

## System Architecture

Lectern operates as a central Dictionary Schema repository within the Overture ecosystem, providing dictionary management and validation services through its RESTful API. The service maintains schemas in a database, tracking versions and relationships between different schema elements. Lectern's schemas are primarily consumed by Lyric, which stores and uses them to validate incoming tabular data submissions. Through this integration, Lectern plays a crucial role in ensuring data quality and consistency in the Overture submission workflow.
Lectern operates as a central Dictionary Schema repository, providing dictionary management and validation services through its RESTful API. The service maintains schemas in a database (mongoDb), tracking versions and relationships between different schema elements. In the Overture platform Lectern's schemas are consumed by [Lyric](https://docs.overture.bio/docs/under-development/lyric/), which stores and uses them to validate incoming tabular data submissions.

![Submission System Architecture](./images/submission-system.svg 'Updated Overture Submission System')
![Submission System Architecture](./assets/submission-system.svg "Updated Overture Submission System")

## Repository Structure

Expand All @@ -25,22 +23,22 @@ The repository is organized with the following directory structure:
```
.
├── apps/
│ └── server
│ └── server
└── packages/
│ ├── client
| ├── common
| ├── dictionary
| └── validation
└── scripts/
```
[Click here to view the Lectern repository on GitHub](https://github.com/overture-stack/lectern)

[Click here to view the Lectern repository on GitHub](https://github.com/overture-stack/lectern)

The modules in the monorepo are organized into three categories:

- `apps/`: Standalone processes meant to be run. These are published to [ghcr.io](https://ghcr.io) as container images.
- `packages/`: Reusable packages shared between applications and other packages. Packages are published to [NPM](https://npmjs.com).
- `scripts`: Utility scripts for use within this repo.
- `apps/`: Standalone processes meant to be run. These are published to [ghcr.io](https://ghcr.io) as container images.
- `packages/`: Reusable packages shared between applications and other packages. Packages are published to [NPM](https://npmjs.com).
- `scripts`: Utility scripts for use within this repo.

#### Lectern Components

Expand All @@ -51,4 +49,4 @@ Each component serves a specific purpose within Lectern, providing functionality
| [Lectern Server](https://github.com/overture-stack/lectern/blob/develop/apps/server/README.md) | @overture-stack/lectern-server | apps/server/ | [![Lectern GHCR Packages](https://img.shields.io/badge/GHCR-lectern-brightgreen?style=for-the-badge&logo=github)](https://github.com/overture-stack/lectern/pkgs/container/lectern) | Lectern Server web application. |
| [Lectern Client](https://github.com/overture-stack/lectern/blob/develop/packages/client/README.md) | @overture-stack/lectern-client | packages/client | [![Lectern Client NPM Package](https://img.shields.io/npm/v/@overture-stack/lectern-client?color=%23cb3837&style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@overture-stack/lectern-client) | TypeScript Client to interact with Lectern Server and Lectern data dictionaries. This library provides a REST client to assist in fetching data from the Lectern server. It also exposes the functionality from the Lectern Validation library to use a Lectern data dictionary to validate data. |
| [Lectern Dictionary](https://github.com/overture-stack/lectern/blob/develop/packages/dictionary/README.md) | | @overture-stack/lectern-dictionary | [![Lectern Client NPM Package](https://img.shields.io/npm/v/@overture-stack/lectern-dictionary?color=%23cb3837&style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@overture-stack/lectern-dictionary) | Dictionary meta-schema definition, includes TS types, and Zod schemas. This also exports all utilities for getting the diff of two dictionaries. |
| [Lectern Validation](https://github.com/overture-stack/lectern/blob/develop/packages/validation/README.md) | @overture-stack/lectern-validation | packages/validation/ | [![Lectern Validation NPM Package](https://img.shields.io/npm/v/@overture-stack/lectern-validation?color=%23cb3837&style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@overture-stack/lectern-client) | Validate data using Lectern Dictionaries.
| [Lectern Validation](https://github.com/overture-stack/lectern/blob/develop/packages/validation/README.md) | @overture-stack/lectern-validation | packages/validation/ | [![Lectern Validation NPM Package](https://img.shields.io/npm/v/@overture-stack/lectern-validation?color=%23cb3837&style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@overture-stack/lectern-client) | Validate data using Lectern Dictionaries.
252 changes: 252 additions & 0 deletions docs/02-Setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
# Setup

This guide provides instructions for setting up a complete development environment for Lectern, Overture's data dictionary management web server service.

## Prerequisites

Before beginning, ensure you have the following installed on your system:

- **PNPM** (package manager - used instead of npm)
- **Node.js** (v18 or higher)
- **Docker** (for running containerized services)

## Development Environment Setup

### 1. Database Setup

Lectern requires a MongoDB database to store dictionaries and metadata. Choose one of the following setup methods:

**Option A: Using Docker Compose (Recommended)**

```bash
# Navigate to the server directory
cd apps/server

# Start MongoDB using docker-compose
docker-compose up -d
```

**Option B: Manual Docker Setup**

```bash
docker run --name lectern-mongo \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
-p 27017:27017 \
-d mongo:latest
```

<details>
<summary><strong>Database Service Details</strong></summary>

| Service | Port | Description | Purpose |
| ------- | ----- | ------------------------------------- | ------------------------------------------------ |
| MongoDB | 27017 | NoSQL database for dictionary storage | Stores data dictionaries, versions, and metadata |

**Important Notes:**

- Ensure port 27017 is available on your system
- Default credentials: `admin/password`
- Adjust port configuration if conflicts exist with other services

</details>

### 2. Server Setup

1. **Clone the Repository**

```bash
git clone https://github.com/overture-stack/lectern.git
cd lectern
```

2. **Install Dependencies**

```bash
# Install all dependencies for the entire monorepo
pnpm install
```

3. **Configure Environment**

```bash
cd apps/server
cp .env.example .env
```

The `.env` file comes preconfigured with development defaults:

```env
# Express Configuration
PORT=3000

# Swagger Documentation
OPENAPI_PATH=/api-docs

# MongoDB Configuration
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_DB=lectern
MONGO_USER=
MONGO_PASS=

# Authentication (disabled by default)
AUTH_ENABLED=false
EGO_API=
SCOPE=

# CORS Configuration
CORS_ALLOWED_ORIGINS=

# Vault Configuration (disabled by default)
VAULT_ENABLED=false
VAULT_URL=http://localhost:8200
VAULT_SECRETS_PATH=/kv/lectern
VAULT_TOKEN=00000000-0000-0000-0000-000000000000
VAULT_ROLE=
```

<details>
<summary><strong>Environment Variables Reference</strong></summary>

**Express Configuration**

- `PORT`: Server port (default: 3000)
- `OPENAPI_PATH`: Swagger UI path (default: /api-docs)

**MongoDB Configuration**

- `MONGO_HOST`: Database hostname (default: localhost)
- `MONGO_PORT`: Database port (default: 27017)
- `MONGO_DB`: Database name (default: lectern)
- `MONGO_USER`: Database username (optional)
- `MONGO_PASS`: Database password (optional)

**Authentication (Optional)**

- `AUTH_ENABLED`: Enable JWT-based authorization (default: false)
- `EGO_API`: EGO API URL for JWT validation
- `SCOPE`: Required policy name in JWT scope
- `CORS_ALLOWED_ORIGINS`: Comma-separated list of allowed origins

**Vault Integration (Optional)**

- `VAULT_ENABLED`: Enable HashiCorp Vault integration (default: false)
- `VAULT_URL`: Vault server URL
- `VAULT_SECRETS_PATH`: Path to secrets in Vault
- `VAULT_TOKEN`: Vault access token
- `VAULT_ROLE`: Vault role for authentication

</details>

4. **Build the Application**

```bash
# From workspace root
pnpm nx build @overture-stack/lectern-server

# Or from apps/server directory
pnpm build
```

5. **Start the Development Server**

```bash
# Production mode
pnpm nx start @overture-stack/lectern-server

# Development mode with hot reloading
pnpm nx debug server
```

## Verification & Testing

### API Health Check

Verify that Lectern is running correctly:

```bash
# Health endpoint
curl http://localhost:3000/health

# Expected response: 200 OK
```

### API Documentation

Access the interactive API documentation at:

- **Swagger UI**: `http://localhost:3000/api-docs`

### Dictionary Management Testing

1. Navigate to the Swagger UI
2. Test creating a new data dictionary using the REST API
3. Verify dictionary creation, retrieval, and management operations

**Troubleshooting:**

- Ensure MongoDB is running and accessible
- Check server logs for validation errors
- Verify API endpoints are responding correctly

:::info Need Help?
If you encounter any issues or have questions about our API, please don't hesitate to reach out through our relevant [**community support channels**](https://docs.overture.bio/community/support).
:::

## Advanced Configuration

### Enabling Authorization

For production environments, enable JWT-based authorization:

1. Set `AUTH_ENABLED=true` in your `.env` file
2. Configure `EGO_API` to point to your Ego authorization service
3. Set the appropriate `SCOPE` for your permissions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unclear, maybe we need to link to a reference that explains scopes from Ego/Keycloak. I wouldn't know what value to set in this.


### Vault Integration

For secure secret management using HashiCorp Vault:

1. Set `VAULT_ENABLED=true` in your `.env` file
2. Configure Vault connection parameters
3. Lectern will retrieve MongoDB credentials from Vault instead of environment variables

## Development Commands Reference

### From Workspace Root

```bash
# Build server
pnpm nx build @overture-stack/lectern-server

# Start server
pnpm nx start @overture-stack/lectern-server

# Debug mode (hot reloading)
pnpm nx debug server
```

### From apps/server Directory

```bash
# Build
pnpm build

# Start
pnpm start

# Development mode
pnpm debug
```

### Docker Operations

```bash
# Build Docker image
docker build --no-cache -t lectern -f apps/server/Dockerfile .
```

:::warning
This guide is intended for development purposes only. For production deployments, implement appropriate security measures, configure authentication, and review all environment variables for your specific use case.
:::
Loading