Catalog Service Sample

Overview

The Catalog Service is a lightweight .NET 6 Web API that demonstrates how to build a microservice for managing product catalogs. It follows the clean architecture principles and is container‑ready.

Prerequisites

Getting Started

Clone the repository and run the service locally:

Clone
Run
git clone https://github.com/dotnet-architecture/microservices-sample.git
cd microservices-sample/catalog-service

The API will be available at https://localhost:5001/api/v1/catalog.

API Endpoints

Method Endpoint Description
GET /api/v1/catalog Get all catalog items
GET /api/v1/catalog/{id} Get a single item by ID
POST /api/v1/catalog Create a new catalog item
PUT /api/v1/catalog/{id} Update an existing item
DELETE /api/v1/catalog/{id} Delete an item

Docker Support

Build and run the service as a container:

Dockerfile
Commands
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["src/CatalogService/CatalogService.csproj", "CatalogService/"]
RUN dotnet restore "CatalogService/CatalogService.csproj"
COPY . .
WORKDIR "/src/src/CatalogService"
RUN dotnet build "CatalogService.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "CatalogService.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CatalogService.dll"]

Source Code

The full source is available on GitHub:

https://github.com/dotnet-architecture/microservices-sample/tree/main/catalog-service

Contributing

We welcome contributions! Please read the contributing guidelines before opening a pull request.