customer

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PersonaWhale      = "WHALE"
	PersonaGold       = "GOLD"
	PersonaFrustrated = "FRUSTRATED"
	PersonaRegular    = "REGULAR"
	PersonaNewbie     = "NEWBIE"
)

Personas.

View Source
const (
	TaskCalculatePersona = "customer.calculate_persona"
	TaskUpdatePersona    = "customer.update_persona"
	TaskUpdateDetails    = "customer.update_details"
)

Workflow task names.

View Source
const (
	StateCompleted = "COMPLETED"
	StateFailed    = "FAILED"
)
View Source
const (
	EventCustomerProfileCreated = "customer.profile_created"
)

Event types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	ID         string         `gorm:"primaryKey" json:"id"`
	CustomerID string         `gorm:"index" json:"customer_id"`
	Line1      string         `json:"line1"`
	Line2      string         `json:"line2"`
	City       string         `json:"city"`
	State      string         `json:"state"`
	Zip        string         `json:"zip"`
	Country    string         `json:"country"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"index" json:"-"`
}

Address represents a physical location associated with a customer.

type Customer

type Customer struct {
	ID        string         `gorm:"primaryKey" json:"id"`
	UserID    string         `gorm:"index" json:"user_id"` // OS-level user identity
	Name      string         `json:"name"`
	Email     string         `json:"email"`
	Persona   string         `json:"persona"` // ML-calculated persona
	Addresses []Address      `gorm:"foreignKey:CustomerID" json:"addresses"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

Customer represents a business-level customer profile.

type MLBrainV2

type MLBrainV2 struct {
	// contains filtered or unexported fields
}

MLBrainV2 analyzes a customer's history via the Context Engine to assign a persona.

func NewMLBrainV2

func NewMLBrainV2(p mdk.Projector) *MLBrainV2

func (*MLBrainV2) Analyze

func (m *MLBrainV2) Analyze(ctx context.Context, customerID string) (string, error)

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module implements the mdk.Module interface for Customer.

func NewModule

func NewModule() *Module

func (*Module) CalculatePersona

func (m *Module) CalculatePersona(ctx context.Context, input any) (any, error)

CalculatePersona determines a customer's persona using the MLBrainV2.

func (*Module) CalculatePersonaStep

func (m *Module) CalculatePersonaStep(sCtx mdk.StepContext) mdk.StepResult

CalculatePersonaStep wraps CalculatePersona to mdk.StepHandler.

func (*Module) FieldResolvers

func (m *Module) FieldResolvers() map[string]any

func (*Module) GetCustomer

func (m *Module) GetCustomer(ctx context.Context, id string) (*Customer, error)

func (*Module) ID

func (m *Module) ID() string

func (*Module) Init

func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error

func (*Module) ListCustomers

func (m *Module) ListCustomers(ctx context.Context) ([]*Customer, error)

func (*Module) Models

func (m *Module) Models() []any

func (*Module) Mutations

func (m *Module) Mutations() map[string]any

func (*Module) Queries

func (m *Module) Queries() map[string]any

func (*Module) Repo

func (m *Module) Repo() *Repository

func (*Module) Routes

func (m *Module) Routes() []mdk.Route

func (*Module) SetProjector

func (m *Module) SetProjector(p mdk.Projector)

func (*Module) Shutdown

func (m *Module) Shutdown(ctx context.Context) error

func (*Module) UpdateCustomer

func (m *Module) UpdateCustomer(ctx context.Context, id string, input UpdateCustomerInput) (*Customer, error)

func (*Module) UpdateCustomerDetails

func (m *Module) UpdateCustomerDetails(ctx context.Context, input any) (any, error)

UpdateCustomerDetails updates the customer's profile information.

func (*Module) UpdateCustomerDetailsStep

func (m *Module) UpdateCustomerDetailsStep(sCtx mdk.StepContext) mdk.StepResult

UpdateCustomerDetailsStep wraps UpdateCustomerDetails to mdk.StepHandler.

func (*Module) UpdatePersona

func (m *Module) UpdatePersona(ctx context.Context, input any) (any, error)

UpdatePersona saves the calculated persona to the customer record.

func (*Module) UpdatePersonaStep

func (m *Module) UpdatePersonaStep(sCtx mdk.StepContext) mdk.StepResult

UpdatePersonaStep wraps UpdatePersona to mdk.StepHandler.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository handles data access for customers.

func NewRepository

func NewRepository(database *gorm.DB) *Repository

NewRepository creates a new Repository.

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, id string) (*Customer, error)

GetByID retrieves a customer by its ID.

func (*Repository) GetByUserID

func (r *Repository) GetByUserID(ctx context.Context, userID string) (*Customer, error)

GetByUserID retrieves a customer by its OS-level UserID.

func (*Repository) List

func (r *Repository) List(ctx context.Context) ([]*Customer, error)

List retrieves all customers.

func (*Repository) Save

func (r *Repository) Save(ctx context.Context, c *Customer) error

Save persists a customer to the database.

type UpdateCustomerInput

type UpdateCustomerInput struct {
	Name  *string `json:"name,omitempty"`
	Email *string `json:"email,omitempty"`
}

Jump to

Keyboard shortcuts

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