Coder Social home page Coder Social logo

meysamhadeli / booking-microservices Goto Github PK

View Code? Open in Web Editor NEW
887.0 30.0 171.0 17.44 MB

Practical microservices, built with .Net 8, DDD, CQRS, Event Sourcing, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.

License: MIT License

Dockerfile 2.52% C# 95.53% Shell 0.06% JavaScript 1.89%
cqrs dotnet dotnetcore grpc masstransit microservices vertical-slice-architecture redis kubernetes clean-architecture

booking-microservices's Introduction

Hi there, I'm Meysam Hadeli πŸ‘‹

I am a software engineer with highly experience in designing and building distributed and scalable systems in .Net and Golang. Also, I am interested in learning about microservices and software architecture. In addition, I am an active open source developer and enjoy collaborating and sharing my knowledge in this community.

πŸ₯· Open Source Projects and Contributions

Professional skills

dotnet golang javascript typescript angular azure docker kubernetes postgres mongodb redis sqlserver rabbitmq kafka


Activities

booking-microservices's People

Contributors

amirhossein18121380 avatar bunkrur avatar dependabot[bot] avatar erjanmx avatar github-actions[bot] avatar meysamhadeli avatar timothymakkison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

booking-microservices's Issues

System.Security.Cryptography.CryptographicException

When i run the docker compose i get the error below

09:41:18 [INFO] Background worker stopped
2023-10-04 09:41:18 09:41:18 [INFO] Subscription to all '"default"'
2023-10-04 09:41:19 09:41:18 [EROR] Hosting failed to start
2023-10-04 09:41:19 System.Security.Cryptography.CryptographicException: The certificate data cannot
2023-10-04 09:41:19 be read with the provided password, the password may be incorrect.
2023-10-04 09:41:19 System.Security.Cryptography.CryptographicException: The certificate data
2023-10-04 09:41:19 cannot be read with the provided password, the password may be incorrect.
2023-10-04 09:41:19 at void System.Security.Cryptography.X509Certificates.UnixPkcs12Reader.
2023-10-04 09:41:19 VerifyAndDecrypt(ReadOnlySpan password, ReadOnlyMemory
2023-10-04 09:41:19 authSafeContents)
2023-10-04 09:41:19 at void System.Security.Cryptography.X509Certificates.UnixPkcs12Reader.
2023-10-04 09:41:19 Decrypt(SafePasswordHandle password, bool ephemeralSpecified)
2023-10-04 09:41:19 at void System.Security.Cryptography.X509Certificates.UnixPkcs12Reader.Decrypt
2023-10-04 09:41:19 (SafePasswordHandle password, bool ephemeralSpecified)
2023-10-04 09:17:21 Unhandled exception. System.Security.Cryptography.CryptographicException: The certificate data cannot be read with the provided password, the password may be incorrect.
2023-10-04 09:17:21 ---> System.Security.Cryptography.CryptographicException: The certificate data cannot be read with the provided password, the password may be incorrect.
2023-10-04 09:17:21 at System.Security.Cryptography.X509Certificates.UnixPkcs12Reader.VerifyAndDecrypt(ReadOnlySpan1 password, ReadOnlyMemory1 authSafeContents)

Save Problem

Brother,
I am facing a problem when saving data. Though I have commented savechanges method, data saves in database.
In my scenario on this table there is no domain events.
var newAircraft = await _flightDbContext.Aircraft.AddAsync(aircraftEntity, cancellationToken);
//await _flightDbContext.SaveChangesAsync(cancellationToken);

Helpful Features

It's Awesome project.
Thanks for making this repository.

I think if you add more feature that would be helpful, like

  1. Login , Authorization & Security.
  2. Complex query 2 or All microservices.
  3. Pagination.
  4. Audit Log
  5. SignalR

@ if you have any plan to add UI then Add React

Thanks.
May Allah live long

unauthorized exception

Hi I am trying to run this project on local machine using docker compose. The command fails with following message:

unauthorized: authentication required

this happens somewhere at pulling eventstore. I closed the terminal already, forgetting to copy the full log geenrated on running the command: docker-compose -f ./deployments/docker-compose/docker-compose.yaml up -d

I found this while digging out: EventStore/EventStore#2706

Any insights please?

Thanks

Use NewId or Ulid instead of Snowflake ID (IdGen)

Base on suggestion in PR #200

Add this feature in PR: #242

Ref:

IdGen

https://github.com/RobThree/IdGen

Ulid

https://github.com/Cysharp/Ulid

NewId

https://github.com/phatboyg/NewId

