Skip to content

Commit

Permalink
Pricing separation (2024-05-09) (#30)
Browse files Browse the repository at this point in the history
* added discounts domain and api projects to Pricing

* updated readme to reflect Pricing, Prices, Discounts changes

* renamed code projects from Pricing to Prices; directory still Pricing
  • Loading branch information
erikshafer authored May 9, 2024
1 parent 6c85a1a commit 767dabf
Show file tree
Hide file tree
Showing 24 changed files with 243 additions and 45 deletions.
18 changes: 16 additions & 2 deletions EventSourcingEcommerce.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inventory.Api", "src\Invent
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pricing", "Pricing", "{E8FE7001-AFB6-4FB2-B922-BB6A203A652E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pricing", "src\Pricing\Pricing\Pricing.csproj", "{62D164F6-13C2-4B93-B01E-95D09B60C59B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prices", "src\Pricing\Prices\Prices.csproj", "{62D164F6-13C2-4B93-B01E-95D09B60C59B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pricing.Api", "src\Pricing\Pricing.Api\Pricing.Api.csproj", "{B96B27DD-C084-4310-9056-1E084795427C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prices.Api", "src\Pricing\Prices.Api\Prices.Api.csproj", "{B96B27DD-C084-4310-9056-1E084795427C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discounts", "src\Pricing\Discounts\Discounts.csproj", "{090F1820-19D9-464B-A0B0-415182075D9D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discounts.Api", "src\Pricing\Discounts.Api\Discounts.Api.csproj", "{F42EAACF-D74A-4646-A311-AB9EB131AE8A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -119,6 +123,14 @@ Global
{B96B27DD-C084-4310-9056-1E084795427C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B96B27DD-C084-4310-9056-1E084795427C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B96B27DD-C084-4310-9056-1E084795427C}.Release|Any CPU.Build.0 = Release|Any CPU
{090F1820-19D9-464B-A0B0-415182075D9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{090F1820-19D9-464B-A0B0-415182075D9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{090F1820-19D9-464B-A0B0-415182075D9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{090F1820-19D9-464B-A0B0-415182075D9D}.Release|Any CPU.Build.0 = Release|Any CPU
{F42EAACF-D74A-4646-A311-AB9EB131AE8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F42EAACF-D74A-4646-A311-AB9EB131AE8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F42EAACF-D74A-4646-A311-AB9EB131AE8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F42EAACF-D74A-4646-A311-AB9EB131AE8A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9CD0617F-6555-4F29-9C3E-211DC9A92CD5} = {5C748417-563A-41A4-AC92-67A815C5A929}
Expand All @@ -136,5 +148,7 @@ Global
{75428565-8144-4AED-B8C8-19F7DDCDAAC6} = {1DB2150C-70C5-47D5-B4FC-5C0190106E75}
{62D164F6-13C2-4B93-B01E-95D09B60C59B} = {E8FE7001-AFB6-4FB2-B922-BB6A203A652E}
{B96B27DD-C084-4310-9056-1E084795427C} = {E8FE7001-AFB6-4FB2-B922-BB6A203A652E}
{090F1820-19D9-464B-A0B0-415182075D9D} = {E8FE7001-AFB6-4FB2-B922-BB6A203A652E}
{F42EAACF-D74A-4646-A311-AB9EB131AE8A} = {E8FE7001-AFB6-4FB2-B922-BB6A203A652E}
EndGlobalSection
EndGlobal
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ Value Streams are a core concept in [Team Topologies](https://teamtopologies.com
- cart
- checkout
- **Catalog** 📝
- listings
- pricing
- listings
- products
- **Pricing** 💵
- prices
- discounts
- **Ordering** 📦
- orders
- payments
Expand All @@ -142,11 +144,12 @@ This early on in development, this is effectively a loose roadmap of what techno
| Value Stream | Module | Done | Runtime | Language | ESDB Library | Read DB(s), Analytics |
|------------------|----------------|------|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 🏪 Retail | Storefront || <img src="https://img.shields.io/badge/Node%20js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" alt="nodejs" /> | <img src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white" alt="typescript" /> | [Emmet](https://event-driven-io.github.io/emmett/) | [<img src="https://img.shields.io/badge/Elastic_Search-005571?style=for-the-badge&logo=elasticsearch&logoColor=white" alt="elasticsearch" />](https://www.elastic.co/) |
| 🏪 Retail | Cart || <img src="https://img.shields.io/badge/Node%20js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" alt="nodejs" /> | <img src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white" alt="typescript" /> | [Emmet](https://event-driven-io.github.io/emmett/) | [<img src="https://img.shields.io/badge/Elastic_Search-005571?style=for-the-badge&logo=elasticsearch&logoColor=white" alt="elasticsearch" />](https://www.elastic.co/) |
| 🏪 Retail | Checkout || <img src="https://img.shields.io/badge/Node%20js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" alt="nodejs" /> | <img src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white" alt="typescript" /> | [Emmet](https://event-driven-io.github.io/emmett/) | N/A |
| 📝 Catalog | Listings || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [Eventuous](https://eventuous.dev/) | [<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" alt="postgresql" />](https://www.postgresql.org/) |
| 📝 Catalog | Pricing || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [MicroPlumberd](https://github.com/modelingevolution/micro-plumberd) | [<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" alt="postgresql" />](https://www.postgresql.org/) |
| 🏪 Retail | Cart || <img src="https://img.shields.io/badge/Node%20js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" alt="nodejs" /> | <img src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white" alt="typescript" /> | [Emmet](https://event-driven-io.github.io/emmett/) | TBD |
| 🏪 Retail | Checkout || <img src="https://img.shields.io/badge/Node%20js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" alt="nodejs" /> | <img src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white" alt="typescript" /> | [Emmet](https://event-driven-io.github.io/emmett/) | TBD |
| 📝 Catalog | Listings || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [Eventuous](https://eventuous.dev/) | [<img src="https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white" alt="mongodb" />](https://www.mongodb.com/) |
| 📝 Catalog | Products || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [Eventuous](https://eventuous.dev/) | [<img src="https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white" alt="mongodb" />](https://www.mongodb.com/) |
| 💵 Pricing | Prices || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [MicroPlumberd](https://github.com/modelingevolution/micro-plumberd) | [<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" alt="postgresql" />](https://www.postgresql.org/) |
| 💵 Pricing | Discounts || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [MicroPlumberd](https://github.com/modelingevolution/micro-plumberd) | [<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" alt="postgresql" />](https://www.postgresql.org/) |
| 📦 Supply Chain | Inventories || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [Eventuous](https://eventuous.dev/) | [<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" alt="postgresql" />](https://www.postgresql.org/) |
| 📦 Supply Chain | Procurement || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [Eventuous](https://eventuous.dev/) | [<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" alt="postgresql" />](https://www.postgresql.org/) |
| 📦 Supply Chain | Fulfillment || <img src="https://img.shields.io/badge/.NET-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt="dotnet" /> | <img src="https://img.shields.io/badge/C%23-239120?style=for-the-badge&logo=csharp&logoColor=white" alt="csharp" /> | [Eventuous](https://eventuous.dev/) | [<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" alt="postgresql" />](https://www.postgresql.org/) |
Expand Down
19 changes: 14 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:

esdb:
image: eventstore/eventstore:24.2.0-bookworm-jammy
image: eventstore/eventstore:24.2.0-jammy
container_name: ecomm_esdb
ports:
- '2113:2113'
Expand Down Expand Up @@ -98,14 +98,23 @@ services:
# context: .
# dockerfile: src/Inventory/Inventory.Api/Dockerfile

# pricing.api:
# image: pricing.api
# container_name: ecomm_pricing_api
# prices.api:
# image: prices.api
# container_name: ecomm_prices_api
# ports:
# - "5219:80"
# build:
# context: .
# dockerfile: src/Pricing/Pricing.Api/Dockerfile
# dockerfile: src/Pricing/Prices.Api/Dockerfile

# discounts.api:
# image: discounts.api
# container_name: ecomm_discounts_api
# ports:
# - "5221:80"
# build:
# context: .
# dockerfile: src/Pricing/Discounts.Api/Dockerfile

# legacy.api:
# image: legacy.api
Expand Down
31 changes: 31 additions & 0 deletions src/Pricing/Discounts.Api/Discounts.Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.4"/>
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Core\Ecommerce.Core.WebApi\Ecommerce.Core.WebApi.csproj" />
<ProjectReference Include="..\Discounts\Discounts.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions src/Pricing/Discounts.Api/Discounts.Api.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@Discounts.Api_HostAddress = http://localhost:5220

GET {{Discounts.Api_HostAddress}}/swagger/
Accept: application/json

###
23 changes: 23 additions & 0 deletions src/Pricing/Discounts.Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Pricing/Discounts.Api/Discounts.Api.csproj", "src/Pricing/Discounts.Api/"]
RUN dotnet restore "src/Pricing/Discounts.Api/Discounts.Api.csproj"
COPY . .
WORKDIR "/src/src/Pricing/Discounts.Api"
RUN dotnet build "Discounts.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Discounts.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Discounts.Api.dll"]
59 changes: 59 additions & 0 deletions src/Pricing/Discounts.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Http.Json;
using NodaTime;
using NodaTime.Serialization.SystemTextJson;
using Serilog;
using Serilog.Events;

Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Grpc", LogEventLevel.Information)
.MinimumLevel.Override("Grpc.Net.Client.Internal.GrpcCall", LogEventLevel.Error)
.MinimumLevel.Override("Microsoft.AspNetCore.Mvc.Infrastructure", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Console()
.WriteTo.Seq("http://localhost:5341")
.CreateLogger();

var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog();

builder.Services
.AddControllers()
.AddJsonOptions(options =>
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb));

// The pricing module with domain and service related code using MicroPlumberd.
// TODO: builder.Services.AddDiscountsModule(builder.Configuration);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.Configure<JsonOptions>(options =>
options.SerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
);

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

// app.UseHttpsRedirection();
app.UseSerilogRequestLogging();
app.UseSwagger().UseSwaggerUI();
app.MapControllers();

try {
app.Run("http://*:5220");
return 0;
}
catch (Exception e) {
Log.Fatal(e, "Host terminated unexpectedly");
return 1;
}
finally {
Log.CloseAndFlush();
}
14 changes: 14 additions & 0 deletions src/Pricing/Discounts.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5220;https://localhost:5221",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
9 changes: 9 additions & 0 deletions src/Pricing/Discounts.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading

0 comments on commit 767dabf

Please sign in to comment.