The project is a robust, production-ready RESTful API designed for scalable e-commerce platforms.
Built with .NET 8 and PostgreSQL, this project demonstrates a clean Layered Architecture approach, separating concerns between data access, business logic, and API endpoints. It features a sophisticated authentication system utilizing JWT with Refresh Token Rotation for maximum security.
- Framework: ASP.NET Core 8 Web API
- Database: PostgreSQL
- ORM: Entity Framework Core (Code-First)
- Security: JWT (Access Tokens), HttpOnly Cookies (Refresh Tokens), BCrypt Hashing, RBAC, Firebase (Google OAuth)
- Cloud Storage: Cloudinary (Media management & automated image optimization)
- Testing: xUnit, Moq (Comprehensive Unit Testing)
- DevOps: GitHub Actions (CI/CD Pipeline), Docker (Multi-stage builds)
- Documentation: Swagger / OpenAPI
- Performance & Reliability: Rate Limiting, Manual DTO Mapping
- JWT Authentication: Implements a secure, stateless login flow.
- Refresh Token Rotation via HttpOnly Cookies: Prevents token theft (XSS attacks) by securely storing and rotating refresh tokens on every use, with automatic revocation of compromised chains.
- Token Blacklisting: Safely invalidates active access tokens upon user logout.
- RBAC Authorization: Distinct roles for Admins (Inventory/User mgmt) and Users (Shopping/Reviews).
- OAuth 2.0 Integration: Seamless "Login with Google" flow via Firebase Admin SDK, seamlessly bridging third-party authentication into the internal JWT ecosystem.
- Layered Design: Clear separation of Controllers, Services, and Repositories via Dependency Injection.
- Global Exception Handling & Logging: A dedicated Middleware catches unhandled exceptions, logs HTTP request/response metrics, and returns standardized error responses (400, 401, 404, 500) without exposing stack traces.
- API Rate Limiting: Protects public endpoints from brute-force and DDoS attacks.
- Optimized Queries: Strategic use of
AsNoTrackingfor read-heavy operations.
- Cloud Media Management: Integrated with Cloudinary to handle product image uploads, resizing, and fast CDN delivery.
- Smart Review System: Users can rate products (1-5), with database-level protection (Unique Index) preventing duplicate reviews.
- Inventory Management: Real-time stock updates upon purchase execution.
- Unit Testing: Critical business logic and service layers are heavily tested using xUnit and Moq, ensuring system stability and accurate dependency mocking.
- Continuous Integration (CI): Automated GitHub Actions pipeline that builds the project and executes xUnit test suites on every push to the
mainbranch. - Containerization: Optimized Multi-Stage
Dockerfileensuring consistent deployment across environments while minimizing the final image size and maintaining security standards (non-root execution).
To run this API locally:
- Clone the repo:
git clone [[https://github.com/OsherBerGit/E-Commerce-DotNet-API.git](https://github.com/OsherBerGit/E-Commerce-DotNet-API.git)]
- Configure Environment:
Update the
ConnectionStringsinappsettings.jsonwith your PostgreSQL credentials. You will also need to configure your Cloudinary keys and Firebase Service Account JSON for media and OAuth to work fully. - Apply Migrations:
dotnet ef database update
- Run the API:
dotnet run
- Explore:
Navigate to
https://localhost:5001/swaggerto test the endpoints interactively.
Note: This project serves as a comprehensive backend portfolio piece, focusing on Clean Architecture and security best practices.