The E-Commerce API is a backend solution for managing e-commerce operations like product management, category organization, and secure user authentication.
It is structured as a 3-Layered Architecture, inspired by Clean Architecture and Onion Architecture, ensuring high scalability, maintainability, and code reusability.
- Layered Design:
- API Layer: Handles HTTP requests and responses (Presentation Layer).
- Core Layer: Contains business logic, domain entities, and service interfaces.
- Infrastructure Layer: Manages data access, repositories, and external services.
- CQRS Pattern: Command-query separation for better readability and performance.
- Generic Repository: Reusable design for database operations.
- Pagination & Filtering: Efficient data retrieval with optional filters for name and price.
- Validation: Ensures input integrity with FluentValidation.
- API Documentation: Integrated with Swagger (JWT support included).
- JWT Authentication: Secures API endpoints.
- Role-Based Access Control: Restricts permissions based on roles.
- CORS Policy: Controlled cross-origin access.
- Image Handling: Supports image upload and management for products.
- Logging: Tracks application activity using Serilog (or any configured logger).
- Unit Testing: Reliable endpoint testing with XUnit.
- ASP.NET Core Web API
- Entity Framework Core
- JWT Authentication
- FluentValidation
- Swagger UI
- XUnit
- Serilog (or your preferred logging tool)
- Clone the repository:
git clone https://github.com/AdelMuhammad-23/ECommerceAPI.git cd ECommerceAPI - Configure database connection in
appsettings.json. - Apply database migrations:
dotnet ef database update
- Run the application:
dotnet run
- ECommerceAPI
- API (Presentation Layer: Controllers & Middleware)
- Core (Business Logic: Entities, DTOs, Interfaces)
- Infrastructure (Data Access: Repositories, Migrations)
- GET
/api/Categories/CategoryList
Retrieves paginated category list with optional filters. - GET
/api/Categories/Get-Category-By{id}
Fetches a specific category by ID. - POST
/api/Categories/Add-Category
Adds a new category. - PUT
/api/Categories/Update-Category
Updates an existing category. - DELETE
/api/Categories/Delete-Category-By{id}
Deletes a category by ID.
- GET
/api/Products/ProductList
Retrieves paginated product list with filters (name, price).
Example filter usage:{ "nameFilter": "phone", "priceFilter": 500 } - GET
/api/Products/Get-Product-By{id}
Retrieves product details by ID. - POST
/api/Products/AddProduct
Adds a new product with image upload. - PUT
/api/Products/Update-Product
Updates product details. - DELETE
/api/Products/Delete-Product-{id}
Deletes a product by ID.
- Integration with a payment gateway for secure transactions.
- Adding user-friendly dashboards for admin analytics.
- Real-time notifications for order updates.