Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd

# Claude Code
.claude/

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
Expand Down
8 changes: 4 additions & 4 deletions Client.Wasm/Components/StudentCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
</CardHeader>
<CardBody>
<UnorderedList Unstyled>
<UnorderedListItem>Номер <Strong>№X "Название лабораторной"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№Х "Название варианта"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Фамилией Именем 65ХХ</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://puginarug.com/">Ссылка на форк</Link></UnorderedListItem>
<UnorderedListItem>Номер <Strong>№2 "Балансировка нагрузки"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№23 "Товар на складе"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Карповым Владимиром 6512</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://github.com/Vouchiko/cloud-development">Ссылка на форк</Link></UnorderedListItem>
</UnorderedList>
</CardBody>
</Card>
2 changes: 1 addition & 1 deletion Client.Wasm/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@using Microsoft.JSInterop
@using Client.Wasm.Layout
@using Client.Wasm.Components
@using Blazorise
@using Blazorise
@using Blazorise.Components
@using System.Text.Json
@using System.Text.Json.Nodes
4 changes: 2 additions & 2 deletions Client.Wasm/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"BaseAddress": ""
"BaseAddress": "http://localhost:5300/warehouse-item"
}
36 changes: 36 additions & 0 deletions CloudDevelopment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,52 @@ VisualStudioVersion = 17.14.36811.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Wasm", "Client.Wasm\Client.Wasm.csproj", "{AE7EEA74-2FE0-136F-D797-854FD87E022A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarehouseItem.ServiceDefaults", "WarehouseItem.ServiceDefaults\WarehouseItem.ServiceDefaults.csproj", "{97B30C3C-3125-4E99-BA67-240DD8126A25}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarehouseItem.Generator", "WarehouseItem.Generator\WarehouseItem.Generator.csproj", "{A9B4BB9B-9F03-4C1F-AB67-9DAD2E4D66BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarehouseItem.AppHost", "WarehouseItem.AppHost\WarehouseItem.AppHost.csproj", "{07AFB6CB-7359-432D-BF0B-14BA7C582AA5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarehouseItem.Gateway", "WarehouseItem.Gateway\WarehouseItem.Gateway.csproj", "{D0EFD087-0103-4ACE-AD32-F8A68EDE1988}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarehouseItem.FileService", "WarehouseItem.FileService\WarehouseItem.FileService.csproj", "{681E8533-01D5-4D49-9D11-B00ED6618E1E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarehouseItem.Tests", "WarehouseItem.Tests\WarehouseItem.Tests.csproj", "{4C568669-19BD-45C5-A91C-75510D555889}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D0EFD087-0103-4ACE-AD32-F8A68EDE1988}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0EFD087-0103-4ACE-AD32-F8A68EDE1988}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0EFD087-0103-4ACE-AD32-F8A68EDE1988}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0EFD087-0103-4ACE-AD32-F8A68EDE1988}.Release|Any CPU.Build.0 = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.Build.0 = Release|Any CPU
{97B30C3C-3125-4E99-BA67-240DD8126A25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97B30C3C-3125-4E99-BA67-240DD8126A25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97B30C3C-3125-4E99-BA67-240DD8126A25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97B30C3C-3125-4E99-BA67-240DD8126A25}.Release|Any CPU.Build.0 = Release|Any CPU
{A9B4BB9B-9F03-4C1F-AB67-9DAD2E4D66BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9B4BB9B-9F03-4C1F-AB67-9DAD2E4D66BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9B4BB9B-9F03-4C1F-AB67-9DAD2E4D66BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9B4BB9B-9F03-4C1F-AB67-9DAD2E4D66BA}.Release|Any CPU.Build.0 = Release|Any CPU
{07AFB6CB-7359-432D-BF0B-14BA7C582AA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07AFB6CB-7359-432D-BF0B-14BA7C582AA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07AFB6CB-7359-432D-BF0B-14BA7C582AA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07AFB6CB-7359-432D-BF0B-14BA7C582AA5}.Release|Any CPU.Build.0 = Release|Any CPU
{681E8533-01D5-4D49-9D11-B00ED6618E1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{681E8533-01D5-4D49-9D11-B00ED6618E1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{681E8533-01D5-4D49-9D11-B00ED6618E1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{681E8533-01D5-4D49-9D11-B00ED6618E1E}.Release|Any CPU.Build.0 = Release|Any CPU
{4C568669-19BD-45C5-A91C-75510D555889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C568669-19BD-45C5-A91C-75510D555889}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C568669-19BD-45C5-A91C-75510D555889}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C568669-19BD-45C5-A91C-75510D555889}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
63 changes: 63 additions & 0 deletions WarehouseItem.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Amazon;
using Aspire.Hosting.LocalStack.Container;

var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedis("warehouse-item-cache")
.WithImageTag("7.4-alpine")
.WithRedisInsight(containerName: "warehouse-item-insight");

var gateway = builder.AddProject<Projects.WarehouseItem_Gateway>("gateway")
.WithHttpEndpoint(name: "http", port: 5300)
.WithExternalHttpEndpoints();

var awsConfig = builder.AddAWSSDKConfig()
.WithProfile("default")
.WithRegion(RegionEndpoint.EUCentral1);

var localstack = builder
.AddLocalStack("warehouse-item-localstack", awsConfig: awsConfig, configureContainer: container =>
{
container.Lifetime = ContainerLifetime.Session;
container.DebugLevel = 1;
container.LogLevel = LocalStackLogLevel.Debug;
container.Port = 4566;
container.AdditionalEnvironmentVariables
.Add("DEBUG", "1");
container.AdditionalEnvironmentVariables
.Add("SNS_CERT_URL_HOST", "sns.eu-central-1.amazonaws.com");
});

var awsResources = builder
.AddAWSCloudFormationTemplate("files", "CloudFormation/warehouse-item-template-sns-s3.yaml", "warehouse-item")
.WithReference(awsConfig);

const int generatorPortBase = 5200;
for (var i = 1; i <= 5; ++i)
{
var generator = builder.AddProject<Projects.WarehouseItem_Generator>($"generator-{i}")
.WithReference(cache, "warehouse-item-cache")
.WithHttpEndpoint(name: "http", port: generatorPortBase + i)
.WithReference(awsResources)
.WithEnvironment("Settings__MessageBroker", "SNS")
.WaitFor(awsResources);

gateway.WaitFor(generator);
}

builder.AddProject<Projects.Client_Wasm>("client")
.WithReference(gateway)
.WaitFor(gateway);

var fileService = builder.AddProject<Projects.WarehouseItem_FileService>("warehouse-item-file-service")
.WithHttpEndpoint(name: "http", port: 5280)
.WithReference(awsResources)
.WithEnvironment("Settings__MessageBroker", "SNS")
.WithEnvironment("Settings__S3Hosting", "Localstack")
.WaitFor(awsResources);
fileService.WithEnvironment("AWS__Resources__SNSUrl", "http://host.docker.internal:5280/api/sns");
fileService.WithEnvironment("AWS__Resources__SNSTopicArn", "arn:aws:sns:eu-central-1:000000000000:warehouse-item-topic");

builder.UseLocalStack(localstack);

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Cloud formation template for warehouse item project'

Parameters:
BucketName:
Type: String
Description: Name for the S3 bucket
Default: 'warehouse-item-bucket'

TopicName:
Type: String
Description: Name for the SNS topic
Default: 'warehouse-item-topic'

Resources:
WarehouseItemBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
VersioningConfiguration:
Status: Suspended
Tags:
- Key: Name
Value: !Ref BucketName
- Key: Environment
Value: Sample
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true

WarehouseItemTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: !Ref TopicName
DisplayName: !Ref TopicName
Tags:
- Key: Name
Value: !Ref TopicName
- Key: Environment
Value: Sample

Outputs:
S3BucketName:
Description: Name of the S3 bucket
Value: !Ref WarehouseItemBucket

S3BucketArn:
Description: ARN of the S3 bucket
Value: !GetAtt WarehouseItemBucket.Arn

SNSTopicName:
Description: Name of the SNS topic
Value: !GetAtt WarehouseItemTopic.TopicName

SNSTopicArn:
Description: ARN of the SNS topic
Value: !Ref WarehouseItemTopic
29 changes: 29 additions & 0 deletions WarehouseItem.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17129;http://localhost:15221",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21101",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22255"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15221",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19083",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20274"
}
}
}
}
21 changes: 21 additions & 0 deletions WarehouseItem.AppHost/WarehouseItem.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>ed7e1e47-dc98-4419-8424-85412466aa9b</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
<PackageReference Include="Aspire.Hosting.Redis" Version="13.1.0" />
<PackageReference Include="LocalStack.Aspire.Hosting" Version="9.5.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WarehouseItem.Generator\WarehouseItem.Generator.csproj" />
<ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" />
<ProjectReference Include="..\WarehouseItem.Gateway\WarehouseItem.Gateway.csproj" />
<ProjectReference Include="..\WarehouseItem.FileService\WarehouseItem.FileService.csproj" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions WarehouseItem.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"LocalStack": {
"UseLocalStack": true,
"Session": {
"AwsAccessKeyId": "test",
"AwsSecretAccessKey": "test",
"RegionName": "eu-central-1"
},
"Config": {
"LocalStackHost": "localhost",
"UseSsl": false,
"UseLegacyPorts": false,
"EdgePort": 4566
}
}
}
9 changes: 9 additions & 0 deletions WarehouseItem.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
54 changes: 54 additions & 0 deletions WarehouseItem.FileService/Controller/S3StorageController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Microsoft.AspNetCore.Mvc;
using System.Text;
using System.Text.Json.Nodes;
using WarehouseItem.FileService.Service.Storage;

