Documentation
¶
Overview ¶
Package transaction provides service-level logic for handling financial transactions and insights.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AIClient ¶
AIClient defines the interface for an AI service client. This abstraction allows for swapping different AI providers (e.g., OpenAI, Gemini). The actual implementation would be in a separate package (e.g., internal/client/openai).
type AIInsight ¶
type AIInsight struct {
GeneratedAt time.Time `json:"generated_at"`
InsightText string `json:"insight_text"`
Suggestions []string `json:"suggestions"`
}
AIInsight holds the AI-generated analysis of a user's spending habits.
type CategoryBreakdown ¶
type CategoryBreakdown struct {
StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"`
TotalSpend float64 `json:"total_spend"`
Breakdown []CategorySpending `json:"breakdown"`
}
CategoryBreakdown represents the distribution of spending across categories.
type CategorySpending ¶
type CategorySpending struct {
Category string `json:"category"`
TotalAmount float64 `json:"total_amount"`
Percentage float64 `json:"percentage"`
}
CategorySpending represents the total spending for a specific category.
type DataPoint ¶
DataPoint represents a single point in a time-series data set, typically for charting.
type InsightService ¶
type InsightService interface {
GetSpendingTrends(ctx context.Context, userID string, period string) (*SpendingTrends, error)
GetCategoryBreakdown(ctx context.Context, userID string, startDate, endDate time.Time) (*CategoryBreakdown, error)
GenerateAIInsights(ctx context.Context, userID string) (*AIInsight, error)
GetSpendingForecast(ctx context.Context, userID string) (*SpendingForecast, error)
}
InsightService defines the interface for transaction insight operations. It provides methods to analyze transaction data and generate meaningful reports.
func NewInsightService ¶
func NewInsightService(repo domain.TransactionRepository, aiClient AIClient) InsightService
NewInsightService creates a new instance of the insight service. It requires a transaction repository and an AI client as dependencies.
type Repository ¶
type Repository interface {
GetByID(ctx context.Context, id uuid.UUID) (*domain.Transaction, error)
List(ctx context.Context, filter domain.TransactionFilter) ([]domain.Transaction, int64, error)
Update(ctx context.Context, tx *domain.Transaction) error
CreateDispute(ctx context.Context, dispute *domain.Dispute) error
GetByUserID(ctx context.Context, userID uuid.UUID) ([]domain.Transaction, error)
}
Repository defines the data access layer requirements for transactions.
type Service ¶
type Service interface {
GetTransaction(ctx context.Context, id uuid.UUID) (*domain.Transaction, error)
ListTransactions(ctx context.Context, filter domain.TransactionFilter) (*domain.PaginatedResponse, error)
CategorizeTransaction(ctx context.Context, id uuid.UUID, category domain.Category) error
DisputeTransaction(ctx context.Context, id uuid.UUID, reason string) (*domain.Dispute, error)
DetectAndMarkRecurring(ctx context.Context, userID uuid.UUID) error
}
Service defines the interface for transaction business logic.
func NewService ¶
func NewService(repo Repository, logger *slog.Logger) Service
NewService creates a new instance of the transaction service.
type SpendingForecast ¶
type SpendingForecast struct {
ForecastPeriodDays int `json:"forecast_period_days"`
ProjectedSpend float64 `json:"projected_spend"`
ConfidenceLevel float64 `json:"confidence_level"` // e.g., 0.85 for 85%
ForecastedTrend []DataPoint `json:"forecasted_trend"`
}
SpendingForecast represents a prediction of future spending.