Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Latest commit

 

History

History
138 lines (128 loc) · 4.76 KB

File metadata and controls

138 lines (128 loc) · 4.76 KB

Database Architecture

The Database uses MongoDB. The Database is called demnet.

The Database contains the following collections:

  1. elections, the collection of the Elections
  2. patches, the collection of the Patches Metadata.
  3. laws, the collection of the human readable Laws.
  4. users, the collection of the user's information and personal data.
  5. messages, the collection of the user's messages. Posts are a special kind of messages addressed to everybody and signed with only the public key of the author.

elections

A sample Election Document looks like this:

{ "proposals" : [<proposals>]
, "deadline" : [<deadline>]
, "closed" : <Bool: is Closed?>
, "winner" : <Winner Proposal>
, "type" : "<either machine or human>"
}

There can be two kinds of proposals: Human and Machine Executable Proposals. These derive from the two kinds of "laws" our network has: Human Executable and Machine Executable Laws. While Human Executable Laws are stored in the laws collection and can be downloaded as a Text Document, the Machine Executable Laws are the Git Repository and can be cloned, pushed, pulled and patched.

Any Election can only be held between proposals of the same kind. So nobody can vote between a human executable and machine executable law as two alternative proposals. All proposals in the proposals list are alternatives to each other.

Human Executable Proposals

These kinds of laws are stored in the laws collection. There they are subdivided into distinct groups called "books". A proposal can only amend, remove and add to a single book and an election about human executable laws can only have proposals for the same books.

{ "book" : "<book_id>"
, "title" : "<title>"
, "ammendments" : [ { "law" : "<law_title>"
                    , "paragraphs" :
                      [ "<§1 ammended>"
                      , "<§2 ammended>",
                      "<…>"]
                    }
                  ]
, "additions" : [ { "title" : <unique title in the book>
                  , "paragraphs" : [ <§1>, <§2>, …]
                  }
                ]
, "removals" : [ <law title> ]
}

machine executbale proposals

These are simpler in structure, because most of the data is present on disk in a Repository.

{ "patch_id" : "<hash field of the patch in demnet.patches" }

patches

A Patch is all the metadata about a patch, that has been or is still in process of being developed.

{ "patcher" : <patcher>
, "is_user" : <True if patcher is user of demnet>
, "name" : <name of the patch>
, "simple_description" : <simple description using simple language>
, "technical_description" : <detailed description of the patch>
, "hold_pre_election" : <True if the patcher wants to hold an election, before starting development>
, "references" : <Links relevant to the patch>
, "closed" : <True if the patch has been closed>
, "hash" : "<SHA256 of all the other fields>"
}

This Collection is soley managed by Patches.py

laws

Laws are subdivided into books of the same responsibility. A Law Document looks like this:

{ "book" : <book_id>
, "title" : <unique title in the book>
, "paragraphs" : [ <§1>, <§2>, …]
}

users

For every Registered user there is a private and public key. The private key is encrypted with each of the users three passwords. This makes it possible to use private keys with each of them

{ "public_key" : "<RSA Public Key>"
, "private_keys" : ["<Encrypted RSA Private Key>"]
, "passwords" : ["<passwords>"]
, "username" : "<unique username>"
, "first_name" : "<first real name>"
, "last_name" : "<last real name>"
, "expiration" : "<date of expiration of key pair>"
, "feed" : ["<hash of message where this user is either in the to or from part>"]
, "readings" : ["<hash of messages, that the user is reading>"]
, "writings" : ["<hash of messages, that the user is writing>"]
, "old_keys" : [{ "expiration" : "<unix timestamp of their expiration>"
                , "public_key" :"<old public key until the expiration>"
                , "private_key" : "<old, encrypted private key>"
                }]
}

messages

For now, there can be only one kind of messages: Public posts. These messages can be read and are addressed to anyone.

{ "from" : "<username of the author>"
, "to" : "all"
, "body" : { "title" : "<title of the post"
           , "content" : "<markdown content of the post."
         }
, "hash" : "<SHA256 of a dict of all the other fields in the message, used as unique and secure identifier>"
, "draft" : <true if message is a draft and not yet ready to be send.>
}

If in "to" there is "all" then the body isn't encrypted and everybody can read it, but only those users who are also in "to" get notification or something of the sort.