Git Product home page Git Product logo

howtobuildarobot's Introduction

Introduction

REST is a difficult topic. A lot of different opinions and misunderstandings. So I will add my own opinionated view and try to explain my reasons on the way. In this tutorial I will build a nice little REST API step by step.

Our domain will be a robot factory. It has several blueprints for robots and is capable of producing them also. But let's not spoil the surprise.

Architectural choices

HATEOAS, not a choice

REST demands that a RESTful API is navigatable. This means that basically you only know one URL and that's the entry to the API. Ever other URL is under the control of the server and will be provided. So no URL building by the client. See Roy Fielding's comment on this: REST APIs must be hypertext-driven

Actions, beyond CRUD

An API based on CRUD operations (create, read, update, delete ) provide a interface to data. Most of the time they are an interface to a database over HTTP. This is fine for several use cases.

This tutorial will aim for a different kind of API where we access the domain logic through REST. This enables us to use the API with different clients without duplicating domain logic code.

Siren as hypermedia format, because Actions

I will use the Siren hypermedia format. It supports Actions which are very useful to access available domain operations. Also Siren is quite clear and straight forward.

ProblemJson, there will be errors

It is very useful to have a fixed format for error reporting so clients will know what objects to expect if something goes wrong. See RFC7807 - Problem Details for HTTP APIs

Clean Architecture and DDD

The server application will be build following principles of Clean Architecture and Domain Driven Design. Both are very useful ideas and worth a lot of reading on their own.

Great reads:

Technical choices

  • C# ASP.NET Core for the server implementation.
  • Web API Hypermedia Extensions I am the maintainer of this project and it will do a lot of work for me. Basically it is a Siren formatter which also builds links so I don't have to.
  • Postman: super useful tool to talk to a HTTP API
  • HypermediaUi I am also the maintainer of this project. It is a generic Siren browser and convenient during development.
  • HTTP as the underling protocol, REST does not exclude other protocols at all.

Building a robot factory

During the tutorial we will build a ASP.NET Core application called RoboPlant. You can find the sources here: RoboPlant

howtobuildarobot's People

Contributors

mathiasreichardt avatar

Watchers

James Cloos 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.