pinnackl / ambitionetreussite

Web application de l'association de Ambition & Réussite.
Apache License 2.0
1 stars 0 forks source link

[feature] Design database architecture #2

Open syu93 opened 7 years ago

syu93 commented 7 years ago

Design the database architecture.

Inspire from wordpress without all the complexity:

https://codex.wordpress.org/images/2/25/WP4.4.2-ERD.png

Prefixed with : ar_

syu93 commented 7 years ago

https://drive.google.com/open?id=1pIOvQ3SV3sLeyAFkduI-v5T6niMwkYuUQqrQ-WTpyMM

syu93 commented 7 years ago

A the we will use the firebase service

syu93 commented 7 years ago

How to structure data https://firebase.google.com/docs/database/web/structure-data

How to secure data https://firebase.google.com/docs/storage/security/start

syu93 commented 7 years ago

@berrabahs

I've worked a way to create a role system to protect data.

Here is a great example :

https://github.com/firebase/firechat/blob/master/rules.json

here is some samle i've created to show you the way

// Rules
{
  "rules": {
    // Read is forbiden for all by default
    ".read": false,
    ".write": false,
    "users": {
      "$users": {
        "basicInfo": {
          // To read besic info the user must be authenticated
          ".read": "(auth != null)",
          // The write here the user must be the user itself or either a moderator or an administrator
          ".write": "(auth.uid == $users || root.child('moderators').hasChild(auth.uid) || root.child('adminisrators').hasChild(auth.uid))"
        },
        "advancedInfo": {
          // The write here the user must be the user itself or either a moderator or an administrator
          ".read": "(auth.uid == $users || root.child('moderators').hasChild(auth.uid) || root.child('adminisrators').hasChild(auth.uid))",
          ".write": "(auth.uid == $users || root.child('moderators').hasChild(auth.uid) || root.child('adminisrators').hasChild(auth.uid))"
        }
      }
    }
  }
}
{
  "administrators" : {
    "a094c6773-08a1-493b-a018-fbeb386721bf" : "99"
  },
  "moderators" : {
    "a094c6773-08a1-493b-a018-fbeb386721bf" : "10"
  },
  "users" : {
    "094c6773-08a1-493b-a018-fbeb386721bf" : {
      "advancedInfo" : {
        "email" : "plop@plop.com"
      },
      "basicInfo" : {
        "name" : "Plop"
      }
    }
  }
}