Help us shape the future of Go! Take the 2026 Go Developer Survey

tmi

package module
v1.21.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README ¶

TMI - Threat Modeling Improved

A collaborative threat modeling server built with Go.

Try it yourself at https://www.tmi.dev
API server online at https://api.tmi.dev
API clients available at https://github.com/ericfitz/tmi-clients

Overview

TMI (Threat Modeling Improved) is a collaborative platform for managing an organization's security review process, including threat modeling. Our mission is to reduce the toil of security reviewing, and to make threat modeling accessible, efficient, and integrated into the software development lifecycle.

The platform features security review organization and state management, interactive data flow diagram creation with real-time collaboration, and comprehensive threat documentation capabilities. Built with modern web technologies, TMI helps teams manage the security review process and identify, analyze, and mitigate security threats through collaborative modeling.

This project is the TMI server back-end, a Go service that implements the TMI REST API.

The associated Angular/Typescript front-end web application is called TMI-UX.

Quick Start

For detailed setup instructions, see Development Setup Guide.

Prerequisites
  • Go 1.26+
  • Docker Desktop (for database & Redis containers)
  • Make (for build automation)
Installation
git clone https://github.com/ericfitz/tmi.git
cd tmi
make dev-up CLUSTER=docker-desktop

The complete development environment (the server, database and Redis, deployed into a Kubernetes cluster) will start automatically, with the server reachable on port 8080. CLUSTER is required: docker-desktop (local) or k3s (remote).

Project Structure

  • api/ - API types and handlers
  • cmd/server/ - Server entry point and configuration
  • api-schema/tmi-openapi.json - OpenAPI specification

Architecture

Data Storage Pattern

