var builder = DistributedApplication.CreateBuilder(args);

//var cache = builder.AddRedis("cache");

var identity = builder.AddProject<Projects.RobotNet_IdentityServer>("identity-server")
    .WithExternalHttpEndpoints();
//.WithReference(cache)
//.WaitFor(cache);

var mapManager = builder.AddProject<Projects.RobotNet_MapManager>("map-manager")
    .WithExternalHttpEndpoints()
    //.WithReference(cache)
    //.WaitFor(cache)
    .WithReference(identity)
    .WaitFor(identity);

var robotManager = builder.AddProject<Projects.RobotNet_RobotManager>("robot-manager")
    .WithExternalHttpEndpoints()
    //.WithReference(cache)
    //.WaitFor(cache)
    .WithReference(identity)
    .WaitFor(identity)
    .WithReference(mapManager)
    .WaitFor(mapManager);

var scriptManager = builder.AddProject<Projects.RobotNet_ScriptManager>("script-manager")
    .WithExternalHttpEndpoints()
    //.WithReference(cache)
    //.WaitFor(cache)
    .WithReference(identity)
    .WaitFor(identity)
    .WithReference(robotManager)
    .WaitFor(robotManager);

builder.AddProject<Projects.RobotNet_WebApp>("robotnet-webapp")
    .WithExternalHttpEndpoints()
    //.WithReference(cache)
    //.WaitFor(cache)
    .WithReference(identity)
    .WaitFor(identity)
    .WithReference(mapManager)
    .WaitFor(mapManager)
    .WithReference(robotManager)
    .WaitFor(robotManager)
    .WithReference(scriptManager)
    .WaitFor(scriptManager);

builder.Build().Run();
