Skip to content

Mercora is a modern e-commerce platform built with ASP.NET Core API designed with a focus on Clean Architecture.

Notifications You must be signed in to change notification settings

ahmedeldamity/OnionStore

Repository files navigation

πŸš€ Mercora

MicrosoftSQLServer .Net C# JSON Docker Redis Stripe

Mercora is a modern e-commerce platform built with ASP.NET Core API designed with a focus on Clean Architecture.

🐳 Docker Compose

This project utilizes Docker Compose to define and run a multi-container application consisting of:

  • Redis Caching: Provides caching capabilities to enhance performance.
  • SQL Server Database: Serves as the data storage for the application.
  • API: Hosts the application's backend logic and endpoints.

πŸ’Ž Prerequisites

πŸŽ‡ Setup and Configuration

1- Clone the Repository

git clone "https://github.com/ahmedeldamity/Mercora"
cd Mercora

2- Build and Start Containers

Use Docker Compose to build and start all containers defined in the docker-compose.yml file.

docker-compose up --build

This command will build the necessary images (if not already built) and start the containers as defined.

3- Access the Services

  • API: Access the API at http://localhost:8080.
  • SQL Server Database: Connect to the SQL Server using the connection string Server=store_database;Database=StoreDatabase;User Id=sa;Password=PAssWord**;.
  • Redis Caching: Redis can be accessed at redis://localhost:6379.

Persisting Data

Data for SQL Server and Redis is persisted using Docker volumes. Ensure that volumes are properly configured in docker-compose.yml to prevent data loss on container restarts.

Database ERD

The Entity-Relationship Diagram (ERD) for the SQL Server database is included below. This diagram illustrates the structure of the database, including tables, relationships, and key constraints.

image

βœ”οΈ Health Check

The application includes a unified health check endpoint to monitor the status of various system components:

  • SQL Server Database: Ensures the connection to the store database is healthy.
  • Redis Caching: Verifies the availability and functionality of the Redis caching system.
  • Hangfire Job Processing: Checks the status of Hangfire to ensure background jobs are being processed correctly.
  • Mail Service: Monitors the mail service to confirm that emails can be sent.

πŸ”„ API Versioning

API versioning is supported to ensure backward compatibility as the API evolves. Clients can specify the version via the URL path, query string, or request headers.

⏳ Rate Limiting

The API uses multiple rate limiting strategies to manage traffic:

  • Fixed Window: Limits requests within a defined time window.
  • Sliding Window: Allows a smoother request flow by checking limits within a moving time window.
  • Concurrency Limit: Restricts the number of concurrent requests being processed at the same time.

API Endpoints

Health Check :

Method Endpoint Description
GET /_health Returns the health status of the system.

Products:

Method Endpoint Description
GET /api/product Retrieve a list of products.
GET /api/product/{id} Retrieve details of a specific product.
POST /api/product Add a new product.
PUT /api/product/{id} Update product.
DELETE /api/product/{id} Delete a product.

Brands :

Method Endpoint Description
GET /api/brand Retrieve a list of brands.
GET /api/brand/{id} Retrieve details of a specific brand.
GET /api/brand/search Retrieve details of a specific brand.
POST /api/brand Add a new brand
PUT /api/brand/{id} Update brand.
DELETE /api/brand/{id} Delete a brand.

Categories :

Method Endpoint Description
GET /api/category Retrieve a list of categories.
GET /api/category/{id} Retrieve details of a specific category.
GET /api/category/search Retrieve details of a specific category.
POST /api/category Add a new category
PUT /api/category/{id} Update category.
DELETE /api/category/{id} Delete a category.

Delivery Methods :

Method Endpoint Description
GET /api/DeliveryMethod Retrieve a list of Delivery Methods.
GET /api/DeliveryMethod/{id} Retrieve details of a specific Delivery Method.
POST /api/DeliveryMethod Add a new Delivery Method
PUT /api/DeliveryMethod/{id} Update Delivery Method.
DELETE /api/DeliveryMethod/{id} Delete a Delivery Method.

Account :

Method Endpoint Description
Post /api/v1.0/Account/register Register a new user and receive a JWT token V-1.0
Post /api/v2.0/Account/register Register a new user and receive a JWT token V-2.0
Post /api/v2.1/Account/register Register a new user and receive a JWT token V-2.1
Post /api/v1.0/Account/login Authenticate a user and receive a JWT token V-1.0
Post /api/v2.0/Account/login Authenticate a user and receive a JWT token V-2.0
POST /api/v1/Account/google-login Authenticate a user and receive a JWT token.
GET /api/v1/Account Get Current User.
GET /api/v1/Account/refresh-token Get New Refresh Token.
Post /api/v1/Account/revoke-token Revoke Refresh Token.

Authentications :

Method Endpoint Description
Post /api/v1/Auth/send-email-verification-code Send Email Verification Code V-1.0
Post /api/v2/Auth/send-email-verification-code Send Email Verification Code V-2.0
Post /api/v1/Auth/verify-register-code Verify Register Code.
Post /api/v1/Auth/send-password-verification-code Send Password Reset Email V-1.0
Post /api/v2/Auth/send-password-verification-code Send Password Reset Email V-2.0
Post /api/v1/Auth/Verify-Reset-Code Verify Reset Code.
Post /api/v1/Auth/change-password Change Password.

Basket :

Method Endpoint Description
Post /api/Basket Create or Update Basket.
GET /api/Basket/{id} Retrieve the current user's basket.
DELETE /api/Basket/{id} Delete Basket.

Payment :

Method Endpoint Description
Post /api/Payment/{{basketId}} Create or Update Payment.

Order :

Method Endpoint Description
Post /api/Order Create Order.
GET /api/Order Get User Orders.
GET /api/Order/{{id}} Get Order By Id

βš” Stopping and Removing Containers

To stop and remove all running containers, use:

docker-compose down