How tuthth/odtutor_be works
Project Type and Purpose
• This is clearly a backend application for an online tutoring system. Its primary purpose is to manage tutor and student accounts, handle bookings and scheduling, process payments (via VNPay), send notifications (via Firebase and mail), and integrate with external services like Google Calendar.
• The project is built as an ASP.NET Web API, organized into API controllers, a service layer, data models (using Entity Framework with migrations), and configuration/settings for external integrations.
File Structure
• The API folder contains the core presentation layer:
– API.csproj, Program.cs, and numerous controllers (such as AccountController, BookingController, TutorRegisterController, etc.) that handle HTTP requests.
• The Models directory holds all the domain entities, enumerables, mappings, migrations, and helper classes, which represent the data layer and database structure.
• The Services folder is organized into Interfaces and Implementations. This is the Business Logic Layer where domain-specific operations (e.g., booking, notifications, tutoring management) are performed.
• The Settings directory contains configurations for external services like Google Calendar, JWT for authentication, Mail settings, subscription settings, and VNPay for payment processing.
• Additional artifacts such as Dockerfiles, CI/CD configs (GitHub and GitLab), and a SQLScript folder indicate deployment and database provisioning tools.
Main Components
• API/Presentation Layer:
– API Controllers (Account, Admin, Booking, etc.) that expose endpoints.
• Service Layer:
– A collection of domain services (AccountService, BookingService, CourseService, NotificationService, etc.) that handle the core business logic.
• Data Layer:
– Models/Entities representing the database structure along with migration scripts that evolve the schema.
• External Integrations:
– Payment gateway via VNPay (settings and VNPayExample)
– Cloud messaging and realtime updates (FirebaseMessagingService, FirebaseRealtimeDatabaseService)
– Google Calendar integration (GoogleCalendarService)
– Email sending (MailService)
• Configuration/Settings:
– Settings for JWT, Mail, Subscription, and other integration points.
• Infrastructure/Deployment:
– Docker configuration files and CI/CD pipelines indicating containerization and automated deployment.
Relationships and Interactions
• The Service Layer contains logic that interacts with the Data Layer:
– Services use repositories or direct DbContext (represented by the Models, especially in the Entities folder) to read/write data.
• Services also integrate with external providers:
– For scheduling, the GoogleCalendarService might be called.
– For payments, VNPay functions are executed.
– For sending notifications, Firebase/Mail services are used.
– Data flow from the client → API Controllers → Services → Models/Database.
– Outbound calls from Services to external systems (e.g., Firebase, Google Calendar, VNPay).
Architectural Patterns and Design Principles
• Layered Architecture: Clear separation between presentation (API controllers), business logic (services), and data access (models).
• Dependency Inversion: Interfaces in the Services/Interfaces directory indicate that implementations can be swapped out or mocked.
• Micro-modularity: With numerous dedicated controllers and services, the system appears modular, which eases maintenance and scalability.
• Containerization: Dockerfile at both the API folder and project root signal that the deployment is containerized.