R&D:

IdGen is 64-bit (8 bytes) and Ulid, Ulid are 128-bit (16 bytes) Id's. Also, IdGen is long and Ulid, Ulid are uniqueidentifier, so we have better performance in the end with IdGen.

For getting a unique Id in all of distributed system is better we use NewId or Ulid. Because we always get a valid unique sequential Id in whole distributed system.

Note: We can handle it with IdGen for get unique Id in whole distributed system. But it's a little tricky and must find a good way to implement it to handle it to scale up in Kubernetes.

stored procs

Hi Guys
how would you execute a stored proc, can you please give a guide

Suggestions in .net7

Here are some suggestions from .net 7. Please take this as they are, suggestions, I'm not saying it's better or worse just some alternatives. Congratulations for this awesome sample!

  • Use TypedResults and Multiple Results.
  • In theory Hellang.Middleware.ProblemDetails is not needed anymore since the ProblemDetails are now easy configurable in .net 7
  • Is SnowFlakIdGenerator since MassTransit already uses NewId with same purposes?
  • Use required on props of records to simplify/omit some rules.
  • Question: Should booking service have any reference to a CurrentUser? Will this be called always in a context of a user?

Lately we've been merging the the request, validator, handler in the same class. Since adding or removing the request will almost always involve changing the validator. F12 (Go to definition is magical). We do not use any auto discovery plain old container registration so navigation and find usages work.

public static class Endpoint
{
    public static void MapRoute(IEndpointRouteBuilder route) => route.MapGet("/account/{id:int}", Handle);

    public record Request
    {
        public required int Id { get; init; }
    }

    public class Validator : AbstractValidator<Request>
    {
        public Validator() => RuleFor(x => x.Id).GreaterThan(2);
    }

    public record Response(string Desc);

    public static async Task<Results<Ok<Response>, NotFound>> Handle(
        [AsParameters] Request request,
        ILogger<Request> logger,
        ApiDbContext context,
        CancellationToken cancellationToken)
    {
        if (request.Id == 10)
        {
            return NotFound();
        }

        var entity = await context.Students.FirstOrDefaultAsync(cancellationToken: cancellationToken);

        return Ok(new Response($"everything went fine for: {request.Id}"));
    }
}

In case you want to do unit tests instead of acceptance tests of your endpoints you can inject Queries and Commands instead of db context so you can easily mock.
We've tried TestContainers with server instance per session and each tests gets a new database + migration. It takes 10 sec to start sql server (azure sql edge) and 4ms to create a random new db with 2 tables. Running an acceptance test which: 1. generates new db. 2. creates the tables. 3. starts the api with test server. 4. makes a http get 5. make a query in db. 5. returns response. Takes 1 sec on average. This way ALL tests are insolated and run in parallel (even in the same (implicit) collection).
I'm planning a PoC for TestContainers with RabbitMq where only one instance of rabbitmq is started for a test session (per assembly fixutre) and all tests will use a separate vhost.

We've also dropped MediatR since we have very few truly cross concerns for it's pipeline and the number of request.

  • OpenTelemetry adds logging to http and mass transit so tracebility is convered by that
  • Caching at the api level. Since queries/command are never re-used between features they are tailed for each feature need. We add caching explicitly in the handler.
  • Transactions when need are controlled at the handler level with transient dbcontext. A handler might create multiple transactions or call saves changes multiple times. In case of concurrency issues there are some chances to recover.
  • Validation happens at the api/endpoint level at least the shallow one anything more complicated is handled directly in the handler

The principles we've been guiding ourselves:

  • adhere to SOLID principles
  • everything is an http api. Even cron jobs, background daemons. Use health-checks and probes
  • vertical slices architecture
  • invest a lot in identifying the correct bounded context
  • duplication is far cheaper than wrong/premature abstractization
  • we do not write applications to have tests, we write tests to build reliable applications. Refactoring should be done no matter how many tests need to be changed. Corollary prefer bdd, acceptance, integration and e2e tests which test business requirements instead of unit tests, especially when the MS are very small. Do sprinkle unit tests when business logic is complex.
  • observability and traceability through OpenTelemetry are primordial
  • easy to onboard new developers by self browsing since technical documentation is almost never written/updated.
    • drive developers into the pit of success with composable extensions framework.
    • limit magic behaviors: auto mappers, auto registration reflection. Prefer source generators instead.
  • YAGNI
    • We will not swap databases without effort
    • We will not change transport protocols from grpc/http to anything else without effort
    • We will not switch from an http api to a console app or daemon service without effort.

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.