How phamminhkha0710/doanweb works
Main Components
a. Frontend Client:
• Views – Represented by Views folder and associated ViewModels, where UI is rendered (HTML, Razor pages).
• Static Assets – Represented by the wwwroot directory (CSS, JavaScript, Images, etc.).
• Client-side Libraries – Integration of Bootstrap, jQuery, Marked.js, PrismJS, and SignalR-related scripts.
b. Backend Server:
• Controllers – In the Controllers directory (including API sub-controllers) that receive HTTP requests, manage user actions (authentication, Q&A actions, repository management, etc.).
• Services – Encapsulated business logic in Services (e.g., AnswerService, BadgeService, NotificationService) that handle application-specific functionality.
• Repositories – Interfaces and concrete implementations (in the Repositories folder) to encapsulate data access, following the repository pattern.
• Models – Data and domain models (in the Models folder) representing entities like User, Question, Answer, Repository, Vote, etc.
• Database – Represented by Entity Framework Core migrations (Migrations folder) and the SQL Server backend configured via the appsettings.json.
• Extensions and Middleware – Application startup configurations and middleware components (Extensions and Middleware folders) that extend ASP.NET Core’s dependency injection and request pipeline.
c. Real-time & Communication Layer:
• Hubs – SignalR hubs (in the Hubs folder) for real-time features such as live notifications, chat, and activity updates.
d. External Integration Components:
• GitIntegration – Subsystem responsible for integrating Gitea for managing code repositories. This module communicates with the external Gitea API and handles tasks like user sync and repository mapping.
Relationships and Data Flow
• Clients (web browsers) interact with the system by making HTTP requests to the Controllers.
• Controllers pass requests through middleware pipelines, leveraging Filters (e.g., for user information) and Extensions (for dependency injection, database migrations, etc.).
• Controllers call Services to execute business logic. For example, a QuestionsController will call QuestionService to process question submissions.
• Services communicate with the Database through Repository patterns. For example, UserService uses UserRepository to manage persistence.
• Real-time communication is managed by SignalR Hubs that push notifications, update views, or relay chat messages to connected clients.
• The GitIntegration module interacts with Gitea’s API to sync repository information and manage source code operations.
• All components consume shared Models (domain data) and use ViewModels to format data for presentation.
Architectural Patterns and Key Design Principles
• MVC (Model-View-Controller) – Clearly separates presentation, application logic, and data.
• Dependency Injection – Framework extensions and service configurations are used extensively (see Extensions folder).
• Repository Pattern – Data access logic is abstracted via repository interfaces and implementations.
• Real-Time Eventing – SignalR is used to deliver real-time notifications, chat, and updates.
• Integration Layer – GitIntegration abstracts external API interactions with Gitea.
• Layered Architecture – Clean separation between the presentation layer, service layer, repository/data layer, and external services.
a. Client Layer:
• Inside, note “Razor Views, HTML, CSS, JavaScript (Bootstrap, jQuery, SignalR)”
b. Backend API & Logic Layer:
• “Models” as a shared entity across Services and Repositories.
c. Real-Time Communication:
d. External Integration:
e. Infrastructure Components:
Final Details and Labeling
• That each component is clearly labeled with its function.
• From Client → Controllers (HTTP Requests)
• From Controllers → Services (Business Logic Invocations)
• From Services → Repositories (Data Access Requests)
• Bi-directional for SignalR Hubs (showing real-time push/pull)
• From GitIntegration → Gitea API (external call)
• Notes where necessary to call out key technologies (ASP.NET Core 9.0, Entity Framework Core, SignalR, etc.) and design choices (Repository Pattern, Dependency Injection).