Bu klasör case study’de istenen backend’i içerir:
- Merchant bazlı ürün ekleme ve listeleme
- Kategori bazlı komisyon oranı (mock servis)
- Satış fiyatı hesaplama: komisyon + %20 KDV
- Merchant veri izolasyonu (header ile)
- Swagger UI
cd backend
cp .env.example .env
docker-compose up --buildSwagger: http://localhost:8080/swagger
Önkoşullar:
- .NET SDK 8
- Çalışan bir MongoDB (lokal veya Atlas)
Mongo bağlantısını environment’tan verebilirsin:
export Mongo__ConnectionString="mongodb://localhost:27017"
export Mongo__DatabaseName="etnaspace"Sonra API’yi çalıştır:
cd backend/src/EtnaSpace.Api
dotnet runbackend/.env içindeki değişkenleri kullanmak istersen (Atlas gibi), API başlangıcında .env dosyası otomatik yüklenir.
Örn:
cd backend
cp .env.example .env
cd src/EtnaSpace.Api
dotnet runNot: Uygulama açılışta migration runner (index) + seeder çalıştırır. Seeder’ı kapatmak için:
export Seed__Enabled="false"Her istekte X-Merchant-Id header zorunludur:
merchant-amerchant-bmerchant-c
Önkoşullar:
- .NET SDK 8
- Integration testler için Docker (opsiyonel)
Unit test + coverage (>= %80 line):
cd backend/src
dotnet test EtnaSpace.Tests.Unit/EtnaSpace.Tests.Unit.csproj -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Threshold=80 /p:ThresholdType=lineIntegration testler (Docker varsa çalışır, yoksa otomatik skip):
cd backend/src
dotnet test EtnaSpace.Tests.Integration/EtnaSpace.Tests.Integration.csproj -c ReleasePOST /api/products
Header:
X-Merchant-Id: merchant-a
Body:
{
"merchantId": "merchant-a",
"productName": "Bluetooth Kulaklık",
"category": "Elektronik",
"baseCost": 500
}Not: merchantId alanı body’de bulunsa da izolasyon için header esas alınır.
GET /api/products
Header:
X-Merchant-Id: merchant-a
GET /api/commissions/{category}
Örn: GET /api/commissions/Elektronik