Our SOLID introduction

SOLID is a project start in 2015 and lead in the 3WC by Tim Berners Lee, the inventor of the web that aims to rethink the way we build application in order to give back the power back to the final user.

For us SOLID project is above all a philosophy, a goal to reach and which inspires us.

Let’s have an overview on how we implement SOLID specifications.

Warning

This page should be improve. Any feedbacks is welcome

Our API

Here is an example of our API :

{
    "@id": "https://api.alpha.happy-dev.fr/users/alice/",
    "first_name": "Alice",
    "last_name": "Poggioli",
    "username": "alice",
    "email": "alice.poggioli@paca.happy-dev.fr",
    "account": {
        "@id": "https://api.alpha.happy-dev.fr/accounts/alice/"
    },
    "name": "Alice Poggioli",
    "profile": {
        "@id": "https://api.alpha.happy-dev.fr/profiles/alice/"
    },
    "circles": {
        "@id": "https://api.alpha.happy-dev.fr/users/alice/circles/",
        "@type": "ldp:Container",
        "ldp:contains": [
            {
                "@id": "https://api.alpha.happy-dev.fr/circle-members/23/"
            },
            {
                "@id": "https://api.alpha.happy-dev.fr/circle-members/54/"
            },
            {
                "@id": "https://api.alpha.happy-dev.fr/circle-members/656/"
            }
        ],
        "permissions": [
            {
                "mode": {
                    "@type": "add"
                }
            },
            {
                "mode": {
                    "@type": "view"
                }
            }
        ]
    },
    "@type": "foaf:user",
    "@context": [
        "https://cdn.happy-dev.fr/owl/hdcontext.jsonld",
        {
            "get_full_name": "rdfs:label"
        }
    ],
}

Looks like a simple JSON but it’s more

Did you notice the presence of a context ?

{
   "@type": "foaf:user",
   "@context": [
       "https://cdn.happy-dev.fr/owl/hdcontext.jsonld",
       {
           "get_full_name": "rdfs:label"
       }
   ]
}

It is a way to go from the Json to JsonLD

That’s mean that we encode Linked Data using Json.

JsonLD is an RDF implementation, which is its-selft the basic language of semantic web.

This context allows you to link object properties in a JSON document to concepts in an ontology.

Here is the context referred :

{
  "@context": {
    "@vocab": "http://happy-dev.fr/owl/#",
    "foaf": "http://xmlns.com/foaf/0.1/",
    "doap": "http://usefulinc.com/ns/doap#",
    "ldp": "http://www.w3.org/ns/ldp#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "geo": "http://www.w3.org/2003/01/geo/wgs84_pos#",
    "acl": "http://www.w3.org/ns/auth/acl#",
    "name": "rdfs:label",
    "deadline": "xsd:dateTime",
    "lat": "geo:lat",
    "lng": "geo:long",
    "jabberID": "foaf:jabberID",
    "permissions": "acl:accessControl",
    "mode": "acl:mode",
    "view": "acl:Read",
    "change": "acl:Write",
    "add": "acl:Append",
    "delete": "acl:Delete",
    "control": "acl:Control"
  }
}

The type we use is foaf. That means that we use the FOAF ontology which is done to describe people.

If you go to the foaf ontology, you’ll see that the properties which we can use are :

account | accountName | accountServiceHomepage | age | aimChatID | based_near | birthday | currentProject | depiction | depicts | dnaChecksum | familyName | family_name | firstName | focus | fundedBy | geekcode | gender | givenName | givenname | holdsAccount | homepage | icqChatID | img | interest | isPrimaryTopicOf | jabberID | knows | lastName | logo | made | maker | mbox | mbox_sha1sum | member | membershipClass | msnChatID | myersBriggs | name | nick | openid | page | pastProject | phone | plan | primaryTopic | publications | schoolHomepage | sha1 | skypeID | status | surname | theme | thumbnail | tipjar | title | topic | topic_interest | weblog | workInfoHomepage | workplaceHomepage | yahooChatID |

Now we can describe a user for every machines in the world using a universal language :)

Why JsonLD is awesome ?

A document structured in RDF is a set of triplets.

An RDF triplet is an association (subject, predicate, object) :

  • the “subject” represents the resource to be described;

  • the “predicate” represents a type of property applicable to this resource;

  • the “object” represents a data or another resource: it is the value of the property.

But in today life, we use to structure datas in in a file, directory, inventory logic and not in linked triplets. It’s quickly a mess to apprehend.

JsonLD allow us to us Linked Datas in a very intuitive way.

Let’s speak about containers

So how JsonLD manage to tiny the datas ?

Let’s have a look on this part :

{
"@id": "https://api.community.startinblox.com/users/alice/circles/",
"@type": "ldp:Container",
"ldp:contains": [
    {
        "@id": "https://api.community.startinblox.com/circle-members/1/",
        "is_admin": true,
        "circle": {
            "@id": "https://api.community.startinblox.com/circles/1/"
        },
        "@type": "hd:circlemember",
        "permissions": [
            {
                "mode": {
                    "@type": "view"
                }
            },
            {
                "mode": {
                    "@type": "delete"
                }
            }
        ]
    },
    {
        "@id": "https://api.community.startinblox.com/circle-members/2/",
        "is_admin": true,
        "circle": {
            "@id": "https://api.community.startinblox.com/circles/2/"
        },
        "@type": "hd:circlemember",
        "permissions": [
            {
                "mode": {
                    "@type": "view"
                }
            },
            {
                "mode": {
                    "@type": "delete"
                }
            }
        ]
    },
    {
        "@id": "https://api.community.startinblox.com/circle-members/3/",
        "is_admin": true,
        "circle": {
            "@id": "https://api.community.startinblox.com/circles/3/"
        },
        "@type": "hd:circlemember",
        "permissions": [
            {
                "mode": {
                    "@type": "view"
                }
            },
            {
                "mode": {
                    "@type": "delete"
                }
            }
        ]
    },
    {
        "@id": "https://api.community.startinblox.com/circle-members/4/",
        "is_admin": true,
        "circle": {
            "@id": "https://api.community.startinblox.com/circles/4/"
        },
        "@type": "hd:circlemember",
        "permissions": [
            {
                "mode": {
                    "@type": "view"
                }
            },
            {
                "mode": {
                    "@type": "delete"
                }
            }
        ]
    }
],
"permissions": [
    {
        "mode": {
            "@type": "add"
        }
    },
    {
        "mode": {
            "@type": "view"
        }
    }
],
"@context": "https://cdn.happy-dev.fr/owl/hdcontext.jsonld"
}

In web semantic language, that’s mean :

The resource pointed by the uri “https://api.alpha.happy-dev.fr/users/alice/circles/” virtually contains thoses resources.

With this trick, we stay in a semantic logic with a directory and file structuring management.

LDP allows us to bridge the gap between the semantic esoteric world and web api’s that are not semantic. The magic is that turning your api into ldp is very simple. You just have to add the contexts :)

Conclusion

Solid specifications are still being written today. Startin’blox contributes to their elaboration and tries to make their use accessible to the greatest number with the minimum of technical competence.

The accessibility of these technologies is for us a major issue in the future of a more open, more egalitarian and more respectful of end users.