# Host Project The `JdeScoping.Host` project is the main entry point - an ASP.NET Core application that runs as a Windows Service. ## Program.cs Configuration ```csharp var builder = WebApplication.CreateBuilder(args); builder.Host.UseWindowsService(); // Run as Windows Service // ASP.NET Core services builder.Services.AddControllersWithViews(); builder.Services.AddRazorPages(); builder.Services.AddSignalR(); // Background services builder.Services.AddHostedService(); builder.Services.AddHostedService(); // Core dependencies (from JdeScoping.Core) builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); // Data source registration (file-based for dev, Oracle for prod) var dataSourceOptions = builder.Configuration .GetSection("DataSource").Get(); if (dataSourceOptions?.UseFileDataSource == true) { builder.Services.AddScoped(); builder.Services.AddScoped(); } else { builder.Services.AddScoped(); builder.Services.AddScoped(); } // Auth registration (fake for dev, LDAP for prod) var authOptions = builder.Configuration .GetSection("Auth").Get(); if (authOptions?.UseFakeAuth == true) { builder.Services.AddScoped(); } else { builder.Services.AddScoped(); } // Configuration builder.Services.Configure(builder.Configuration.GetSection("Ldap")); builder.Services.Configure(builder.Configuration.GetSection("DataSync")); builder.Services.Configure(builder.Configuration.GetSection("DataSource")); builder.Services.Configure(builder.Configuration.GetSection("Auth")); var app = builder.Build(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.MapRazorPages(); app.MapControllers(); app.MapHub("/hubs/status"); app.MapFallbackToFile("index.html"); app.Run(); ``` ## Controllers | Controller | Purpose | |------------|---------| | `SearchController` | Submit search, get results, download Excel | | `LookupController` | Autocomplete APIs for items, work centers, operators | | `AuthController` | Login/logout against LDAP | ## Hubs | Hub | Purpose | |-----|---------| | `StatusHub` | Pushes search status updates to connected clients | ## Background Services | Service | Purpose | |---------|---------| | `SearchProcessorService` | Polls for queued searches, executes them, generates Excel | | `DataSyncService` | Runs on schedule, syncs JDE/CMS data to local cache | Background services use `IServiceScopeFactory` to create scopes for database access, avoiding scoped-in-singleton issues. ## Related Documentation - [Solution Structure](./SolutionStructure.md) - [Data Flow](./DataFlow.md) - [Configuration](./Configuration.md)