Giter Site home page Giter Site logo

marcoscostadev / minimal-api-docker-tdd Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 4.0 578 KB

This project is a participant in the first Rinha de Backend competition. Please note that this code is not intended for production use; it has been highly optimized for the competition. It has employed the best techniques to handle 3K to 7K records per second using two instances of a web app, database, cache with only 3GB of RAM and 1 unit of CPU.

Home Page: https://github.com/zanfranceschi/rinha-de-backend-2023-q3

License: MIT License

C# 94.89% Dockerfile 2.37% PLpgSQL 2.42% Shell 0.32%
rinha-de-backend

minimal-api-docker-tdd's Introduction

Minimal API with Docker and TDD

Github: @MarcosCostaDev | Twitter/X: @MarcosCostaDev

Project Url https://github.com/MarcosCostaDev/minimal-api-docker-TDD

Technologies

  • CSharp (C#)
  • .NET Core (.NET 7)
  • Swagger
  • xUnit (Test framework)
  • Docker / Docker compose (container orchestrator)
  • Redis (Distributed Cache)
  • Nginx (Load balancer)
  • Postgres (Database)

Requirements

How to run

  • Open the ./src folder
  • Open a terminal / bash and execute docker-compose up
  • API will be available in the URL http://localhost:9999
  • Swagger will be available in the URL http://localhost:9999/swagger
  • API Endpoints available
    • GET /ping health check, return pong if the API is up.
    • POST /pessoas for creating a record in the table People using the format message below
      {
          "apelido" : "josé 12",
          "nome" : "José Roberto",
          "nascimento" : "2012-03-08T00:00:00",
          "stack" : ["C#", "Node", "Oracle"]
      }
    • GET /pessoas/[id] for retrieving a record of a person created using replacing [id] with the person id.
    • GET /pessoas/t=[your search] for retrieving records that contain the words informed, replace [your search] with your actual search.
    • GET /contagem-pessoas for retrieving the number of people created.

Learn more

Running on Visual Studio

The project originally was created using Visual Studio 2022 Community Edition, but you can download its most recent version and you need to download the Visual Studio Container tools for executing the project.

xUnit and integration tests

The integration test runs on docker containers that simulate this project in "Production".

Stress Test with the Postman

After you execute the application using Docker-compose up or run it using Visual Studio. You will be able to execute the stress tests for this API using Postman.

  1. Download Postman and install it.
  2. Go to import collection and select the file ./test/stress/RinhaBackEnd.postman_collection.json
  3. After importing the collection to the postman, right-click on the "RinhaBackEnd" collection, and select Run Collection, the Runner Window will be shown.
  4. Right side, adjust the order of execution: place the POST /pessoas above the GET /pessoas/:id this will avoid trying to get a person that does not exist.
  5. Left side of the Runner window, select performance, and use the configuration you want.
  6. Click on run.

minimal-api-docker-tdd's People

Contributors

marcoscostadev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.