How mdung0807/busticketbookingapi works
Project Type and Purpose
• This is a multi-module RESTful API project built using .NET (C#). It supports various business domains of a bus booking system such as authentication, address management, billing, bus and bus station management, company and customer management, payment via PayPal, and more.
• The README indicates that it’s designed to work with SQL Server (migrations, update-database) and has a step-by-step build process. It also references an external dataset (Vietnamese provinces), so integration with external data sources is part of its functionality.
Analyzing the File Structure
• The solution is spread over multiple projects, each handling a specific domain:
• Address management (BusBookTicket.AddressManagement)
• Application and shared services (BusBookTicket.Application, e.g., CloudImage, MailKet, Notification, OTP, PayPalPayment)
• Authentication (BusBookTicket.Auth)
• Billing (BusBookTicket.BillManage)
• Bus Station management (BusBookTicket.BusStationManage)
• Bus details including buses, bus types, seats, etc. (BusBookTicket.Buses)
• Company, Customer, Discount, Price, Ranks, Reviews, and Routes management
• Ticketing (BusBookTicket.Ticket)
• A common/core project (BusBookTicket.Core) encapsulates cross-cutting concerns: data models (entities), repositories, specifications, migrations, utilities, and infrastructure (e.g., Dapper context, unit of work).
• Each module contains directories for Controllers (web API endpoints), DTOs (data transfer objects), Services (business logic), Specifications (for filtering and validation), Validators, and sometimes repositories. This clearly follows an architectural separation (API layer, business logic, data access).
Key Architectural Components to Capture
a. Main Components:
• API Gateway/Controllers: Each module (Auth, Address, Bill, Bus, etc.) includes one or more controllers that expose RESTful endpoints.
• Service Layer: Business logic is encapsulated in separate service classes within each module (e.g., AuthService, BusService, TicketService).
• Domain/Core Layer: BusBookTicket.Core holds centralized domain models, repository interfaces, unit-of-work implementation, entity configurations, and migrations. This serves as the backbone for data persistence and business definitions.
• External Services: Integration components such as Cloud Image processing, Mail services (MailKet), Notification hub, OTP, and PayPal Payment.
• Database: The system uses SQL Server (as indicated by the migrations, update-database command, and SQL templates contained in SrcTemplate).
b. Relationships and Interactions:
• Controllers receive HTTP requests and call the respective service layer methods.
• Each service interacts with its domain repositories and uses the common specifications (from the Core) for data querying.
• Shared utilities and configurations (like JWT authentication in Auth, Mapping Profiles, Middleware, and exception handling) are applied across projects.
• The Core module is the central dependency that many modules use, ensuring consistency in model definitions and repository patterns.
• External API integrations (for example, PayPal Payment service and Cloud Image service) act as third-party integrations that are called from within application services.
c. Architectural Patterns:
• Separation of Concerns: Clear division into Controllers, Services, Repositories, and Domain models.
• Domain-Driven Design elements: Each domain (Auth, Bus, Ticket, etc.) is self-contained with its DTOs, validators, specifications, and business logic.
• Repository and Unit of Work patterns: These are implemented under BusBookTicket.Core.
• Use of External Middleware for cross-cutting concerns (exception handling, JWT authentication).
d. Relevant Technologies, Frameworks, and Libraries:
• .NET / C# for backend API development.
• Entity Framework (migrations and DbContext in BusBookTicket.Core) along with Dapper (given the presence of DapperContext) for data access.
• ASP.NET Core for building RESTful endpoints (Controllers, Middleware).
• Third-party integrations for Payment (PayPal), Mail services, and Cloud Image processing.
• Possibly SignalR (NotificationHub) for real-time notifications.
Putting It All Together
• Separate technical blocks for “External Services” (Cloud Image, Mail, Notification, OTP, PayPal) that are invoked by the respective modules.
• Incorporate middleware components like Authentication (JWT utilities) and Exception Middleware (global error handling) as cross-cutting concerns touching the API layer.