Skip to content

CHORUS-TRE/chorus-backend

Repository files navigation

Chorus backend

Introduction

This project is the backend of the chorus platform.

Features

  • Proto Interface Description: Implements Protocol Buffers for defining data structures and service interfaces.
  • OpenAPI API Definition: Utilizes OpenAPI specifications for a clear and standardized RESTful API description.
  • CI/CD Pipeline: Integrates Continuous Integration and Continuous Deployment using Jenkins on Kubernetes.
  • Versioned & Iterative Migrations: Manages database schema changes efficiently and safely.
  • Unit Testing: Incorporates extensive unit tests to ensure code quality and reliability.
  • Acceptance Testing: Implements acceptance tests to validate functionality against business requirements.
  • User & Authentication Service: Provides a dedicated service for user management and authentication.
  • JWT Generation: Implements JSON Web Tokens for secure data transmission.
  • Authorization Middlewares: Ensures secure access control within the application.

Launching

  1. install go
  2. pull repo
  3. requirements a) postgres docker compose -f .devcontainer/docker-compose.yml up -d b) kind ./scripts/create-local-cluster.sh
  4. launch go run go run cmd/chorus/main.go start | go run cmd/logger/main.go
  5. go to localhost:5000/doc
  6. create tenant a) get jwt TEST_CONFIG_FILE="./configs/dev/chorus.yaml" go run --tags=unit ./tests/steward/getadmintoken/main.go b) init tenant 1 in openapi steward service
  7. create user
  8. login
  9. test with get my user

Developer doc.

Create a complete service (here the workbench service)

1. Interface

  1. create service & entity protocul buffer definitions in api/proto/v1/workbench-service.proto and api/proto/v1/workbench.proto
  2. ./scripts/generate-protos.sh

4. Write the migration

  1. implement migration in internal/migration/postgres/00003_workbench.sql
    • launch the backend to apply the new migration

2. Plug autogenerated server

  1. tell the server there is a new service (both grpc and http) in internal/cmd/start.go

3. Provider (dependency injection)

  1. implement provider in internal/cmd/provider/workbench.go (copy from internal/cmd/provider/workspace.go for instance)
    • implement provider for ctrl, service and store

5. Controller

  1. implement controller in internal/api/v1/workbench-controller.go
  2. implement controller auth middleware in internal/api/v1/middleware/workbench-authorization.go
  3. implement converter in internal/api/v1/converter/workbench.go

6. Model

  1. implement model in pkg/workbench/model/workbench.go

7. Service

  1. implement service in pkg/workbench/service/workbench-service.go
  2. implement service caching middleware in pkg/workbench/service/middleware/caching.go
  3. implement service logging middleware in pkg/workbench/service/middleware/logging.go
  4. implement service validation middleware in pkg/workbench/service/middleware/validation.go

9. Store

  1. implement store in pkg/workbench/store/postgres/workbench-storage.go
  2. implement store logging middleware in pkg/workbench/store/middleware/logging.go

10. Tests

// todo

License and Usage Restrictions

Any use of the software for purposes other than academic research, including for commercial purposes, shall be requested in advance from CHUV.