How osama1010c/rentmateapi works
Project Type and Purpose
• This is an ASP .NET Core Web API (“RentMateAPI”) serving as the backend for a property-rental application.
• It exposes REST endpoints for user management, property listings, messaging, rental requests, saved posts, search, admin tasks, and real-time chat (via SignalR).
High-Level Layered Structure
• Presentation/API Layer
• Controllers (Controllers/)
• SignalR Hub (Hub/ChatHub.cs)
• Application/Business Layer
• Services (Services/Interfaces & Implementations)
• DTOs (DTOModels/)
• Data Access Layer
• Repositories (Repositories/Interfaces & Implementations)
• Unit of Work (UOF/)
• EF Core DbContext & Entities (Data/)
• Infrastructure/Cross-Cutting
• JWT Authentication Extension (Extensions/CustomJwtAuthExtention.cs)
• Dependency-Injection Extensions (Extensions/ServiceCollectionExtensions.cs)
• Configuration (appsettings*.json)
Main Components
A. External Clients
• Web App, Mobile App, Third-party services → consume REST endpoints and SignalR hub
B. API Gateway / HTTP Interface
• Kestrel/Web Host (Program.cs)
• Middleware pipeline (Auth, Logging, CORS, etc.)
C. Controllers & Hub
• Controllers/AdminController, UserController, PropertyController, etc.
• ChatHub for real-time messaging
D. Services
• Business-logic layer classes (IUserService, PropertyService, etc.)
• Accept DTOs, enforce validation/business rules
E. Repositories & UnitOfWork
• Generic IRepository<T> + concrete Repository<T>
• UnitOfWork committing transactions across multiple repositories
F. EF Core & Database
• AppDbContext exposing DbSets for Models/Entities
• Underlying SQL Server (or other RDBMS)
Relationships and Data-Flow
• Controller methods call into Service interfaces → implement business logic → call into UnitOfWork or Repository methods
• Repositories use AppDbContext to query/persist Data/Models → Database
• SignalR Hub sits at the API boundary: clients open WebSocket connections → ChatHub → inject IMessageService → persists messages
• DTOModels sit between Controller and Service layers; Data/Models sit between Repository and DbContext
Architectural Patterns & Design Principles
• Layered (N-Tier) architecture separating concerns
• Dependency Injection for Controllers, Services, Repositories, DbContext
• Repository + Unit of Work for atomic DB operations
• DTO pattern to decouple domain models from API contracts
• SignalR for real-time communication
• Extension methods to register services and authentication schemes