# dmalykh/taxonomy architecture

> Architecture diagram of the GitHub repository dmalykh/taxonomy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dmalykh/taxonomy
- Repository: https://github.com/dmalykh/taxonomy

## Overview

##### Main Components Identification

a) API Layer (Multiple Interfaces):
- GraphQL API Server
- gRPC API Server
- CLI Interface

b) Core Service Layer:
- Namespace Service
- Term Service
- Vocabulary Service
- Reference Service

c) Repository Layer:
- EntGo Database Abstraction
- Database (configurable through DSN)

##### Architectural Pattern Representation

**┌─ API Layer ─────────┐**
- GraphQL           │
- gRPC              │
- CLI               │
- ┬────────────┘

**┌────────▼────────────┐**
- Service Layer       │
- Namespace         │
- Term              │
- Vocabulary        │
- Reference         │
- ┬────────────┘

**┌────────▼────────────┐**
- Repository Layer    │
- EntGo            │
- ┬────────────┘

**┌────────▼────────────┐**
- Database            │
- ┘

##### Specific Elements

- Blue: API interfaces
- Green: Core services
- Yellow: Repository layer
- Gray: Database layer

b) Component Relationships:
- Data flow directions
- Dependency injection points

##### Important Details to Highlight

a) API Layer:
- GraphQL schema structure (from /src/api/graphql/schema/)
- gRPC service definitions (from /src/api/grpc/proto/)
- CLI commands structure (from /src/cmd/)

b) Domain Model:
- Term
- Vocabulary
- Namespace
- Reference
- Entity relationships

c) Repository Pattern:
- EntGo implementation
- Database agnostic design

##### Key Relationships to Emphasize

- Term-Vocabulary relationships (unique constraints)
- Namespace-Entity relationships
- Reference management system
- Service-Repository interaction patterns

This approach will provide a clear understanding of both the high-level architecture and the detailed implementation structure while maintaining the clean architecture principles evident in the codebase.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef service fill:#4CAF50,stroke:#388E3C,color:white
    classDef repository fill:#FFC107,stroke:#FFA000,color:black
    classDef database fill:#9E9E9E,stroke:#616161,color:white
    classDef model fill:#FF5722,stroke:#E64A19,color:white

    %% API Layer
    subgraph API
        GQL["GraphQL API"]:::api
        GRPC["gRPC API"]:::api
        CLI["CLI Interface"]:::api
    end

    %% Service Layer
    subgraph Services
        NS["Namespace Service"]:::service
        TS["Term Service"]:::service
        VS["Vocabulary Service"]:::service
        RS["Reference Service"]:::service
    end

    %% Domain Models
    subgraph Models
        TM["Term Model"]:::model
        VM["Vocabulary Model"]:::model
        NM["Namespace Model"]:::model
        RM["Reference Model"]:::model
    end

    %% Repository Layer
    subgraph Repositories
        EntGo["EntGo Repository"]:::repository
        NR["Namespace Repository"]:::repository
        TR["Term Repository"]:::repository
        VR["Vocabulary Repository"]:::repository
        RR["Reference Repository"]:::repository
    end

    %% Database Layer
    DB[(Database)]:::database

    %% Relationships
    GQL --> NS & TS & VS & RS
    GRPC --> NS & TS & VS & RS
    CLI --> NS & TS & VS & RS

    NS --> NR
    TS --> TR
    VS --> VR
    RS --> RR

    NS --> NM
    TS --> TM
    VS --> VM
    RS --> RM

    NR & TR & VR & RR --> EntGo
    EntGo --> DB

    %% Click Events
    click GQL "https://github.com/dmalykh/taxonomy/tree/master/src/api/graphql/"
    click GRPC "https://github.com/dmalykh/taxonomy/tree/master/src/api/grpc/"
    click CLI "https://github.com/dmalykh/taxonomy/tree/master/src/cmd/"
    
    click NS "https://github.com/dmalykh/taxonomy/blob/master/src/internal/service/namespace/namespace.go"
    click TS "https://github.com/dmalykh/taxonomy/blob/master/src/internal/service/term/term.go"
    click VS "https://github.com/dmalykh/taxonomy/blob/master/src/internal/service/vocabulary/vocabulary.go"
    click RS "https://github.com/dmalykh/taxonomy/blob/master/src/internal/service/reference/reference.go"
    
    click TM "https://github.com/dmalykh/taxonomy/blob/master/src/taxonomy/model/term.go"
    click VM "https://github.com/dmalykh/taxonomy/blob/master/src/taxonomy/model/vocabulary.go"
    click NM "https://github.com/dmalykh/taxonomy/blob/master/src/taxonomy/model/namespace.go"
    click RM "https://github.com/dmalykh/taxonomy/blob/master/src/taxonomy/model/reference.go"
    
    click EntGo "https://github.com/dmalykh/taxonomy/tree/master/src/internal/repository/entgo/"
    click NR "https://github.com/dmalykh/taxonomy/blob/master/src/internal/repository/entgo/repository/namespace.go"
    click TR "https://github.com/dmalykh/taxonomy/blob/master/src/internal/repository/entgo/repository/term.go"
    click VR "https://github.com/dmalykh/taxonomy/blob/master/src/internal/repository/entgo/repository/vocabulary.go"
    click RR "https://github.com/dmalykh/taxonomy/blob/master/src/internal/repository/entgo/repository/reference.go"
```
