A robust, microservices-based ordering API built with .NET 8. Developed for OJT (On-the-Job Training), this project demonstrates scalable backend architecture, raw database operations, and secure authentication flows.
SimpleOrderingAPI is designed to handle the core functionalities of an e-commerce or ordering platform. Instead of relying on an ORM like Entity Framework Core, this project utilizes ADO.NET for highly optimized, raw SQL database interactions. It implements a microservices architecture routed through an API Gateway, ensuring that individual domains (Users, Products, Orders) remain decoupled and independently scalable.
- Microservices Architecture: Independent services handling distinct business domains.
- API Gateway: A single, unified entry point for all client requests, routing traffic to the appropriate downstream microservices.
- Raw Data Access: Direct and performant database operations using ADO.NET.
- Secure Authentication:
- JWT (JSON Web Tokens): For secure, stateless API authorization.
- Google OAuth 2.0: Integrated third-party authentication.
- API Versioning: Ensures backward compatibility for clients as the API evolves.
- Unit Testing: Comprehensive test coverage to ensure reliability across services.
The solution is divided into several focused projects:
ApiGateway: The central routing hub for incoming requests.UserService: Manages user profiles, registration, JWT generation, and Google OAuth 2 login flows.ProductService: Handles the product catalog, inventory status, and product management endpoints.OrderService: Manages cart operations, order placement, and payment/checkout processing.CryptService: A dedicated service for handling cryptographic operations, hashing, and encryption.OrderingAPI.Shared: A common class library containing shared DTOs, interfaces, and utility functions used across all microservices.OrderingAPI.Tests: The unit testing project ensuring the stability and correctness of the services.
- Framework: .NET 8 (C#)
- Data Access: ADO.NET
- Database: MySQL (via
sql_activities.sql) - Authentication: JWT Bearer Auth & Google OAuth 2.0 Identity
- Architecture: Microservices, API Gateway Pattern
- Testing: xUnit / Moq
- .NET 8 SDK
- MySQL Server
- A Google Cloud Console project (for OAuth 2.0 Client ID and Secret)
-
Clone the repository:
git clone [https://github.com/Jccqt/SimpleOrderingAPI.git](https://github.com/Jccqt/SimpleOrderingAPI.git) cd SimpleOrderingAPI -
Database Setup:
- Locate the
sql_activities.sqlfile in the root directory. - Execute this script in your MySQL instance to generate the necessary tables and schema.
- Locate the
-
Configuration:
- Navigate to the
appsettings.json(or use .NET User Secrets) in your respective services (UserService,ProductService,OrderService, etc.). - Update the configuration with your local database connection strings and security keys:
"ConnectionStrings": { "DefaultConnection": "Server=localhost;Database=YourDbName;User=root;Password=YourPassword;" }, "JwtSettings": { "Secret": "YOUR_SUPER_SECRET_JWT_KEY", "Issuer": "SimpleOrderingAPI", "Audience": "SimpleOrderingAPIClients" }, "Authentication": { "Google": { "ClientId": "YOUR_GOOGLE_CLIENT_ID", "ClientSecret": "YOUR_GOOGLE_CLIENT_SECRET" } }
- Navigate to the
-
Run the Application: Since this is a microservices architecture, you will need to start the
ApiGatewayalong with the necessary background services. You can configure multiple startup projects in Visual Studio (OrderingAPI.slnx) or run them via CLI:dotnet run --project OrderingAPI/ApiGateway/ApiGateway.csproj dotnet run --project OrderingAPI/UserService/UserService.csproj # Repeat for other essential services
To execute the unit tests and ensure everything is functioning correctly:
dotnet test OrderingAPI/OrderingAPI.Tests/OrderingAPI.Tests.csproj