Code Monkey home page Code Monkey logo

javacar's Introduction

This project is for test assignment for a mid-senior backend developer position.

The project consists of creating a backend application with 3 entities, Carro, Modelo and Marca (names in Portuguese because it is written like that in the modeling).

For the carros query route, it must return a custom json in this format (fully copied, maybe I change somethings... but same pattern!):

{
    "carros": [
        {
            "id": 1,
            "timestamp_cadastro": 1696539488,
            "modelo_id": 12,
            "ano": 2015,
            "combustivel": "FLEX",
            "num_portas": 4
            "cor": "BEGE",
            "nome_modelo": "ONIX PLUS",
            "valor": 50.000
        },
        {
            "id": 2,
            "timestamp_cadastro": 1696531234,
            "modelo_id": 14,
            "ano": 2014,
            "combustivel": "FLEX",
            "num_portas": 4
            "cor": "AZUL",
            "nome_modelo": "JETTA",
            "valor": 49.000
        },
        {
            "id": 3,
            "timestamp_cadastro": 16965354321,
            "modelo_id": 79,
            "ano": 1993,
            "combustivel": "DIESEL",
            "num_portas": 4
            "cor": "AZUL",
            "nome_modelo": "HILLUX SW4",
            "valor": 47.500
        }
    ]
}

In the other routes, as nothing was specified, I implemented it in the way I thought most appropriate.

In total, the application has 15 routes (5 for each entity)

GET hostname:port/api/carros/
GET hostname:port/api/carros/:id
POST hostname:port/api/carros/
PUT hostname:port/api/carros/:id
DELETE hostname:port/api/carros/:id

GET hostname:port/api/modelos/
GET hostname:port/api/models/:id
POST hostname:port/api/modelos/
PUT hostname:port/api/modelos/:id
DELETE hostname:port/api/modelos/:id

GET hostname:port/api/marcas/
GET hostname:port/api/marcas/:id
POST hostname:port/api/marcas/
PUT hostname:port/api/marcas/:id
DELETE hostname:port/api/marcas/:id

The routes are made to carry out CRUD operations, in common we have:

  1. Route to access all entity records
  2. Route to access a specific record
  3. Route to create a new record
  4. Route to change an existing record
  5. Route to delete an existing record

Things to note:

Expected JSON OBJECTS

When send to carros

Routes:

  1. POST hostname:port/api/carros/
  2. PUT hostname:port/api/carros/:id
{
  "modelo_id": INTEGER,
  "ano": INTEGER,
  "combustivel": STRING,
  "cor": STRING,
  "num_portas": INTEGER
}

When send to modelos

Routes:

  1. POST hostname:port/api/modelos/
  2. PUT hostname:port/api/modelos/:id
{
  "nome": STRING,
  "valor_fipe": INTEGER,
  "marca_id": INTEGER
}

When send to marcas

Routes:

  1. POST hostname:port/api/marcas/
  2. PUT hostname:port/api/marcas/:id
{
  "nome_marca": STRING
}

ROUTES ERRORS

The errors that the backend currently handles are:

Create

  1. POST hostname:port/api/carros/
  2. POST hostname:port/api/modelos/
  3. POST hostname:port/api/marcas/
  • Return 400 When: Client inserts a json that is invalid, informs that that object is invalid and cannot be created.

Read

All

There are 3 routes:

  1. GET hostname:port/api/carros/
  2. GET hostname:port/api/modelos/
  3. GET hostname:port/api/marcas/

In these 3 routes, no error is returned, if there is no record in the database, a 200 is returned with an empty object.

By id

  1. GET hostname:port/api/carros/:id
  2. GET hostname:port/api/models/:id
  3. GET hostname:port/api/marcas/:id
  • Return 404 When: A record with this id does not exist.

Update

  1. PUT hostname:port/api/carros/:id
  2. PUT hostname:port/api/modelos/:id
  3. PUT hostname:port/api/marcas/:id
  • Return 404 When: A record with this id does not exist.
  • Return 400 when: Client inserts a json that is invalid, informs that that object is invalid!

Delete

  1. DELETE hostname:port/api/carros/:id
  2. DELETE hostname:port/api/modelos/:id
  3. DELETE hostname:port/api/marcas/:id
  • Return 404 When: A record with this id does not exist.

javacar's People

Contributors

ur4n0-235 avatar

Watchers

 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.