# biocomputingup/dome-registry architecture

> Architecture diagram of the GitHub repository biocomputingup/dome-registry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/biocomputingup/dome-registry
- Repository: https://github.com/biocomputingup/dome-registry

## Overview

##### Project type and purpose
- This is a full-stack web application, the DOME Registry, composed of three NPM packages:
- dome-registry-core: a shared TypeScript library with business logic used by both front- and back-end.
- dome-registry-ui: an Angular single-page application (SPA) that provides the user interface.
- dome-registry-ws: a NestJS-based web service (REST API) that implements the server side, data persistence, authentication, and integrations.

##### File structure
- Top-level directories:
- dome-registry-core/ – shared modules, utility functions, review logic, built with Webpack for distribution.
- dome-registry-ui/ – Angular CLI project: components (pages, services, directives, assets), environment configs, build scripts.
- dome-registry-ws/ – NestJS project: modules (app, review, user, ORCID OAuth, JWT-auth, email, caching, Apicuron integration), controllers, services, DTOs, schemas, scripts, Swagger setup, tests.
- Notice architectural pattern in the WS: NestJS modules follow a layered approach (controllers → services → data schemas), with cross-cutting concerns (auth guards, interceptors, caching decorators).

##### Extract insights from the README
- The README confirms the three-part split and gives installation, linking, and run instructions.
- The UI is served by Apache/nginx in production; the WS runs on Node with `npm run start:dev`.
- dome-registry-core is linked into both UI and WS via `npm link` to share type definitions and logic.

##### Main components
a. Frontend (Angular SPA)
– Components/pages, AuthInterceptor, ReviewService, UserService
– Consumes REST endpoints exposed by dome-registry-ws
b. Backend (NestJS web service)
– API Gateway layer: controllers (review, user, ORCID, JSON-LD, documents)
– Business logic: services orchestrating review workflows, ORCID integration, email notifications, caching
– Data layer: schemas (MongoDB via Mongoose or a similar ODM)
– Shared core logic: imported from dome-registry-core for review-specific utilities
c. Database
– A persistent store (e.g., MongoDB) mapping to the WS schemas
d. External services
– ORCID OAuth provider (authentication, identity checks)
– Apicuron subscription API (apicuron-sub module)
– Email system (SMTP or an email-as-a-service client)
e. Cross-cutting infrastructure
– Caching (Redis or in-memory) via cache-decorator
– JWT auth guard/strategy
– Swagger (API documentation module)

##### Relationships & interactions
- Angular UI → HTTP(S) requests → NestJS controllers.
- Controllers invoke Services → apply business rules → read/write to Database.
- Certain operations trigger:
- Email client for notifications
- ORCID OAuth strategy for user identity
- Apicuron client for external subscription events
- Cache decorator wraps selected Service methods to reduce load.
- dome-registry-core functions are invoked by both UI (for shared types, review form logic) and WS (for shared review validations).

##### Architectural patterns & design principles
- Separation of concerns: UI vs. API vs. core library
- Modular backend: NestJS modules for each domain (review, user, auth, OAuth, email, caching)
- Dependency injection: services injected into controllers and other services
- Layered architecture in WS: Controllers → Services → Data/Schemas
- Shared code extracted into a standalone package (core) for DRY and consistency

