Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ coverage.*
.vscode/

site/

drs-server
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ MKDOCS_IMAGE ?= squidfunk/mkdocs-material:latest

.PHONY: gen
gen:
@mkdir -p .tmp internal/apigen
@mkdir -p .tmp apigen
# OpenAPI Generator (Go server stub)
# delete previous generated code
rm -rf internal/apigen
rm -rf apigen
# generate new code
docker run --rm \
--user "$$(id -u):$$(id -g)" \
-v "$(PWD):/local" \
$(OAG_IMAGE) generate \
-g go-gin-server \
-g go-server \
--skip-validate-spec \
--git-repo-id drs-server \
--git-user-id calypr \
-i /local/$(OPENAPI) \
-o /local/internal/apigen
# a bundle is created at internal/apigen/openapi.yaml, remove examples from it
-o /local/apigen \
--additional-properties outputAsLibrary=true,sourceFolder=drs,packageName=drs
# a bundle is created at apigen/openapi.yaml, remove examples from it
# as many are not compliant with the spec or seem to be randomly generated
go run ./cmd/openapi-remove-examples
# go run ./cmd/openapi-remove-examples

.PHONY: test
test:
Expand All @@ -36,6 +38,7 @@ serve:
docs:
docker run --rm -it \
-v "$(PWD):/docs" \
--user "$$(id -u):$$(id -g)" \
-p 8000:8000 \
$(MKDOCS_IMAGE) \
serve -a 0.0.0.0:8000
85 changes: 55 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,68 @@
# drs-server

A lightweight reference implementation of a GA4GH Data Repository Service (DRS) server in Go.
A lightweight, production-grade implementation of a GA4GH Data Repository Service (DRS) server in Go.

