https://github.com/hvaezapp/zitro-shop
modular e-commerce API built with .NET 9. The project follows a Modular Monolith architecture.
https://github.com/hvaezapp/zitro-shop
csharp docker dotnetcore fluentvalidation modular-monolith rabbitmq redis sqlserver
Last synced: 3 months ago
JSON representation
modular e-commerce API built with .NET 9. The project follows a Modular Monolith architecture.
- Host: GitHub
- URL: https://github.com/hvaezapp/zitro-shop
- Owner: hvaezapp
- License: mit
- Created: 2025-12-16T15:13:27.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-18T09:50:39.000Z (6 months ago)
- Last Synced: 2025-12-21T06:50:32.566Z (6 months ago)
- Topics: csharp, docker, dotnetcore, fluentvalidation, modular-monolith, rabbitmq, redis, sqlserver
- Language: C#
- Homepage:
- Size: 154 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ZitroShop
ZitroShop is a modern, modular e-commerce API built with .NET 9. The project follows a **Modular Monolith** architecture, ensuring clear separation of concerns between different business domains such as Products, Basket, and Payments.
## 🚀 Tech Stack
- **Framework:** .NET 9
- **Database:** SQL Server (EF Core)
- **Caching & Locking:** Redis
- **Message Broker:** RabbitMQ
- **API Documentation:** Scalar (Modern Swagger alternative)
- **Validation:** FluentValidation
## 🏗 Project Structure
The solution is divided into several modules:
- **ZitroShop.Api:** The entry point and API layer.
- **ZitroShop.Modules:** Contains independent business modules:
- **ProductModule:** Product catalog and management.
- **BasketModule:** Shopping basket logic using Redis for persistence and locking.
- **PaymentModule:** Payment processing and status tracking.
- **ZitroShop.Shared:** Shared infrastructure, base classes, and utilities.
## 🛠 Getting Started
### 1. Prerequisites
- [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0)
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
- [SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)
### 2. Infrastructure Setup
Run the following command to start Redis and RabbitMQ containers:
```bash
docker compose up -d
```
### 3. Database Configuration
Update the connection string in `src/ZitroShop.Api/appsettings.Development.json` if your SQL Server instance differs from the default:
```json
"ConnectionStrings": {
"SvcDbContext": "data source=.;initial catalog=ZitroShopDB;TrustServerCertificate=True;Trusted_Connection=True;"
}
```
Then, apply the migrations to create the database:
```bash
dotnet ef database update --project src/ZitroShop.Modules --startup-project src/ZitroShop.Api
```
### 4. Running the Project
```bash
dotnet run --project src/ZitroShop.Api
```
The API will be available at `http://localhost:5128`.
### 5. API Documentation
Once the app is running, you can explore the interactive API documentation at:
- **Scalar:** `http://localhost:5128/scalar/v1`
---
## 📡 API Examples
### 📦 Products
#### Get All Products
Retrieves a list of all available products.
- **URL:** `/products`
- **Method:** `GET`
- **Example Request:**
```bash
curl -X GET http://localhost:5128/products
```
### 🛒 Basket
#### Add Product to Basket
Adds a specific product to a user's basket.
- **URL:** `/basket/add`
- **Method:** `POST`
- **Payload:**
```json
{
"userId": 1,
"productId": 1
}
```
- **Example Request:**
```bash
curl -X POST http://localhost:5128/basket/add \
-H "Content-Type: application/json" \
-d '{"userId": 1, "productId": 1}'
```
### 💳 Payment
#### Start Payment Process
Initiates a payment for the items in the user's basket.
- **URL:** `/payment/start`
- **Method:** `POST`
- **Payload:**
```json
{
"userId": 1
}
```
- **Example Request:**
```bash
curl -X POST http://localhost:5128/payment/start \
-H "Content-Type: application/json" \
-d '{"userId": 1}'
```
#### Check Payment Status
Retrieves the current status of a payment.
- **URL:** `/payment/{paymentId}`
- **Method:** `GET`
- **Example Request:**
```bash
curl -X GET http://localhost:5128/payment/1
```
---
