Skip to content

gilberto-009199/desafio-anotai-backend-aws

 
 

Repository files navigation

desafio backend AnotaAi

Spring Boot

Docker

Swagger

MongoDB

AWS

S3 Bucket

SQS

Terraform

A proposta é construir uma API utilizando MongoDB, AWS S3 e AWS SQS para gerenciar um catálogo de produtos de um marketplace.

O sistema deve permitir o cadastro de produtos e categorias, cada um vinculado a um proprietário. Os usuários poderão criar, atualizar e excluir esses itens, além de associar produtos a categorias (lembrando que um produto só pode pertencer a uma categoria por vez). Todas as informações devem estar organizadas por proprietário, e a busca pelo catálogo não deve depender diretamente do banco de dados.

Install/Build :

# AWS credencial set Region, AWS_KEY_ID, AWS_SECRET
$ sed -i "s|spring.cloud.aws.region.static=.*|spring.cloud.aws.region.static=us-east-1|" desafio_backend/src/main/resources/application.properties
$ sed -i "s|spring.cloud.aws.credentials.access-key=.*|spring.cloud.aws.credentials.access-key=${AWS_KEY_ID}|" desafio_backend/src/main/resources/application.properties
$ sed -i "s|spring.cloud.aws.credentials.secret-key=.*|spring.cloud.aws.credentials.secret-key=${AWS_SECRET}|" desafio_backend/src/main/resources/application.properties

# Build .jar
$ chmod +x desafio_backend/mvnw clean package
$ cd desafio_backend
$ ./mvnw clean package
$ cd ..

# terraform create infra in aws

$ terraform plan
$ terraform apply

Use API :

# Catalog of s3 json's
$ curl -X GET  http://localhost:8080/

# Use /category

$ curl -X GET  http://localhost:8080/category
$ curl -X POST http://localhost:8080/category \
     -H "Content-Type: application/json" \
     -d '{
        "title": "Category Title",
        "description": "Category Description",
        "ownerId": "7464587"
    }'
$ curl -X PUT http://localhost:8080/category/67ea362a2389093dfc9d22bc \
     -H "Content-Type: application/json" \
     -d '{
        "title": "Category Title UpDate",
        "description": "Category Description UpDate",
        "ownerId": "7464587"
    }'
$ curl -X DELETE http://localhost:8080/category/67ea362a2389093dfc9d22bc

# Use /product

$ curl -X GET  http://localhost:8080/product
$ curl -X POST http://localhost:8080/product \
     -H "Content-Type: application/json" \
     -d '{
        "title": "titulo teste",
        "description": "descriptaçaot teste",
        "price": 1,
        "ownerId": "7464587"
    }'
$ curl -X PUT http://localhost:8080/product/67ea344a2389093dfc9d22b1 \
     -H "Content-Type: application/json" \
     -d '{
        "title": "titulo teste",
        "description": "descriptaçaot teste",
        "price": 1,
        "category":{
            "id": "67ea362a2389093dfc9d22bc"
        }
        "ownerId": "7464587"
    }'
$ curl -X DELETE http://localhost:8080/product/67ea344a2389093dfc9d22b1

Code/Architecture:

Swagger:

Swagger UI

Backend Analyst Candidate Test

Dear developer,

Welcome to the Backend Analyst Candidate Test. This test aims to assess your general knowledge and development speed. Below, you will find the details and requirements for this test.

The Challenge

Your task is to develop an API using Node.js for a product catalog management system in a marketplace application. You should analyze and convert the following user stories into routes for the application:

User Stories:

  • As a user, I want to register a product with its owner, so that I can access its data in the future (title, description, price, category, owner ID).

  • As a user, I want to register a category with its owner, so that I can access its data in the future (title, description, owner ID).

  • As a user, I want to associate a product with a category.

  • As a user, I want to update the data of a product or category.

  • As a user, I want to delete a product or category from my catalog.

  • A product can only be associated with one category at a time.

  • Assume that products and categories belong only to one owner.

  • Keep in mind that this is an online product catalog, which means there will be multiple requests for editing items/categories per second, as well as accessing the catalog search endpoint.

  • Consider the product catalog as a JSON compilation of all available categories and items owned by a user. This way, the catalog search endpoint does not need to fetch information from the database.

  • Whenever there is a change in the product catalog, publish this change to the "catalog-emit" topic in the AWS SQS service.

  • Implement a consumer that listens to catalog changes for a specific owner.

  • When the consumer receives a message, search the database for that owner's catalog, generate the catalog JSON, and publish it to an AWS S3 service bucket.

You need to develop this test using the following technologies:

  • MongoDB for the database.
  • AWS SQS for the catalog change notifications.
  • AWS S3 for storing the catalog JSON.
  • Node.js for the backend.
  • Express.js as the web framework.

Diagram representing the final structure of the project:

diagram with struture S3 SQS for catalog

Instructions

To begin the test, fork this repository, create a branch with your full name, and send us the link to your completed test (link to your repository). If you only clone the repository, you won't be able to push changes, making the pull request more complicated.

  • Use your own AWS account to set up the required services.
  • Update the README file with instructions on how to run your application.
  • Paste the branch name into the GUPY system and indicate the completion of the test.
  • Feel free to provide us with feedback regarding the test.

Our Evaluation Criteria We will assess the following aspects of your solution:

  • Knowledge of JavaScript, Node.js, and Express.js.
  • Proper structure of the application layers.
  • Handling of outgoing calls.
  • Effective use of environment variables.
  • Implementation of unit tests.
  • Logging mechanisms.
  • Error handling strategies.
  • Documentation quality.
  • Code organization, module separation, readability, and comments.
  • Commit history.

About

[OK] Spring Boot Backend AWS + MongoDB + SQS + S3

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 90.0%
  • HCL 9.7%
  • JavaScript 0.3%