using WebServer.Components; using Controllers.PythonInterop; using Controllers.DataBase; using Controllers.Payment; // Load the module in globally and use correct path for local or docker runners AIModule interopModule = new AIModule(); if (args.Contains("Retrain-AI")) { // This runs once per month on the first -> set by the crontab.txt interopModule.PullAI(); interopModule.TrainAI(); } else if (args.Contains("Perform-AI")) { // This runs every hour that the stock market is open -> set by the crontab.txt // Get all current holdings for Stocks // Perform the AI Signal per stock // Perform action in background for each stock } else { // This runs when the server is started normally // Make sure the data is ready before first run string firstPullRan = (new DbDriver()).Get("FirstPull"); if (firstPullRan != "1") { interopModule.PullAI(); interopModule.TrainAI(); (new DbDriver()).Set("FirstPull", "1"); } // Create the webapp var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents().AddInteractiveServerComponents(); // Insert the DB driver for Dependency Injection builder.Services.AddScoped(); // Insert the payment Processor builder.Services.AddSingleton( new PaymentTestor() // Of type Payment Testor -> Change this with stripe or square in the future ); // Insert the python modlue for Dependency Injection builder.Services.AddSingleton(interopModule); // Build the app var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } // Conffigure policies app.UseHttpsRedirection(); app.UseAntiforgery(); app.MapStaticAssets(); app.MapRazorComponents().AddInteractiveServerRenderMode(); // Start the web app app.Run(); }