# matthewjohn/terrareg architecture

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

- Interactive diagram: https://gitdiagram.com/matthewjohn/terrareg
- Repository: https://github.com/matthewjohn/terrareg

## Overview

Terrareg is an open-source Terraform Registry. Its principal workflow is for a user or Terraform client to discover and retrieve modules from the registry; administrators can also publish and index modules from Git or uploaded source, after which Terrareg analyzes module content for presentation. The tree includes an experimental Go implementation, but the README identifies it as development-only, so the map emphasizes the established Python application. Some processing capabilities are documented but their implementation was not sampled; those relationships are shown only where the README supports them.

Main entry points: [`terrareg/database.py`](https://github.com/matthewjohn/terrareg/blob/main/terrareg/database.py) (Relational database), [`terrareg-go/internal/domain/module/service`](https://github.com/matthewjohn/terrareg/tree/main/terrareg-go/internal/domain/module/service) (Module indexing), [`terrareg/module_search.py`](https://github.com/matthewjohn/terrareg/blob/main/terrareg/module_search.py) (Module search), [`terrareg/provider_model.py`](https://github.com/matthewjohn/terrareg/blob/main/terrareg/provider_model.py) (Provider catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["API and discovery"]
  node_api["HTTP API"]
  node_module_search_api["Module search API<br/>[module_search.py]"]
  node_module_search["Module search<br/>[module_search.py]"]
  node_provider_search_api["Provider search API<br/>[provider_search.py]"]
end

subgraph group_modules["Module catalog"]
  node_module_catalog["Module catalog<br/>[models.py]"]
  node_module_indexing["Module indexing"]
  node_git_sources["Git sources"]
  node_provider_source_factory["Source selection<br/>[factory.py]"]
end

subgraph group_auth["Authentication"]
  node_authentication["Authentication<br/>[__init__.py]"]
  node_github_auth["GitHub sign-in"]
end

subgraph group_providers["Provider registry"]
  node_provider_search["Provider search<br/>[provider_search.py]"]
  node_provider_catalog["Provider catalog<br/>[provider_model.py]"]
  node_repositories["Source repositories"]
end

subgraph group_platform["Shared platform"]
  node_module_files[("File storage<br/>[file_storage.py]")]
  node_analytics["Usage analytics"]
  node_database[("Relational database<br/>[database.py]")]
  node_configuration["Configuration<br/>[config.py]"]
end

node_user(("Terraform user"))

node_user -->|"searches"| node_module_search_api
node_user -->|"requests module API"| node_api
node_module_search_api -->|"delegates"| node_module_search
node_module_search -->|"queries"| node_module_catalog
node_module_search -->|"reads"| node_database
node_user -->|"publishes source"| node_module_indexing
node_module_indexing -.->|"indexes modules"| node_module_catalog
node_module_indexing -.->|"stores files"| node_module_files
node_module_indexing -.->|"imports from Git"| node_git_sources
node_git_sources -->|"selected by"| node_provider_source_factory
node_github_auth -->|"resolves source"| node_provider_source_factory
node_user -->|"authenticates"| node_authentication
node_provider_search_api -->|"delegates"| node_provider_search
node_provider_search -.->|"searches"| node_provider_catalog
node_provider_catalog -->|"uses repository"| node_repositories
node_provider_catalog -->|"reads"| node_database
node_repositories -->|"reads and writes"| node_database
node_module_catalog -->|"reads and writes"| node_database
node_analytics -.->|"records usage"| node_database
node_api -.->|"uses settings"| node_configuration

click node_api "https://github.com/matthewjohn/terrareg/tree/main/terrareg/server/api"
click node_module_search_api "https://github.com/matthewjohn/terrareg/blob/main/terrareg/server/api/module_search.py"
click node_module_search "https://github.com/matthewjohn/terrareg/blob/main/terrareg/module_search.py"
click node_module_catalog "https://github.com/matthewjohn/terrareg/blob/main/terrareg/models.py"
click node_module_indexing "https://github.com/matthewjohn/terrareg/tree/main/terrareg-go/internal/domain/module/service"
click node_git_sources "https://github.com/matthewjohn/terrareg/tree/main/terrareg/provider_source"
click node_provider_source_factory "https://github.com/matthewjohn/terrareg/blob/main/terrareg/provider_source/factory.py"
click node_module_files "https://github.com/matthewjohn/terrareg/blob/main/terrareg/file_storage.py"
click node_authentication "https://github.com/matthewjohn/terrareg/blob/main/terrareg/auth/__init__.py"
click node_github_auth "https://github.com/matthewjohn/terrareg/blob/main/terrareg/auth/github_auth_method.py"
click node_provider_search_api "https://github.com/matthewjohn/terrareg/blob/main/terrareg/server/api/provider_search.py"
click node_provider_search "https://github.com/matthewjohn/terrareg/blob/main/terrareg/provider_search.py"
click node_provider_catalog "https://github.com/matthewjohn/terrareg/blob/main/terrareg/provider_model.py"
click node_repositories "https://github.com/matthewjohn/terrareg/blob/main/terrareg/repository_model.py"
click node_analytics "https://github.com/matthewjohn/terrareg/blob/main/terrareg-go/internal/domain/analytics/service/analytics_service.go"
click node_database "https://github.com/matthewjohn/terrareg/blob/main/terrareg/database.py"
click node_configuration "https://github.com/matthewjohn/terrareg/blob/main/terrareg/config.py"

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_api,node_module_search_api,node_module_search,node_provider_search_api,node_user toneBlue
class node_module_catalog,node_module_indexing,node_git_sources,node_provider_source_factory toneAmber
class node_authentication,node_github_auth toneMint
class node_provider_search,node_provider_catalog,node_repositories toneRose
class node_module_files,node_analytics,node_database,node_configuration toneIndigo
```

## Components

### API and discovery

- [HTTP API](https://github.com/matthewjohn/terrareg/tree/main/terrareg/server/api): `terrareg/server/api`
- [Module search API](https://github.com/matthewjohn/terrareg/blob/main/terrareg/server/api/module_search.py): `terrareg/server/api/module_search.py`
- [Module search](https://github.com/matthewjohn/terrareg/blob/main/terrareg/module_search.py): `terrareg/module_search.py`
- [Provider search API](https://github.com/matthewjohn/terrareg/blob/main/terrareg/server/api/provider_search.py): `terrareg/server/api/provider_search.py`

### Module catalog

- [Module catalog](https://github.com/matthewjohn/terrareg/blob/main/terrareg/models.py): `terrareg/models.py`
- [Module indexing](https://github.com/matthewjohn/terrareg/tree/main/terrareg-go/internal/domain/module/service): `terrareg-go/internal/domain/module/service`
- [Git sources](https://github.com/matthewjohn/terrareg/tree/main/terrareg/provider_source): `terrareg/provider_source`
- [Source selection](https://github.com/matthewjohn/terrareg/blob/main/terrareg/provider_source/factory.py): `terrareg/provider_source/factory.py`

### Authentication

- [Authentication](https://github.com/matthewjohn/terrareg/blob/main/terrareg/auth/__init__.py): `terrareg/auth/__init__.py`
- [GitHub sign-in](https://github.com/matthewjohn/terrareg/blob/main/terrareg/auth/github_auth_method.py): `terrareg/auth/github_auth_method.py`

### Provider registry

- [Provider search](https://github.com/matthewjohn/terrareg/blob/main/terrareg/provider_search.py): `terrareg/provider_search.py`
- [Provider catalog](https://github.com/matthewjohn/terrareg/blob/main/terrareg/provider_model.py): `terrareg/provider_model.py`
- [Source repositories](https://github.com/matthewjohn/terrareg/blob/main/terrareg/repository_model.py): `terrareg/repository_model.py`

### Shared platform

- [File storage](https://github.com/matthewjohn/terrareg/blob/main/terrareg/file_storage.py): `terrareg/file_storage.py`
- [Usage analytics](https://github.com/matthewjohn/terrareg/blob/main/terrareg-go/internal/domain/analytics/service/analytics_service.go): `terrareg-go/internal/domain/analytics/service/analytics_service.go`
- [Relational database](https://github.com/matthewjohn/terrareg/blob/main/terrareg/database.py): `terrareg/database.py`
- [Configuration](https://github.com/matthewjohn/terrareg/blob/main/terrareg/config.py): `terrareg/config.py`

### Other components

- **Terraform user**

## Connections

- Terraform user → Module search API: searches (evidence: `README.md`)
- Terraform user → HTTP API: requests module API (evidence: `README.md`)
- Module search API → Module search: delegates (evidence: `terrareg/server/api/module_search.py`)
- Module search → Module catalog: queries (evidence: `terrareg/module_search.py`)
- Module search → Relational database: reads (evidence: `terrareg/module_search.py`)
- Terraform user → Module indexing: publishes source (evidence: `README.md`)
- Module indexing → Module catalog: indexes modules
- Module indexing → File storage: stores files
- Module indexing → Git sources: imports from Git
- Git sources → Source selection: selected by (evidence: `terrareg/provider_source/factory.py`)
- GitHub sign-in → Source selection: resolves source (evidence: `terrareg/auth/github_auth_method.py`)
- Terraform user → Authentication: authenticates (evidence: `README.md`)
- Provider search API → Provider search: delegates
- Provider search → Provider catalog: searches
- Provider catalog → Source repositories: uses repository (evidence: `terrareg/provider_model.py`)
- Provider catalog → Relational database: reads (evidence: `terrareg/provider_model.py`)
- Source repositories → Relational database: reads and writes (evidence: `terrareg/repository_model.py`)
- Module catalog → Relational database: reads and writes (evidence: `terrareg/models.py`)
- Usage analytics → Relational database: records usage
- HTTP API → Configuration: uses settings
