Documentation
¶
Index ¶
- Constants
- type Address
- type Customer
- type MLBrainV2
- type Module
- func (m *Module) CalculatePersona(ctx context.Context, input any) (any, error)
- func (m *Module) CalculatePersonaStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) FieldResolvers() map[string]any
- func (m *Module) GetCustomer(ctx context.Context, id string) (*Customer, error)
- func (m *Module) ID() string
- func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error
- func (m *Module) ListCustomers(ctx context.Context) ([]*Customer, error)
- func (m *Module) Models() []any
- func (m *Module) Mutations() map[string]any
- func (m *Module) Queries() map[string]any
- func (m *Module) Repo() *Repository
- func (m *Module) Routes() []mdk.Route
- func (m *Module) SetProjector(p mdk.Projector)
- func (m *Module) Shutdown(ctx context.Context) error
- func (m *Module) UpdateCustomer(ctx context.Context, id string, input UpdateCustomerInput) (*Customer, error)
- func (m *Module) UpdateCustomerDetails(ctx context.Context, input any) (any, error)
- func (m *Module) UpdateCustomerDetailsStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) UpdatePersona(ctx context.Context, input any) (any, error)
- func (m *Module) UpdatePersonaStep(sCtx mdk.StepContext) mdk.StepResult
- type Repository
- func (r *Repository) GetByID(ctx context.Context, id string) (*Customer, error)
- func (r *Repository) GetByUserID(ctx context.Context, userID string) (*Customer, error)
- func (r *Repository) List(ctx context.Context) ([]*Customer, error)
- func (r *Repository) Save(ctx context.Context, c *Customer) error
- type UpdateCustomerInput
Constants ¶
const ( PersonaWhale = "WHALE" PersonaGold = "GOLD" PersonaFrustrated = "FRUSTRATED" PersonaRegular = "REGULAR" PersonaNewbie = "NEWBIE" )
Personas.
const ( TaskCalculatePersona = "customer.calculate_persona" TaskUpdatePersona = "customer.update_persona" TaskUpdateDetails = "customer.update_details" )
Workflow task names.
const ( StateCompleted = "COMPLETED" StateFailed = "FAILED" )
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 ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the mdk.Module interface for Customer.
func (*Module) CalculatePersona ¶
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 (*Module) GetCustomer ¶
func (*Module) ListCustomers ¶
func (*Module) Repo ¶
func (m *Module) Repo() *Repository
func (*Module) SetProjector ¶
func (*Module) UpdateCustomer ¶
func (*Module) UpdateCustomerDetails ¶
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 ¶
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) GetByUserID ¶
GetByUserID retrieves a customer by its OS-level UserID.