##### Essential details to capture
- The three‐package split (core, ui, ws) and how core is linked
- Angular’s AuthInterceptor enforcing JWT on every request
- NestJS modules (ORCID, JWT-auth, Apicuron, Email, Review, User)
- DB persistence and cache decorator placement
- External integrations (ORCID OAuth, Apicuron events, email notifications)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Angular SPA)"
        AngularSPA["Angular SPA"]:::frontend
        AppModule["App Module\napp.module.ts"]:::frontend
        AppRouting["App Routing\napp-routing.module.ts"]:::frontend
        AuthInterceptor["AuthInterceptor\nauth.interceptor.ts"]:::frontend
        ReviewServiceUI["ReviewService\nreview.service.ts"]:::frontend
        UserServiceUI["UserService\nuser.service.ts"]:::frontend
        SwaggerUI["Swagger-API Component\nswagger-api.component.ts"]:::frontend
        MainTS["Main Entry\nmain.ts"]:::frontend
    end

    subgraph "Shared Core Library"
        Core["dome-registry-core"]:::core
    end

    subgraph "Backend API (NestJS)"
        rootMod["App Module\napp.module.ts"]:::backend
        mainWS["Bootstrap\nmain.ts"]:::backend

        subgraph "Review Module"
            RC["Review Controller\nreview.controller.ts"]:::backend
            RS["Review Service\nreview.service.ts"]:::backend
            RSchema["Review Schema\nreview.schema.ts"]:::backend
            subgraph "JSON-LD Submodule"
                JLC["JSON-LD Controller\njson-ld.controller.ts"]:::backend
                JLS["JSON-LD Service\njson-ld.service.ts"]:::backend
            end
            subgraph "Document Submodule"
                DC["Document Controller\ndocument.controller.ts"]:::backend
                DS["Document Service\ndocument.service.ts"]:::backend
            end
        end

        subgraph "User Module"
            UC["User Controller\nuser.controller.ts"]:::backend
            US["User Service\nuser.service.ts"]:::backend
            USchema["User Schema\nuser.schema.ts"]:::backend
            UIInterceptor["User Interceptor\nuser.interceptor.ts"]:::backend
            UIDecorator["User Decorator\nuser.decorator.ts"]:::backend
        end

        subgraph "ORCID OAuth Module"
            ORCIDCtrl["ORCID Controller\norcid-oauth.controller.ts"]:::backend
            ORCIDGuard["ORCID Guard\norcid-oauth.guard.ts"]:::backend
            ORCIDStrat["ORCID Strategy\norcid-oauth.strategy.ts"]:::backend
        end

        subgraph "JWT-Auth Module"
            JWGuard["JWT Auth Guard\njwt-auth.guard.ts"]:::backend
            JWTService["JWT Service\njwt-auth.service.ts"]:::backend
            JWTStrat["JWT Strategy\njwt-auth.strategy.ts"]:::backend
        end

        subgraph "Email Notification Module"
            EmailClient["Email Client Service\nemail-client.service.ts"]:::backend
        end

        subgraph "Apicuron Module"
            ApicClient["Apicuron Client\napicuron-client.service.ts"]:::backend
        end

        CacheDec["Cache Decorator\ncache-decorator.ts"]:::backend
        Config["Configuration\nconfiguration.ts"]:::backend
        SwaggerWS["Swagger Setup\nswagger.ts"]:::backend
    end

    DB["MongoDB"]:::db

    ORCIDService["ORCID OAuth Provider"]:::external
    EmailService["Email Service"]:::external
    ApicService["Apicuron API"]:::external

    AngularSPA -->|"HTTP/JSON"| RC
    AngularSPA -->|"HTTP/JSON"| UC
    AppRouting --> AppModule
    AppModule --> AngularSPA
    AuthInterceptor --> AngularSPA
    ReviewServiceUI --> AngularSPA
    UserServiceUI --> AngularSPA
    SwaggerUI --> AngularSPA
    MainTS --> AngularSPA

    Core --> AngularSPA
    Core --> RS

    rootMod --> RC
    rootMod --> UC
    rootMod --> ORCIDCtrl
    rootMod --> JWGuard
    mainWS --> rootMod
    SwaggerWS --> rootMod
    Config --> rootMod

    RC --> RS
    UC --> US
    RS --> RSchema
    US --> USchema
    JLC --> JLS
    DC --> DS

    RS --> DB
    US --> DB
    RSchema --> DB
    USchema --> DB

    RS --> EmailClient
    RS --> ApicClient
    UC --> ORCIDCtrl
    ORCIDCtrl --> ORCIDService
    EmailClient --> EmailService
    ApicClient --> ApicService

    RS --> CacheDec
    CacheDec --> RS

    click Core "https://github.com/biocomputingup/dome-registry/tree/main/dome-registry-core/"
    click AppModule "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ui/src/app/app.module.ts"
    click AppRouting "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ui/src/app/app-routing.module.ts"
    click AuthInterceptor "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ui/src/app/auth.interceptor.ts"
    click ReviewServiceUI "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ui/src/app/review.service.ts"
    click UserServiceUI "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ui/src/app/user.service.ts"
    click SwaggerUI "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ui/src/app/swagger-api/swagger-api.component.ts"
    click MainTS "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ui/src/main.ts"

    click rootMod "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/app.module.ts"
    click mainWS "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/main.ts"
    click RC "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/review/review.controller.ts"
    click RS "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/review/review.service.ts"
    click RSchema "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/review/review.schema.ts"
    click JLC "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/review/Json-ld/json-ld.controller.ts"
    click JLS "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/review/Json-ld/json-ld.service.ts"
    click DC "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/review/doc/document.contoller.ts"
    click DS "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/review/doc/document.service.ts"
    click UC "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/user/user.controller.ts"
    click US "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/user/user.service.ts"
    click USchema "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/user/user.schema.ts"
    click UIInterceptor "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/user/user.interceptor.ts"
    click UIDecorator "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/user/user.decorator.ts"
    click ORCIDCtrl "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/orcid-oauth/orcid-oauth.controller.ts"
    click ORCIDGuard "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/orcid-oauth/orcid-oauth.guard.ts"
    click ORCIDStrat "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/orcid-oauth/orcid-oauth.strategy.ts"
    click JWGuard "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/jwt-auth/jwt-auth.guard.ts"
    click JWTService "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/jwt-auth/jwt-auth.service.ts"
    click JWTStrat "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/jwt-auth/jwt-auth.strategy.ts"
    click EmailClient "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/Email-system/email-client.service.ts"
    click ApicClient "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/apicuron-sub/apicuron-client.service.ts"
    click CacheDec "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/cache-management/cache-decorator.ts"
    click Config "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/config/configuration.ts"
    click SwaggerWS "https://github.com/biocomputingup/dome-registry/blob/main/dome-registry-ws/src/swagger/swagger.ts"

    classDef frontend fill:#cfe2f3,stroke:#0366d6,color:#0366d6
    classDef core fill:#fff2cc,stroke:#bf9000
    classDef backend fill:#d9ead3,stroke:#38761d,color:#38761d
    classDef db fill:#fce5cd,stroke:#e69138,color:#e69138
    classDef external fill:#e1e1e1,stroke:#999999
```
