# nef2le/anonix architecture

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

- Interactive diagram: https://gitdiagram.com/nef2le/anonix
- Repository: https://github.com/nef2le/anonix

## Overview

Anonix is a Go microservice system that pseudonymizes or anonymizes personal data through a public REST gateway. The main user flow is a client or admin panel calling the gateway, which applies authentication/RBAC and routes requests to auth, mapping, and tokenizer services; mapping and tokenizer are explicitly documented not to call each other. Mapping persists reversible token records and audit data, while tokenizer performs cryptographic operations through Vault. Additional product branches include role/kind administration, key rotation, audit access, and scheduled TTL cleanup. Edges reflect README statements and shown imports/routes; unsampled internals are represented only where documented.

Main entry points: [`gateway/cmd/main.go`](https://github.com/nef2le/anonix/blob/main/gateway/cmd/main.go) (HTTP gateway), [`auth_service/internal/service/service.go`](https://github.com/nef2le/anonix/blob/main/auth_service/internal/service/service.go) (Authentication and RBAC), [`mapping/internal/service/service.go`](https://github.com/nef2le/anonix/blob/main/mapping/internal/service/service.go) (Mapping and audit), [`gateway/internal/services/tokenizer_service.go`](https://github.com/nef2le/anonix/blob/main/gateway/internal/services/tokenizer_service.go) (Tokenizer client service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway and panel"]
  node_panel["Admin panel<br/>[app.js]"]
  node_gateway_app["HTTP gateway<br/>[main.go]"]
  node_auth_routes["Auth handlers"]
  node_mapping_routes["Mapping handlers"]
  node_token_routes["Tokenizer handlers"]
  node_key_routes["Key rotation"]
  node_auth_gateway["Auth client service<br/>[auth_service.go]"]
  node_mapping_gateway["Mapping client service<br/>[mapping_service.go]"]
  node_token_gateway["Tokenizer client service"]
  node_panel_api["Panel API client<br/>[api.js]"]
  node_panel_views["Admin views"]
end

subgraph group_identity["Identity and access"]
  node_auth_service["Authentication and RBAC<br/>[service.go]"]
  node_auth_grpc["Auth gRPC endpoint<br/>[handler.go]"]
  node_auth_store[("Users and roles store<br/>[postgres.go]")]
  node_auth_cache[("Token cache<br/>[redis.go]")]
end

subgraph group_data["Token data services"]
  node_mapping_service["Mapping and audit<br/>[service.go]"]
  node_mapping_grpc["Mapping gRPC endpoint<br/>[handler.go]"]
  node_mapping_store[("Mapping database<br/>[postgres.go]")]
  node_mapping_cache[("Mapping cache<br/>[redis.go]")]
end

subgraph group_security["Cryptography and cleanup"]
  node_token_service["Token algorithms<br/>[service.go]"]
  node_token_grpc["Tokenizer gRPC endpoint<br/>[handler.go]"]
  node_cleaner["TTL cleaner<br/>[service.go]"]
end

node_client(("API client"))
node_vault[("HashiCorp Vault")]

node_client -->|"calls REST"| node_gateway_app
node_panel -->|"uses API"| node_panel_api
node_panel_api -->|"calls REST"| node_gateway_app
node_gateway_app -->|"routes auth"| node_auth_routes
node_gateway_app -->|"routes data"| node_mapping_routes
node_gateway_app -->|"routes tokens"| node_token_routes
node_gateway_app -->|"routes rotation"| node_key_routes
node_gateway_app -->|"serves panel"| node_panel_views
node_panel_views -->|"requests data"| node_panel_api
node_auth_routes -->|"calls service"| node_auth_gateway
node_mapping_routes -->|"calls service"| node_mapping_gateway
node_token_routes -->|"calls service"| node_token_gateway
node_key_routes -.->|"rotates keys"| node_token_gateway
node_auth_gateway -.->|"gRPC request"| node_auth_grpc
node_mapping_gateway -.->|"gRPC request"| node_mapping_grpc
node_token_gateway -.->|"gRPC request"| node_token_grpc
node_auth_grpc -->|"dispatches"| node_auth_service
node_auth_service -.->|"reads and writes"| node_auth_store
node_auth_service -.->|"caches tokens"| node_auth_cache
node_mapping_grpc -->|"dispatches"| node_mapping_service
node_mapping_service -.->|"reads and writes"| node_mapping_store
node_mapping_service -.->|"reads and writes"| node_mapping_cache
node_token_grpc -->|"dispatches"| node_token_service
node_token_service -->|"uses Transit"| node_vault
node_cleaner -->|"deletes expired"| node_mapping_store
node_cleaner -->|"deletes expired"| node_mapping_cache

click node_panel "https://github.com/nef2le/anonix/blob/main/gateway/static/panel/app.js"
click node_gateway_app "https://github.com/nef2le/anonix/blob/main/gateway/cmd/main.go"
click node_auth_routes "https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/auth_service_handler.go"
click node_mapping_routes "https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/mapping_service_handler.go"
click node_token_routes "https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/tokenizer_service_handler.go"
click node_key_routes "https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/key_rotation_handler.go"
click node_auth_gateway "https://github.com/nef2le/anonix/blob/main/gateway/internal/services/auth_service.go"
click node_mapping_gateway "https://github.com/nef2le/anonix/blob/main/gateway/internal/services/mapping_service.go"
click node_token_gateway "https://github.com/nef2le/anonix/blob/main/gateway/internal/services/tokenizer_service.go"
click node_auth_service "https://github.com/nef2le/anonix/blob/main/auth_service/internal/service/service.go"
click node_auth_grpc "https://github.com/nef2le/anonix/blob/main/auth_service/internal/transport/grpc/handler.go"
click node_auth_store "https://github.com/nef2le/anonix/blob/main/auth_service/internal/ports/adapters/storage/postgres.go"
click node_auth_cache "https://github.com/nef2le/anonix/blob/main/auth_service/internal/ports/adapters/cache/redis.go"
click node_mapping_service "https://github.com/nef2le/anonix/blob/main/mapping/internal/service/service.go"
click node_mapping_grpc "https://github.com/nef2le/anonix/blob/main/mapping/internal/transport/grpc/handler.go"
click node_mapping_store "https://github.com/nef2le/anonix/blob/main/mapping/internal/ports/adapters/storage/postgres.go"
click node_mapping_cache "https://github.com/nef2le/anonix/blob/main/mapping/internal/ports/adapters/cache/redis.go"
click node_token_service "https://github.com/nef2le/anonix/blob/main/tokenizer/internal/service/service.go"
click node_token_grpc "https://github.com/nef2le/anonix/blob/main/tokenizer/internal/transport/grpc/handler.go"
click node_cleaner "https://github.com/nef2le/anonix/blob/main/mapping_cleaner/internal/service/service.go"
click node_panel_api "https://github.com/nef2le/anonix/blob/main/gateway/static/panel/api.js"
click node_panel_views "https://github.com/nef2le/anonix/tree/main/gateway/static/panel/views"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_panel,node_gateway_app,node_auth_routes,node_mapping_routes,node_token_routes,node_key_routes,node_auth_gateway,node_mapping_gateway,node_token_gateway,node_panel_api,node_panel_views,node_client toneBlue
class node_auth_service,node_auth_grpc,node_auth_store,node_auth_cache,node_vault toneAmber
class node_mapping_service,node_mapping_grpc,node_mapping_store,node_mapping_cache toneMint
class node_token_service,node_token_grpc,node_cleaner toneRose
```

## Components

### Gateway and panel

- [Admin panel](https://github.com/nef2le/anonix/blob/main/gateway/static/panel/app.js): `gateway/static/panel/app.js`
- [HTTP gateway](https://github.com/nef2le/anonix/blob/main/gateway/cmd/main.go): `gateway/cmd/main.go`
- [Auth handlers](https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/auth_service_handler.go): `gateway/internal/handlers/http_handlers/auth_service_handler.go`
- [Mapping handlers](https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/mapping_service_handler.go): `gateway/internal/handlers/http_handlers/mapping_service_handler.go`
- [Tokenizer handlers](https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/tokenizer_service_handler.go): `gateway/internal/handlers/http_handlers/tokenizer_service_handler.go`
- [Key rotation](https://github.com/nef2le/anonix/blob/main/gateway/internal/handlers/http_handlers/key_rotation_handler.go): `gateway/internal/handlers/http_handlers/key_rotation_handler.go`
- [Auth client service](https://github.com/nef2le/anonix/blob/main/gateway/internal/services/auth_service.go): `gateway/internal/services/auth_service.go`
- [Mapping client service](https://github.com/nef2le/anonix/blob/main/gateway/internal/services/mapping_service.go): `gateway/internal/services/mapping_service.go`
- [Tokenizer client service](https://github.com/nef2le/anonix/blob/main/gateway/internal/services/tokenizer_service.go): `gateway/internal/services/tokenizer_service.go`
- [Panel API client](https://github.com/nef2le/anonix/blob/main/gateway/static/panel/api.js): `gateway/static/panel/api.js`
- [Admin views](https://github.com/nef2le/anonix/tree/main/gateway/static/panel/views): `gateway/static/panel/views`

### Identity and access

- [Authentication and RBAC](https://github.com/nef2le/anonix/blob/main/auth_service/internal/service/service.go): `auth_service/internal/service/service.go`
- [Auth gRPC endpoint](https://github.com/nef2le/anonix/blob/main/auth_service/internal/transport/grpc/handler.go): `auth_service/internal/transport/grpc/handler.go`
- [Users and roles store](https://github.com/nef2le/anonix/blob/main/auth_service/internal/ports/adapters/storage/postgres.go): `auth_service/internal/ports/adapters/storage/postgres.go`
- [Token cache](https://github.com/nef2le/anonix/blob/main/auth_service/internal/ports/adapters/cache/redis.go): `auth_service/internal/ports/adapters/cache/redis.go`

### Token data services

- [Mapping and audit](https://github.com/nef2le/anonix/blob/main/mapping/internal/service/service.go): `mapping/internal/service/service.go`
- [Mapping gRPC endpoint](https://github.com/nef2le/anonix/blob/main/mapping/internal/transport/grpc/handler.go): `mapping/internal/transport/grpc/handler.go`
- [Mapping database](https://github.com/nef2le/anonix/blob/main/mapping/internal/ports/adapters/storage/postgres.go): `mapping/internal/ports/adapters/storage/postgres.go`
- [Mapping cache](https://github.com/nef2le/anonix/blob/main/mapping/internal/ports/adapters/cache/redis.go): `mapping/internal/ports/adapters/cache/redis.go`

### Cryptography and cleanup

- [Token algorithms](https://github.com/nef2le/anonix/blob/main/tokenizer/internal/service/service.go): `tokenizer/internal/service/service.go`
- [Tokenizer gRPC endpoint](https://github.com/nef2le/anonix/blob/main/tokenizer/internal/transport/grpc/handler.go): `tokenizer/internal/transport/grpc/handler.go`
- [TTL cleaner](https://github.com/nef2le/anonix/blob/main/mapping_cleaner/internal/service/service.go): `mapping_cleaner/internal/service/service.go`

### Other components

- **API client**
- **HashiCorp Vault**

## Connections

- API client → HTTP gateway: calls REST (evidence: `gateway/cmd/main.go`)
- Admin panel → Panel API client: uses API (evidence: `gateway/static/panel/app.js`)
- Panel API client → HTTP gateway: calls REST (evidence: `gateway/static/panel/api.js`)
- HTTP gateway → Auth handlers: routes auth (evidence: `gateway/cmd/main.go`)
- HTTP gateway → Mapping handlers: routes data (evidence: `gateway/cmd/main.go`)
- HTTP gateway → Tokenizer handlers: routes tokens (evidence: `gateway/cmd/main.go`)
- HTTP gateway → Key rotation: routes rotation (evidence: `gateway/cmd/main.go`)
- HTTP gateway → Admin views: serves panel (evidence: `gateway/cmd/main.go`)
- Admin views → Panel API client: requests data (evidence: `gateway/static/panel/app.js`)
- Auth handlers → Auth client service: calls service (evidence: `gateway/internal/handlers/http_handlers/auth_service_handler.go`)
- Mapping handlers → Mapping client service: calls service (evidence: `gateway/internal/handlers/http_handlers/mapping_service_handler.go`)
- Tokenizer handlers → Tokenizer client service: calls service (evidence: `gateway/internal/handlers/http_handlers/tokenizer_service_handler.go`)
- Key rotation → Tokenizer client service: rotates keys
- Auth client service → Auth gRPC endpoint: gRPC request
- Mapping client service → Mapping gRPC endpoint: gRPC request
- Tokenizer client service → Tokenizer gRPC endpoint: gRPC request
- Auth gRPC endpoint → Authentication and RBAC: dispatches (evidence: `auth_service/internal/transport/grpc/handler.go`)
- Authentication and RBAC → Users and roles store: reads and writes
- Authentication and RBAC → Token cache: caches tokens
- Mapping gRPC endpoint → Mapping and audit: dispatches (evidence: `mapping/internal/transport/grpc/handler.go`)
- Mapping and audit → Mapping database: reads and writes
- Mapping and audit → Mapping cache: reads and writes
- Tokenizer gRPC endpoint → Token algorithms: dispatches (evidence: `tokenizer/internal/transport/grpc/handler.go`)
- Token algorithms → HashiCorp Vault: uses Transit
- TTL cleaner → Mapping database: deletes expired
- TTL cleaner → Mapping cache: deletes expired
