Initial import into Gitea

This commit is contained in:
Grae Jones
2026-03-14 13:50:09 -07:00
parent 8e7e03702e
commit 34c1f09e01
154 changed files with 17666 additions and 1548 deletions

View File

@@ -0,0 +1,75 @@
namespace IntelligenceApi.Models;
// ════════════════════════════════════════════════
// Request: Gateway → IntelligenceApi
// Gateway sends raw census data fetched from DB,
// plus the ZCTA for context.
// ════════════════════════════════════════════════
public sealed class DemographicAnalysisRequest
{
/// <summary>5-digit ZIP code / ZCTA</summary>
public string Zcta { get; set; } = string.Empty;
/// <summary>
/// Raw census row from spDemographics.
/// All numeric fields; nulls treated as zero.
/// </summary>
public CensusData Census { get; set; } = new();
}
public sealed class CensusData
{
public int TotalPopulation { get; set; }
public int TotalHouseholds { get; set; }
public int MedianIncome { get; set; }
public int MedianHomeValue { get; set; }
public decimal Pct18to24 { get; set; }
public decimal Pct25to34 { get; set; }
public decimal Pct35to44 { get; set; }
public decimal Pct45to54 { get; set; }
public decimal Pct55to64 { get; set; }
public decimal Pct65plus { get; set; }
public decimal PctBachelorPlus { get; set; }
public decimal PctOwnerOccupied { get; set; }
public decimal PctRenterOccupied { get; set; }
public decimal PctFamilyHouseholds { get; set; }
public decimal PctLivingAlone { get; set; }
public decimal PctHispanic { get; set; }
public decimal PctAsian { get; set; }
public decimal PctBlack { get; set; }
public decimal PctRemoteWork { get; set; }
public decimal PctPublicTransit { get; set; }
public decimal UnemploymentRate { get; set; }
public decimal PctIncomeUnder30k { get; set; }
public decimal PctIncome30kTo75k { get; set; }
public decimal PctIncome75kTo150k { get; set; }
public decimal PctIncome150kPlus { get; set; }
}
// ════════════════════════════════════════════════
// Response: IntelligenceApi → Gateway → Client
// ════════════════════════════════════════════════
public sealed class DemographicAnalysisResponse
{
public bool Ok { get; set; } = true;
public string Zcta { get; set; } = string.Empty;
/// <summary>Raw census metrics passed through for display</summary>
public CensusData Census { get; set; } = new();
/// <summary>Derived recommendations for wizard chip auto-population</summary>
public AudienceRecommendations Recommendations { get; set; } = new();
/// <summary>Human-readable summary strings for the insight bar</summary>
public List<string> Insights { get; set; } = new();
}
public sealed class AudienceRecommendations
{
public List<string> AgeRanges { get; set; } = new();
public List<string> Incomes { get; set; } = new();
public string AgeSkew { get; set; } = "balanced";
public string MarketScope { get; set; } = "local";
}

View File

@@ -0,0 +1,117 @@
namespace IntelligenceApi.Models;
// ════════════════════════════════════════════════
// Request: Gateway → IntelligenceApi
// Gateway injects clientCategory from ClientContext
// before forwarding the wizard's forecast request.
// ════════════════════════════════════════════════
public sealed class SpendDistributionRequest
{
/// <summary>
/// Client category — the primary engine selector.
/// Values: General | Franchisee | Franchisor | FoodFranchisee | etc.
/// Injected by the Gateway from ClientContext.ClientCategory.
/// </summary>
public string ClientCategory { get; set; } = "General";
/// <summary>Advertising objective: awareness, traffic, leads, sales</summary>
public string Objective { get; set; } = "traffic";
/// <summary>Business category from wizard Step 1 (industry)</summary>
public string? BusinessCategory { get; set; }
/// <summary>Keywords from URL analysis</summary>
public List<string> Keywords { get; set; } = new();
/// <summary>Geo targeting from audience step</summary>
public GeoTargeting? GeoTargeting { get; set; }
/// <summary>Audience parameters</summary>
public AudienceParams? Audience { get; set; }
/// <summary>Monthly budget in whole dollars</summary>
public decimal MonthlyBudget { get; set; }
/// <summary>Channels to estimate</summary>
public List<string>? Channels { get; set; }
/// <summary>
/// Provider base URLs forwarded from Gateway config.
/// Allows engines to call providers without needing their own config.
/// </summary>
public Dictionary<string, string>? ProviderUrls { get; set; }
/// <summary>Internal API keys forwarded from Gateway config.</summary>
public Dictionary<string, string>? InternalKeys { get; set; }
}
public sealed class GeoTargeting
{
public List<string>? ZipCodes { get; set; }
public double? RadiusMiles { get; set; }
public List<long>? GeoTargetIds { get; set; }
}
public sealed class AudienceParams
{
public int? AgeMin { get; set; }
public int? AgeMax { get; set; }
public List<string>? Genders { get; set; }
public List<string>? Interests { get; set; }
}
// ════════════════════════════════════════════════
// Response: IntelligenceApi → Gateway → Client
// Identical shape to ChannelForecastResponse in
// the Gateway so no client changes are needed.
// ════════════════════════════════════════════════
public sealed class SpendDistributionResponse
{
public bool Ok { get; set; } = true;
public string Objective { get; set; } = string.Empty;
public decimal TotalBudget { get; set; }
public List<ChannelAllocation> Channels { get; set; } = new();
public DistributionRecommendation? Recommendation { get; set; }
public DistributionMeta Metadata { get; set; } = new();
}
public sealed class ChannelAllocation
{
public string Provider { get; set; } = string.Empty;
public int AllocationPercent { get; set; }
public decimal AllocatedBudget { get; set; }
public AllocationMetrics Estimates { get; set; } = new();
public double EfficiencyScore { get; set; }
public string StrengthLabel { get; set; } = string.Empty;
public string Confidence { get; set; } = "none";
public string DataSource { get; set; } = "none";
}
public sealed class AllocationMetrics
{
public double Impressions { get; set; }
public double? Reach { get; set; }
public double Clicks { get; set; }
public double Conversions { get; set; }
public decimal AvgCpc { get; set; }
public decimal AvgCpm { get; set; }
public decimal? EstimatedCpa { get; set; }
public double Ctr { get; set; }
}
public sealed class DistributionRecommendation
{
public string Summary { get; set; } = string.Empty;
public List<string> Highlights { get; set; } = new();
}
public sealed class DistributionMeta
{
public DateTimeOffset GeneratedAt { get; set; } = DateTimeOffset.UtcNow;
public string ForecastPeriod { get; set; } = "30 days";
/// <summary>Which engine handled this request — useful for debugging and billing.</summary>
public string Engine { get; set; } = "General";
}