namespace WarehouseItem.FileService.Controller;

[ApiController]
[Route("api/s3")]
public class S3StorageController(IFileService fileService, ILogger<S3StorageController> logger) : ControllerBase
{
[HttpGet]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<ActionResult<List<string>>> ListFiles()
{
logger.LogInformation("Method {method} of {controller} was called.", nameof(ListFiles),
nameof(S3StorageController));
try
{
var list = await fileService.GetFilesList();

logger.LogInformation("Got a list of {count} files from bucket.", list.Count);
return Ok(list);
}
catch (Exception ex)
{
logger.LogError(ex, "Exception occured during {method} of {controller}.", nameof(ListFiles),
nameof(S3StorageController));
return StatusCode(500, new { message = ex.Message });
}
}

[HttpGet("{key}")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public async Task<ActionResult<JsonNode>> GetFile(string key)
{
logger.LogInformation("Method {method} of {controller} was called.", nameof(GetFile),
nameof(S3StorageController));
try
{
var node = await fileService.DownloadFile(key);
logger.LogInformation("Received json of {size} bytes.", Encoding.UTF8.GetByteCount(node.ToJsonString()));
return Ok(node);
}
catch (Exception ex)
{
logger.LogError(ex, "Exception occured during {method} of {controller}.", nameof(GetFile),
nameof(S3StorageController));
return StatusCode(500, new { message = ex.Message });
}
}
}
Loading
Loading