Giter VIP home page Giter VIP logo

cloud-humans-assignment's Introduction

Cloud Humans - Backend Take Home Assignment

This repository contains a backend take-home assignment made for Cloud Humans.

The application is a simple API built with NestJS, which has a single API endpoint that receives a JSON payload with the Pro application data and returns a JSON response with the selected project.

Installation

    # Clone the repository
    $ git clone https://github.com/rogerlenhart/cloud-humans-assignment.git

    # Access the project folder
    $ cd cloud-humans-assignment

    # Install dependencies
    $ npm install

There is a insomnia-collection.json file at the root directory, which contais example requests for testing.

Running the app

Development

  $ npm run dev

Server will start on http://localhost:3000

Production

  $ docker-compose up

Server will start on http://localhost:3000

Tests

  $ npm run test

Technical Decisions

Technologies

  • Node.js: it's a lightweight, fast and flexible technology, making it a good choice for building simple web applications like this one.
  • Typescript: with explicit type annotations, code becomes easier to understand and maintain.
  • NestJs: while remaining lightweight, this framework offers a more modular and scalable approach, providing greater extensibility to the application.

Architecture

The application was built based on Clean Architecture principles, mainly regarding the separation of software into layers, which is reflected in the folder structure.

src
  - domain
    - entities
  • domain: is the core of the application.
  • entities: represent the core concepts and rules of the application.
src
  - application
    - repositories
    - use-cases
  • application: layer that implements use cases and interacts with diferent services.
  • repositories: contains the abstract repositories.
  • use-cases: classes that use domain knowledge to achieve specific goals.
src
  - infrastructure
    - database
      - repositories
    - http
      - controllers
      - dtos
      - view-models
  • infrastructure: contains code that is highly coupled with the framework.
  • repositories: contains the implementations of the repositories.
  • controllers: manages routes, http requests and responses.
  • dtos: objects that represent the request of controllers, with specific validation rules.
  • view-models: responsible for mapping entities to http responses.

Database

Due to the small scope of the application, I decided that a database would not be necessary. Despite that, classes were mostly written to depend on interfaces instead of actual implementations, so that business rules are independent of database. This approach also makes it easier to integrate with databases in the future.

Unit Tests

NestJS relies on the Jest testing framework, which offers various useful features for test creation. One such feature is parameterized tests, that enables us to execute a single test method multiple times with different parameters. This way, it becomes much more practical to test the various possibilities that the scoring system of this application has.

I focused on testing the entities and their business logic, in particular the scoring calculation methods, to ensure that the requirements were met. I also made some tests for the pro applications Controller and Use Case using a in-memory implementation of the repository class.

cloud-humans-assignment's People

Contributors

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