## Table of Contents
- [Overview](#overview)
- [Quickstart](QUICKSTART.md)
- [Contributing](CONTRIBUTING.md)
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
## Purpose

The `drs-server` provides a robust implementation of the [GA4GH DRS API](https://ga4gh.github.io/data-repository-service-schemas/). It is designed to manage metadata for data objects and provide secure access via signed URLs.

## Overview
### Key Features
- **GA4GH DRS Compliance**: Implements the standard DRS API for describing and accessing data objects.
- **Database Flexibility**: Supports both **SQLite** and **PostgreSQL** backends with a modular driver architecture.
- **S3 Integration**: Native support for Amazon S3 (and compatible storage like MinIO) with signed URL generation for downloads and multipart uploads.
- **Gen3 Compatibility Layers**:
- **Fence Compatibility**: Supports Fence-style `/data/download` and multipart upload endpoints.
- **Indexd Compatibility**: Provides Indexd-style metadata management for integration with `git-drs`.

GA4GH DRS is a standard API for describing and accessing data objects in cloud or on‑premise repositories.
This project consumes the official GA4GH `data-repository-service-schemas` as a Git submodule and generates a Go HTTP server from the DRS OpenAPI spec.
## Configuration

The server is configured via a YAML or JSON file. Use the following structure to set up your environment:

```mermaid
graph TD
0[ga4gh/data-repository-service-schemas DRS OpenAPI spec submodule] --> B
A[Makefile] --> B[make gen]
A --> C2[cmd/server]
A --> D[make test]
A --> E[make docs/]
```yaml
port: 8080

B --> G[internal/apigen generated DRS server code]
B --> H[cmd/openapi-remove-examples clean OpenAPI helper] --> H2[internal/apigen/api/openapi.yaml]
database:
sqlite:
file: "drs.db"
# Or use PostgreSQL:
# postgres:
# host: "localhost"
# port: 5432
# user: "user"
# password: "password"
# database: "drs"
# sslmode: "disable"

H2 --> C2
D --> C2
G --> C2
s3_credentials:
- bucket: "my-test-bucket"
region: "us-east-1"
access_key: "AKIAXXXXXXXXXXXXXXXX"
secret_key: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
endpoint: "s3.amazonaws.com" # Optional: set for MinIO or custom backends
```

* Makefile - targets for generation, tests, docs, and running the server.
* `make gen` - generates the DRS server code from the OpenAPI spec.
* ga4gh/data-repository-service-schemas - GA4GH DRS OpenAPI spec (Git submodule).
* internal/apigen - generated DRS server code.
* cmd/openapi-remove-examples - helper to clean the bundled OpenAPI.
* `make serve` - runs the DRS server.
* cmd/server - main HTTP server (uses gin-gonic/gin).
* `make test` - launches server, runs integration tests.
* `make docs` - serves documentation with MkDocs.
## Running Integration Tests

You can run integration tests using your own config file:

```bash
go test ./cmd/server -v -count=1 -testConfig=config.yaml
```

## Architecture

The project follows a modular structure to ensure maintainability:
- `db/core`: Core interfaces and models.
- `db/sqlite`, `db/postgres`: Database implementation drivers.
- `internal/api`: Subpackages for different API contexts (Admin, Fence, Gen3).
- `service`: High-level business logic implementing the DRS service.
- `urlmanager`: Logic for interacting with cloud storage providers.

## Development

The project uses a Makefile for common tasks:
- `make gen`: Generates the DRS server code from the official GA4GH OpenAPI spec (Git submodule).
- `make test`: Runs all unit and integration tests.
- `make serve`: Starts the DRS server.


58 changes: 58 additions & 0 deletions apigen/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.openapi-generator-ignore
README.md
api/openapi.yaml
drs/api.go
drs/api_objects.go
drs/api_objects_service.go
drs/api_service_info.go
drs/api_service_info_service.go
drs/api_upload_request.go
drs/api_upload_request_service.go
drs/error.go
drs/helpers.go
drs/impl.go
drs/logger.go
drs/model_access_method.go
drs/model_access_method_access_url.go
drs/model_access_method_authorizations.go
drs/model_access_method_update_request.go
drs/model_access_url.go
drs/model_authorizations.go
drs/model_bulk_access_method_update_request.go
drs/model_bulk_access_method_update_request_updates_inner.go
drs/model_bulk_access_url.go
drs/model_bulk_delete_request.go
drs/model_bulk_object_access_id.go
drs/model_bulk_object_access_id_bulk_object_access_ids_inner.go
drs/model_bulk_object_id_no_passport.go
drs/model_bulk_update_access_methods_200_response.go
drs/model_checksum.go
drs/model_contents_object.go
drs/model_delete_request.go
drs/model_drs_object.go
drs/model_drs_object_candidate.go
drs/model_drs_service.go
drs/model_drs_service_drs.go
drs/model_drs_service_type.go
drs/model_error.go
drs/model_get_bulk_access_url_200_response.go
drs/model_get_bulk_objects_200_response.go
drs/model_get_bulk_objects_request.go
drs/model_get_service_info_200_response.go
drs/model_options_bulk_object_200_response.go
drs/model_post_access_url_request.go
drs/model_post_object_request.go
drs/model_register_objects_201_response.go
drs/model_register_objects_request.go
drs/model_service.go
drs/model_service_organization.go
drs/model_service_type.go
drs/model_summary.go
drs/model_unresolved_inner.go
drs/model_upload_method.go
drs/model_upload_method_access_url.go
drs/model_upload_request.go
drs/model_upload_request_object.go
drs/model_upload_response.go
drs/model_upload_response_object.go
drs/routers.go
1 change: 1 addition & 0 deletions apigen/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.19.0-SNAPSHOT
36 changes: 36 additions & 0 deletions apigen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Go API Server for drs

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

## Overview
This server was generated by the [openapi-generator]
(https://openapi-generator.tech) project.
By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.

To see how to make this your own, look here:

[README](https://openapi-generator.tech)

- API version: 1.5.0
- Build date: 2026-01-12T03:49:20.482821942Z[Etc/UTC]
- Generator version: 7.19.0-SNAPSHOT


### Running the server
To run the server, follow these simple steps:

```
go run main.go
```

The server will be available on `http://localhost:8080`.

To run the server in a docker container
```
docker build --network=host -t drs .
```

Once image is built use
```
docker run --rm -it drs
```
Loading