- Go 1.21
- Fiber router
- MongoDB noSQL database
- air for live reloading of the dev environment
- Docker and docker-compose
- Swagger for Docs generation
- Nginx for load balancing of the stress test
- Gatling stress test
Built for the friendly competition Rinha de Backend Q3 2023 by zanfranceschi, competition details (in portuguese) found here
- Clone the repo & cd into it
git clone git@github.com:albertofp/rinha-de-backend.git && cd rinha-de-backend
- Start the containers
docker compose up
API exposed at:
localhost:9999/
Docs at
localhost:9999/docs
To run the stress test, run make stress
Docs auto-generated by Swagger
1.0
Alberto F. Pluecker albertopluecker@gmail.com Github
- http
- application/json
- application/json
Method | URI | Name | Summary |
---|---|---|---|
GET | /contagem-pessoas | get contagem pessoas | Count total amount of people in the database |
Method | URI | Name | Summary |
---|---|---|---|
GET | /getall | get getall | Get every person in the database |
Method | URI | Name | Summary |
---|---|---|---|
GET | /pessoas | get pessoas | Search by term |
GET | /pessoas/{id} | get pessoas ID | Search person by ID |
POST | /pessoas | post pessoas | Create new person document |
Method | URI | Name | Summary |
---|---|---|---|
GET | /status | get status | Health check |
GET /contagem-pessoas
- application/json
Code | Status | Description | Has headers | Schema |
---|---|---|---|---|
200 | OK | OK | schema | |
500 | Internal Server Error | Internal Server Error | schema |
Status: OK
Status: Internal Server Error
GET /getall
Returns an empty array if no people found.
- application/json
Code | Status | Description | Has headers | Schema |
---|---|---|---|---|
200 | OK | OK | schema |
Status: OK
GET /pessoas
Search for a person in database by a given query string. Search term must not be empty
- application/json
Name | Source | Type | Go type | Separator | Required | Default | Description |
---|---|---|---|---|---|---|---|
t | query |
string | string |
Search term |
Code | Status | Description | Has headers | Schema |
---|---|---|---|---|
200 | OK | OK | schema | |
400 | Bad Request | Bad Request | schema | |
500 | Internal Server Error | Internal Server Error | schema |
Status: OK
Status: Bad Request
Status: Internal Server Error
GET /pessoas/{id}
Returns a person with the given id (UUID format)
- application/json
Name | Source | Type | Go type | Separator | Required | Default | Description |
---|---|---|---|---|---|---|---|
id | path |
string | string |
✓ | Person ID |
Code | Status | Description | Has headers | Schema |
---|---|---|---|---|
200 | OK | OK | schema | |
400 | Bad Request | Bad Request | schema | |
404 | Not Found | Not Found | schema | |
500 | Internal Server Error | Internal Server Error | schema |
Status: OK
Status: Bad Request
Status: Not Found
Status: Internal Server Error
GET /status
Code | Status | Description | Has headers | Schema |
---|---|---|---|---|
200 | OK | OK | schema |
Status: OK
[]string
POST /pessoas
Adds a person to the database. Returns an error if another person with the same value for the "apelido" field exists. Apelido and Nome have to be strings of length up to 32 and 100, respectively. Nascimento has to follow date format YYYY-MM-DD. Stack is optional, but each entry contained has to be a string of up to 32 chars in length.
- application/json
- application/json
Name | Source | Type | Go type | Separator | Required | Default | Description |
---|---|---|---|---|---|---|---|
request | body |
ModelsPersonCreateRequest | models.ModelsPersonCreateRequest |
✓ | Request body |
Code | Status | Description | Has headers | Schema |
---|---|---|---|---|
201 | Created | Created | schema | |
422 | Unprocessable Entity | Unprocessable Entity | schema | |
500 | Internal Server Error | Internal Server Error | schema |
Status: Created
Status: Unprocessable Entity
Status: Internal Server Error
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
count | integer | int64 |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
message | string | string |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
apelido | string | string |
||||
nascimento | string | string |
||||
nome | string | string |
||||
stack | []string | []string |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
id | string | string |
||||
message | string | string |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
apelido | string | string |
||||
id | string | string |
||||
nascimento | string | string |
||||
nome | string | string |
||||
stack | []string | []string |