Skip to content
Snippets Groups Projects
Solid-introduction.rst 7.35 KiB
Newer Older
Our SOLID introduction
======================
`SOLID <https://solid.mit.edu/>`__ is a project start in 2015 and lead
Alice Poggioli's avatar
Alice Poggioli committed
in the 3WC by `Tim Berners Lee <https://fr.wikipedia.org/wiki/Tim_Berners-Lee>`__, the inventor of
the web that aims to universalizes web API. He was upset that his warning about the future of the web
wasn’t heard and that’s why he propose a new way to build web
application that give power back to the final user.

Alice Poggioli's avatar
Alice Poggioli committed
SOLID project has inspired Startin’blox a lot.
Let's have an overview on how we implement `SOLID specifications <https://github.com/solid/solid-spec>`__.


.. warning::
   This page should be improve. Any feedbacks is sooo welcome :)
Our API
-------

Here is an example of our API :

.. code:: json

   {
       "@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 ?

.. code:: json

    {
       "@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 <https://fr.wikipedia.org/wiki/JSON-LD>`__

That’s mean that we encode `Linked
Data <https://en.wikipedia.org/wiki/Linked_data>`__ using Json.

JsonLD is an `RDF <https://en.wikipedia.org/wiki/RDF>`__ implementation,
which is its-selft the basic language of `semantic
web <https://en.wikipedia.org/wiki/Semantic_Web>`__.

This context allows you to link object properties in a JSON document to
concepts in an `ontology <https://en.wikipedia.org/wiki/Web_Ontology_Language>`__.

Here is the context referred :

.. code:: json

   {
     "@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 <http://xmlns.com/foaf/0.1/>`__, 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 :

.. code:: json

    {
        "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"
                    }
                }
            ]
        }
    }

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
----------
Alice Poggioli's avatar
Alice Poggioli committed
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.