Persistence goes through GORM. Entity models live in api/models/ and are the single source of truth for the schema: tables are created and migrated from the model struct tags by AutoMigrate(). The database is PostgreSQL or Oracle Autonomous Database (a supported production target); the stores are accessed through the interfaces declared in api/store.go, with GORM-backed implementations in api/*_store_gorm.go. Redis is used for caching and sessions. Unit tests of the GORM stores run against SQLite.

Documentation

Comprehensive documentation is organized by audience:

📖 For Developers
🚀 For Operations Teams
📋 Complete Documentation Index

See TMI Wiki for the complete documentation catalog organized by role and topic.

Development Commands

make dev-up CLUSTER=docker-desktop      # Start complete dev environment
make dev-status CLUSTER=docker-desktop  # Show dev environment status
make dev-down CLUSTER=docker-desktop    # Tear down dev environment (keep db data)
make build-server       # Build production binary
make test-unit                # Run unit tests
make test-integration         # Run integration tests (needs a running stack)
make cats-fuzz               # Run security fuzzing
make lint               # Run code linting

Configuration

The server reads a YAML configuration file passed with --config, and every setting can be overridden with a TMI_-prefixed environment variable (for example TMI_SERVER_PORT, TMI_JWT_EXPIRATION_SECONDS, TMI_REDIS_URL). The YAML file holds the bootstrap keys needed to start the server; operational settings are stored in the database settings service and can be overridden with the environment or the YAML file.

./bin/tmiserver --config=/path/to/config.yml
./bin/tmiserver --generate-config    # write an annotated example configuration

See config-example.yml for the bootstrap keys and their defaults, and the TMI Wiki for the full configuration reference. The environment variable for each key is declared with the key in internal/config/config.go.

WebSocket URLs

The collaborative editing WebSocket for a diagram is GET /threat_models/{threat_model_id}/diagrams/{diagram_id}/ws, and server-wide notifications are on GET /ws/notifications. Both are specified in the AsyncAPI document (api-schema/tmi-asyncapi.yml) and authenticate with a short-lived ticket passed as the ticket query parameter.

When the client reaches the server over TLS, use wss:// instead of ws://. Example: wss://your-server.com/threat_models/{threat_model_id}/diagrams/{diagram_id}/ws?ticket=...

Use GET /api/server-info to discover the correct WebSocket base URL, scheme and TLS settings automatically.

License

See license.txt

Documentation ¶

Overview ¶

Package tmi embeds static assets that the TMI server serves under /static.

The assets (favicons, web manifest icons, logos, and OAuth/SAML provider sign-in icons) are embedded into the binary rather than read from a relative ./static directory at runtime. The server runs from a Chainguard "static" container that contains only the binary (see Dockerfile.server), so a relative ./static path resolves to nothing and every static route 404s in production — including the provider sign-in icons (#498). Embedding keeps the image binary-only while making the assets available in every deployment topology regardless of the working directory.

Index ¶

Constants ¶

This section is empty.

Variables ¶

View Source
var StaticFS embed.FS

StaticFS holds the contents of the static/ directory, embedded at build time. Serve it under /static via fs.Sub(StaticFS, "static").

Functions ¶

This section is empty.

Types ¶

This section is empty.

Directories ¶

Path Synopsis
api
Package api provides storage and HTTP handlers for the TMI service.
Package api provides storage and HTTP handlers for the TMI service.
models
Package models - hooks.go contains GORM lifecycle hooks for validation.
Package models - hooks.go contains GORM lifecycle hooks for validation.
notifications
Package notifications provides database notification services that work across different database backends (PostgreSQL and Oracle).
Package notifications provides database notification services that work across different database backends (PostgreSQL and Oracle).
platform/v1alpha1
Package v1alpha1 contains the TMIComponent custom resource API for the TMI Component Platform.
Package v1alpha1 contains the TMIComponent custom resource API for the TMI Component Platform.
seed
Package seed provides database seeding for required initial data.
Package seed provides database seeding for required initial data.
validation
Package validation provides cross-database validation for TMI models.
Package validation provides cross-database validation for TMI models.
Package auth — /me/identities/link/* handlers (#383).
Package auth — /me/identities/link/* handlers (#383).
db
repository
Package repository provides database repository interfaces and implementations for the auth service.
Package repository provides database repository interfaces and implementations for the auth service.
cmd
chunkembed command
Command tmi-chunk-embed is the chunk-and-embed worker of the TMI Component Platform (issue #347).
Command tmi-chunk-embed is the chunk-and-embed worker of the TMI Component Platform (issue #347).
component-controller command
Command component-controller runs the TMI Component Platform controller.
Command component-controller runs the TMI Component Platform controller.
dbtool command
cmd/dbtool/backfill_empty_strings.go
cmd/dbtool/backfill_empty_strings.go
dedup-group-members command
Package main implements a one-off utility to remove duplicate rows from the group_members table.
Package main implements a one-off utility to remove duplicate rows from the group_members table.
extractor command
Command tmi-extractor is the sandboxed document-parse worker of the TMI Component Platform (issue #347).
Command tmi-extractor is the sandboxed document-parse worker of the TMI Component Platform (issue #347).
genconfig command
Command genconfig writes config-example.yml from the classification registry.
Command genconfig writes config-example.yml from the classification registry.
genconfigdocs command
Command genconfigdocs writes config-reference.md from the classification registry.
Command genconfigdocs writes config-reference.md from the classification registry.
migrate command
Package main implements the migrate CLI tool for TMI database schema management.
Package main implements the migrate CLI tool for TMI database schema management.
rotator command
Command rotator rotates the high-value secrets in tmi-secrets (#965).
Command rotator rotates the high-value secrets in tmi-secrets (#965).
server command
worker-probe command
Command worker-probe is a stub TMI worker.
Command worker-probe is a stub TMI worker.
internal
config/bootstrap
Package bootstrap provides the minimal, environment-only configuration a TMI worker component needs to start and reach the point where it can accept a job.
Package bootstrap provides the minimal, environment-only configuration a TMI worker component needs to start and reach the point where it can accept a job.
configsecrets
Package configsecrets bridges internal/config and internal/secrets.
Package configsecrets bridges internal/config and internal/secrets.
crypto
Package crypto provides encryption utilities for TMI.
Package crypto provides encryption utilities for TMI.
dbcheck
Package dbcheck provides utilities for classifying database errors.
Package dbcheck provides utilities for classifying database errors.
dberrors
Package dberrors provides typed database error classification.
Package dberrors provides typed database error classification.
dbschema
Package dbschema: global ThreatModel alias sequence (#452).
Package dbschema: global ThreatModel alias sequence (#452).
errcode
Package errcode holds the closed vocabulary of machine-readable error codes returned in the "error" field (and "details.code") of TMI API error bodies (ADR 2026-10-08 error-code vocabulary, issue #1048).
Package errcode holds the closed vocabulary of machine-readable error codes returned in the "error" field (and "details.code") of TMI API error bodies (ADR 2026-10-08 error-code vocabulary, issue #1048).
llm
Package llm is TMI's provider-agnostic seam over chat-completion and embedding backends.
Package llm is TMI's provider-agnostic seam over chat-completion and embedding backends.
periodic
Package periodic provides a small helper for ticker-driven background maintenance loops (e.g.
Package periodic provides a small helper for ticker-driven background maintenance loops (e.g.
platform/controller
Package controller implements the TMIComponent reconciler for the TMI Component Platform.
Package controller implements the TMIComponent reconciler for the TMI Component Platform.
rotator
Package rotator rotates the high-value secrets in tmi-secrets one idempotent phase at a time, recording progress in Secret annotations (#965).
Package rotator rotates the high-value secrets in tmi-secrets one idempotent phase at a time, recording progress in Secret annotations (#965).
safehttp
Package safehttp provides the shared SSRF-validation and dial-time IP-pinning core for server-originated outbound HTTP.
Package safehttp provides the shared SSRF-validation and dial-time IP-pinning core for server-originated outbound HTTP.
secrets
Package secrets provides a unified interface for retrieving secrets from various providers.
Package secrets provides a unified interface for retrieving secrets from various providers.
tlsconfig
Package tlsconfig builds the client tls.Config values TMI uses for its in-cluster Redis and NATS connections (PR 6, threats T356/T388).
Package tlsconfig builds the client tls.Config values TMI uses for its in-cluster Redis and NATS connections (PR 6, threats T356/T388).
tlsconfig/testpki
Package testpki writes a throwaway certificate authority and leaf certificates for unit tests and the integration harness.
Package testpki writes a throwaway certificate authority and leaf certificates for unit tests and the integration harness.
unicodecheck
Package unicodecheck provides consolidated Unicode validation for security-sensitive input.
Package unicodecheck provides consolidated Unicode validation for security-sensitive input.
worker
Package worker is the shared runtime for TMI Component Platform worker binaries (tmi-extractor, tmi-chunk-embed).
Package worker is the shared runtime for TMI Component Platform worker binaries (tmi-extractor, tmi-chunk-embed).
wwwauth
Package wwwauth builds RFC 6750 (OAuth 2.0 Bearer Token) WWW-Authenticate response headers.
Package wwwauth builds RFC 6750 (OAuth 2.0 Bearer Token) WWW-Authenticate response headers.
pkg
extract
Package extract is the framework-free document/content extraction library.
Package extract is the framework-free document/content extraction library.
jobenvelope
Package jobenvelope defines the single job-envelope schema used by every stage of the TMI Component Platform extraction pipeline.
Package jobenvelope defines the single job-envelope schema used by every stage of the TMI Component Platform extraction pipeline.
scripts
check-error-codes command
Command check-error-codes rejects string-literal error codes in non-generated, non-test Go files.
Command check-error-codes rejects string-literal error codes in non-generated, non-test Go files.
test
testdb
Package testdb provides direct database access for integration tests.
Package testdb provides direct database access for integration tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL