apptypes

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package apptypes defines application type specifications for VisionSpec. Each app type (website, microservice, mobile, desktop) has specific constraints, required artifacts, and validation rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppDefaults

type AppDefaults struct {
	Technical      TechnicalDefaults      `json:"technical,omitempty" yaml:"technical,omitempty"`
	Infrastructure InfrastructureDefaults `json:"infrastructure,omitempty" yaml:"infrastructure,omitempty"`
}

AppDefaults defines default configurations for this app type.

type AppMetadata

type AppMetadata struct {
	Name        AppType `json:"name" yaml:"name"`
	Version     string  `json:"version" yaml:"version"`
	Description string  `json:"description,omitempty" yaml:"description,omitempty"`
}

AppMetadata contains app type identification.

type AppPrompts

type AppPrompts struct {
	WhenToUse         string `json:"whenToUse,omitempty" yaml:"whenToUse,omitempty"`
	WhenNotToUse      string `json:"whenNotToUse,omitempty" yaml:"whenNotToUse,omitempty"`
	KeyConsiderations string `json:"keyConsiderations,omitempty" yaml:"keyConsiderations,omitempty"`
}

AppPrompts contains LLM guidance for this app type.

type AppType

type AppType string

AppType represents the type of application being built.

const (
	AppTypeWebsite      AppType = "website"
	AppTypeMicroservice AppType = "microservice"
	AppTypeMobile       AppType = "mobile"
	AppTypeDesktop      AppType = "desktop"
	AppTypeCLI          AppType = "cli"
	AppTypeLibrary      AppType = "library"
)

func ValidAppTypes

func ValidAppTypes() []AppType

ValidAppTypes returns all valid app types.

func (AppType) IsValid

func (a AppType) IsValid() bool

IsValid returns whether this is a known app type.

func (AppType) String

func (a AppType) String() string

String returns the string representation.

type AppTypeSpec

type AppTypeSpec struct {
	APIVersion string           `json:"apiVersion" yaml:"apiVersion"` // visionspec/v1
	Kind       string           `json:"kind" yaml:"kind"`             // AppTypeSpec
	Metadata   AppMetadata      `json:"metadata" yaml:"metadata"`
	Artifacts  Artifacts        `json:"artifacts" yaml:"artifacts"`
	Defaults   AppDefaults      `json:"defaults" yaml:"defaults"`
	Specs      SpecRequirements `json:"specs" yaml:"specs"`
	Prompts    AppPrompts       `json:"prompts,omitempty" yaml:"prompts,omitempty"`
}

AppTypeSpec defines the specification for an application type.

func MicroserviceSpec

func MicroserviceSpec() *AppTypeSpec

MicroserviceSpec returns the default AppTypeSpec for microservices.

func (*AppTypeSpec) AllowsSpec

func (s *AppTypeSpec) AllowsSpec(spec types.SpecType) bool

AllowsSpec returns true if this app type allows the given spec (required or optional).

func (*AppTypeSpec) RequiresSpec

func (s *AppTypeSpec) RequiresSpec(spec types.SpecType) bool

RequiresSpec returns true if this app type requires the given spec.

func (*AppTypeSpec) Validate

func (s *AppTypeSpec) Validate() error

Validate validates an AppTypeSpec.

type ArtifactType

type ArtifactType string

ArtifactType represents a build artifact type.

const (
	ArtifactBinary         ArtifactType = "binary"
	ArtifactContainerImage ArtifactType = "container-image"
	ArtifactOpenAPISpec    ArtifactType = "openapi-spec"
	ArtifactProtoSpec      ArtifactType = "proto-spec"
	ArtifactHelmChart      ArtifactType = "helm-chart"
	ArtifactPulumiModule   ArtifactType = "pulumi-module"
	ArtifactStaticSite     ArtifactType = "static-site"
	ArtifactMobileApp      ArtifactType = "mobile-app"
	ArtifactDesktopApp     ArtifactType = "desktop-app"
	ArtifactNPMPackage     ArtifactType = "npm-package"
	ArtifactGoModule       ArtifactType = "go-module"
	ArtifactPyPIPackage    ArtifactType = "pypi-package"
	ArtifactWASMModule     ArtifactType = "wasm-module"
)

type Artifacts

type Artifacts struct {
	Required []ArtifactType `json:"required" yaml:"required"`
	Optional []ArtifactType `json:"optional,omitempty" yaml:"optional,omitempty"`
}

Artifacts defines what this app type produces.

type InfrastructureDefaults

type InfrastructureDefaults struct {
	Containerized         *bool    `json:"containerized,omitempty" yaml:"containerized,omitempty"`
	Orchestration         []string `json:"orchestration,omitempty" yaml:"orchestration,omitempty"` // e.g., ["kubernetes", "ecs"]
	HorizontalScaling     *bool    `json:"horizontalScaling,omitempty" yaml:"horizontalScaling,omitempty"`
	CDNRequired           *bool    `json:"cdnRequired,omitempty" yaml:"cdnRequired,omitempty"`
	MinAvailabilityTarget string   `json:"minAvailabilityTarget,omitempty" yaml:"minAvailabilityTarget,omitempty"` // e.g., "99.9"
}

InfrastructureDefaults defines IRD-level defaults for this app type.

type Loader

type Loader interface {
	// Load returns the app type spec for a given app type.
	Load(appType AppType) (*AppTypeSpec, error)

	// Available returns all available app types.
	Available() []AppType
}

Loader loads app type specifications from various sources.

func BuiltinLoader

func BuiltinLoader() Loader

BuiltinLoader returns a loader with built-in app type specs.

func DefaultLoader

func DefaultLoader() Loader

DefaultLoader returns the default app type loader (built-in specs).

func NewChainLoader

func NewChainLoader(loaders ...Loader) Loader

NewChainLoader creates a loader that tries multiple loaders in order. The first loader that can load an app type spec wins. This is useful for organization-specific overrides:

loader := apptypes.NewChainLoader(
	orgLoader,        // Try org-specific first (more prescriptive)
	builtinLoader,    // Fall back to visionspec defaults (more flexible)
)

func NewEmbeddedLoader

func NewEmbeddedLoader(fsys embed.FS, dir string) Loader

NewEmbeddedLoader creates a loader from embedded filesystem. App type specs should be named: {dir}/{apptype}.yaml (e.g., microservice.yaml)

Usage:

//go:embed apptypes/*.yaml
var orgAppTypes embed.FS

loader := apptypes.NewEmbeddedLoader(orgAppTypes, "apptypes")

func NewFileLoader

func NewFileLoader(dir string) Loader

NewFileLoader creates a loader that reads app type specs from a directory.

func NewMemoryLoader

func NewMemoryLoader(specs ...*AppTypeSpec) Loader

NewMemoryLoader creates a loader from in-memory app type specs.

type MicroserviceConstraints

type MicroserviceConstraints struct {
	// Tenancy constraints
	AllowedTenancyModels []constitution.TenancyModel

	// Availability constraints
	MinAvailability constitution.AvailabilityTarget
	MaxRTO          string // Maximum acceptable RTO
	MaxRPO          string // Maximum acceptable RPO

	// Scaling constraints
	RequireHorizontalScaling bool
	RequireContainerization  bool

	// API constraints
	RequireAPISpec bool   // Must have OpenAPI or Proto spec
	APISpecFormat  string // Preferred format: "openapi" or "proto"
}

MicroserviceConstraints defines validation constraints for microservices.

func DefaultMicroserviceConstraints

func DefaultMicroserviceConstraints() *MicroserviceConstraints

DefaultMicroserviceConstraints returns the default constraints for microservices.

type SpecRequirements

type SpecRequirements struct {
	Required []types.SpecType `json:"required" yaml:"required"`
	Optional []types.SpecType `json:"optional,omitempty" yaml:"optional,omitempty"`
}

SpecRequirements defines which VisionSpec documents are required/optional.

type TechnicalDefaults

type TechnicalDefaults struct {
	APIStyles       []string `json:"apiStyles,omitempty" yaml:"apiStyles,omitempty"`             // e.g., ["rest", "grpc"]
	EmbeddedDB      *bool    `json:"embeddedDb,omitempty" yaml:"embeddedDb,omitempty"`           // Allow SQLite?
	StatefulAllowed *bool    `json:"statefulAllowed,omitempty" yaml:"statefulAllowed,omitempty"` // Can store state locally?
}

TechnicalDefaults defines TRD-level defaults for this app type.

type ValidationIssue

type ValidationIssue struct {
	Field    string
	Message  string
	Severity ValidationSeverity
}

ValidationIssue represents a validation problem.

func ValidateForMicroservice

func ValidateForMicroservice(c *constitution.Constitution, constraints *MicroserviceConstraints) []ValidationIssue

ValidateForMicroservice validates a constitution against microservice constraints.

type ValidationSeverity

type ValidationSeverity string

ValidationSeverity indicates the severity of a validation issue.

const (
	SeverityError   ValidationSeverity = "error"
	SeverityWarning ValidationSeverity = "warning"
	SeverityInfo    ValidationSeverity = "info"
)

Jump to

Keyboard shortcuts

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