Skip to content

Latest commit

 

History

History
153 lines (114 loc) · 6.62 KB

File metadata and controls

153 lines (114 loc) · 6.62 KB

Travel and Accommodation Booking Platform

.NET and Docker

Overview

This is an ASP.NET Core API project for an advanced online hotel booking system. Which includes the Login Page, Home Page, Search Results, Hotel Details, Secure Checkout, and Admin Management.

Table of Contents

  1. Overview
  2. Project Requirements
  3. Domain Models
  4. Project Architecture
    1. Structure & Dependencies
    2. Presentation Layer
    3. Application Layer
    4. Domain Layer
    5. Persistence Layer
    6. Infrastructure Layer
    7. Request Flow
  5. Getting Started
    1. Setup
    2. Running
    3. Postman Collection

Project Requirements

To understand the project requirements in detail, please refer to the Project Requirements documentation.

Domain Models

The domain models used in this project were derived from the project requirements to reflect the business logic accurately. To view the detailed domain models, please refer to the Domain Models documentation. Here is a class diagram for the domain models of the project:

DrawSQL-ClassDiagram

Project Architecture

This project is designed using the Clean Architecture. Here is an overview of the architecture of the project:

Excalidraw-ComponentDiagram

Excalidraw Link

Structure & Dependencies

  • The App project serves as the entry point of the application and is responsible for configuring all the necessary services, dependency injections, and application settings. It depends on all projects and that's why it was separated from the Presentation layer.
  • The Application Layer is the core of the system and does not depend on any other layers. It contains the business logic, commands, queries, and validation logic that drive the system.
  • The Presentation, Persistence, and Infrastructure layers are structured to depend only on the Application layer and never on each other. This isolation ensures that changes in one layer (e.g., switching the database in the Persistence layer or changing the UI framework in the Presentation layer) do not affect the others.

Presentation Layer

  • Controllers: All endpoints should be defined here.
  • Filters: All filters should be defined here, including swagger filters.
  • ViewModels: Application response objects should be mapped to ViewModels when complex UI model is required.
  • Requests: Complex application request objects can be created and mapped from Requests objects.

Application Layer

  • Commands: All business logic commands.
  • Queries: All business logic queries.
  • Responses: Models that are returned from Command & Query Handlers.
  • Command Handlers: Orchestrate command logic, including error handling and calling repositories or services.
  • Query Handlers: Orchestrate query logic, including error handling and calling specifications and repositories.
  • Validators: Fluent validators that ensures Commands & Queries always receive valid requests.
  • Specifications: Adralis Specifications which are fine-grained query logic pieces sent to generic repositories.

Domain Layer

  • Entities: Core objects of the system representing the main business concepts.
  • Value Objects: Objects with unique attributes structure but do not have unique identity. They are part of other domain entities.
  • Rules: Domain rules have general constants which application services and entity configurations in persistence layer should follow.
  • Result: A unified result object which all services and request handlers should return.
  • Errors: Domain error constants which application services and handlers can return for failure results.

Persistence Layer

  • Entity Configurations: How entities are mapped to database schema. Defined by EF Core.
  • Migrations: All migrations should be in the persistence layer.
  • EF Core Repositories: Generic repositories that take specifications and perform simple functions using DbContext.

Infrastructure Layer

  • Auth Services: Authentication related services should be in the infrastructure.
  • Cloudinary Image Storage: Application Image Storage is implemented with Cloudinary in the Infrastructure.

Request Flow

  • The following diagram illustrates the flow of a request through the system. It shows how a user's request is filtered, validated, and processed by the application, eventually retrieving data from the repositories.
  • A request can be a Query or a Command.
  • Queries are typically handled by sending a specification to a query repository which returns the required DTO that is mapped and sent to the user.
  • Commands are typically handled by performing integrity checks, then calling specific CUD repository methods, and finally committing changes.

Request Flow

Excalidraw Link

Getting Started

Setup

Before running the project, you need to configure the application settings. Add the following appsettings.json in the TravelAccommodationBookingPlatform.App project: (You can find these values in the Jira project site)

{
  "CloudinarySettings": {
    "CloudName": "...",
    "ApiKey": "...",
    "ApiSecret": "..."
  },
  "SmtpSettings": {
    "Host": "...",
    "Port": "...",
    "Username": "...",
    "Password": "...",
    "From": "..."
  }
}

Running

The project uses docker-compose which includes a SQL Server image, so no need to install it locally. Use the following command to run docker-compose:

docker-compose up

Postman Collection

  1. Import into Postman: Json file is located at postman_collection.json
  2. Configure Environment Variables:
    • baseURL: For example to localhost:8080
    • bearerToken: Generate it from users/token endpoint. Use the user or admin examples as you need.