refactor: consolidate service registration into AddMoneyMapCore extension

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-20 18:20:23 -04:00
parent d63ded45e1
commit 62fa1d5c4c
2 changed files with 58 additions and 48 deletions
@@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MoneyMap.Data;
using MoneyMap.Services;
using MoneyMap.Services.AITools;
namespace MoneyMap.Core;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddMoneyMapCore(
this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<MoneyMapContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("MoneyMapDb")));
services.AddMemoryCache();
// Core transaction and import services
services.AddScoped<ITransactionImporter, TransactionImporter>();
services.AddScoped<ICardResolver, CardResolver>();
services.AddScoped<ITransactionCategorizer, TransactionCategorizer>();
services.AddScoped<ITransactionService, TransactionService>();
services.AddScoped<ITransactionStatisticsService, TransactionStatisticsService>();
// Entity management services
services.AddScoped<IAccountService, AccountService>();
services.AddScoped<ICardService, CardService>();
services.AddScoped<IMerchantService, MerchantService>();
services.AddScoped<IBudgetService, BudgetService>();
// Receipt services
services.AddScoped<IReceiptMatchingService, ReceiptMatchingService>();
services.AddScoped<IReceiptManager, ReceiptManager>();
services.AddScoped<IReceiptAutoMapper, ReceiptAutoMapper>();
services.AddScoped<IPdfToImageConverter, PdfToImageConverter>();
// Reference data and dashboard
services.AddScoped<IReferenceDataService, ReferenceDataService>();
services.AddScoped<IDashboardService, DashboardService>();
services.AddScoped<IDashboardStatsCalculator, DashboardStatsCalculator>();
services.AddScoped<ITopCategoriesProvider, TopCategoriesProvider>();
services.AddScoped<IRecentTransactionsProvider, RecentTransactionsProvider>();
services.AddScoped<ISpendTrendsProvider, SpendTrendsProvider>();
// AI services
services.AddScoped<IAIToolExecutor, AIToolExecutor>();
services.AddScoped<IFinancialAuditService, FinancialAuditService>();
return services;
}
}