How hieptrinh2002/pureclinic.backend works
Main Components
• API / Presentation Layer:
• Controllers (e.g., AccountController, AppointmentController, DoctorController, etc.)
• Action filters, Middleware (GlobalExceptionHandler, Logging, PermissionHandler)
• Extensions (e.g., mapping and security extensions)
• SignalR hubs for notifications (AppointmentHub, ChatHub, NotificationHub, etc.)
• Application / Business Layer:
• Business objects and view models (for appointments, doctors, users, etc.)
• Validators for input models
• Service interfaces (IAppointmentService, IAuthService, IDoctorService, etc.)
• Implementation of Business Logic encapsulated in Services (AuthService, AppointmentService, etc.)
• Mapper layer (MappingProfile)
• Domain / Core:
• Domain entities (Patient, Doctor, Appointment, Invoice, MedicalReport, etc.)
• Enumerations, Constants, Exceptions, and interfaces (for domain behavior)
• Core business logic and domain models
• Infrastructure Layer:
• Data Access:
• Persistence (ApplicationDbContext, EntityConfigurations, Repository implementations, UnitOfWork pattern)
• Seed data scripts and configurations
• External Services:
• Email and SMTP integrations
• File storage via Cloudinary
• Caching (MemoryCache & RedisCache)
• RabbitMQ integration for message-based background jobs (EmailProducer, FileProducer, RabbitMQ Connection, etc.)
• Background Job Processing:
• Background services (AppointmentReminderJob, DataCleanupJob, EmailConfirmationJob, ReportGenerationJob)
• Schedulers (RecurringJobScheduler, DelayedJobScheduler)
• SignalR for real-time notifications (HubConnectionService)
Relationships and Interactions
• The API layer receives HTTP requests and routes them to Controllers.
• Controllers invoke business services (e.g., AuthService, AppointmentService) which implement the core application logic.
• Business services in turn interact with repository interfaces in the Infrastructure layer via the Unit of Work to query or update the database.
• Caching services (both Memory and Redis) are incorporated to optimize performance.
• Background job components are scheduled via Hangfire (or equivalent scheduling logic) and use RabbitMQ to produce/consume messages.
• External services like Cloudinary and SMTP Email Services are called from within the Infrastructure services.
• Real-time communication with SignalR hubs allows updates to be pushed to connected clients (doctors, patients, etc.).
• Validators are used extensively in the API layer to ensure data integrity before processing.
Highlighted Architectural Patterns and Design Principles
• Clean Architecture: Clear separation into Core, Infrastructure, and API layers.
• Repository & Unit of Work: Abstract data access in a maintainable and testable manner.
• Domain-Driven Design: Use of rich domain models and business objects.
• Background Job Processing and Messaging: Integration of asynchronous tasks and RabbitMQ messaging for scalability.
• Caching Strategy: Combination of Memory Cache and Redis for optimized performance.
• Real-Time Communication: SignalR components for live notifications and interactions.
Instructing the Principal Software Engineer
– API Layer (Controllers, Filters, Middlewares, SignalR Hubs)
– Business/Application Layer (Services, Validators, Mappers)
– Domain/Core Layer (Entities, Business Models)
– Infrastructure (Database access, Repositories, External Services, Background Jobs, Caching, Messaging with RabbitMQ)
• Then, drill down into how each component interacts. For example:
• An HTTP request to /api/appointment triggers the AppointmentController, which calls AppointmentService.
• AppointmentService uses a repository (via the Unit of Work pattern) to interact with the database and might also trigger a background job for appointment reminders.
• The NotificationHub (via SignalR) is used to send real-time alerts.
• Separation of concerns, so each layer (presentation, business, data) is visually distinct.
• Use annotations to note integration details:
– “Cache: MemoryCacheService / RedisCacheService”
– “Background Jobs: Hangfire / Scheduler services”
– “External Services: Cloudinary, SMTP”.