Giter Site home page Giter Site logo

booking-hero's Introduction

hotel-booking

Hotel booking is a challenge to develop a booking api for the very last hotel.

Customer requirements

  • no downtime: 99.99 to 100% availability
  • Any stay can't be longer than 3 days and can't be reserved more than 30 days in advance
  • All reservations start at least the next day of booking
  • To simplify: DAY starts from 00:00 to 23:59:59
  • Every end-user can check the room availability, place a reservation, cancel it or modify it.
  • To simplify the API is insecure.

Architecture and Code Design

Even though the last available room presents a strong competition to be booked, we have to consider the project deadline. Maybe, the best architecture to be chosen is a microservice that includes besides an api gateway, an microservice queue manager, to delivery preference numbers for end-users guarantee their bookings and other microservices to allow scalate in any direction and improve the services availiability. It could be combined with a CQRS pattern taking the advantage from the best of SQL databases to write bookings and NOSql databases to read the booking availiability. Although it seems to be the best solution it wouldn't be possible to implement on the proposed time of the project. So, I chose a very simple architecture that represents a single API targeting a first delivery, like any agile project. To make it possible migrating the current project domain to a more appropriated architecture, I chose to follow some patterns:

Repository pattern

Although the project data access layer is using EF Core, the repository pattern brings more flexibility for testing and implement a CQRS architecture in a next version

Interactor / Clean Architecture / Commands

Implements for Clean Architecture takes some additional time, but it keeps the boundary clean and it will allow to separate our commands and queries in interactions throught commands.

Tech Stack

Front-end: no front end

Back-end: .NET 6, Sql Server

Frameworks, Packs and Libs

For the conclusion of this challenge it was used: ASPNEt Core, OpenAPI Doc (Swagger), Entity Framework Core and NUnit

Special thanks for DateOnlyTimeOnly.AspNet.Swashbuckle that adds support for recieving and returning DateOnly/TimeOnly as ISO 8601 string to ASP.NET API

Features

  • Room:
  • Creates a Room
  • List all rooms
  • Gets a Room
  • Reservation:
  • Availability Room
  • Gets reservation (by id or reservation code)
  • Reserve a Room
  • Change a reservation
  • Cancel a reservation

Run Requirements

  • .NET 6
  • SQL Server
  • Visual Studio 2022

Tests

There are 2 types of tests:

  • DbTests: tests repositories writing and reading
  • Use case tests: Tests use cases funcionality creating mocks for repositories

To run DbTests it's necessary to run migrations first:

Package Manager Console:

Update-Database

dotnet cli:

dotnet ef database update

For use case tests it's not necessary run migrations first.

Roadmap

Initializing the project

Just set BookingHero.Booking.API as startup project and run the migrations

If everything is well Visual Studio will open a new browser on API Swagger documentation page.

  1. Create a room: POST /api/v1/room
  2. Check room availability throught: GET /api/v1/reservation/{roomId}/availability
  3. If it's available, create a reservation: POST api/v1/reservation/{roomId}/reservation
  4. Get your reservation: 4.1. if you have the reservationId: /api/v1/reservation/{roomId}/reservation/{reservationId} 4.2. if you have the reservation code: /api/v1/reservation/{roomId}/reservation/code/{reservationCode}
  5. Change your reseravtion: PUT /api/v1/reservation/{roomId}/reservation/{reservationCode}
  6. Cancel your reservation: DELETE /api/v1/reservation/{roomId}/reservation/{reservationCode}

booking-hero's People

Contributors

felipebergmann avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.