Skip to content

viconnex/theodercafe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fais tes choix sur theodercafe.com

app-preview

Install

Backend

cd backend && cp .env.dev.dist .env.dev && cd ..
docker-compose up

Frontend

cd frontend
cp .env.dist .env
npm install
npm run start

Setup Google OAuth Client for Login

Authentication is performed via Google OAuth (see Authentication Flow schema below). To use OAuth locally, you need to:

Help: passport-google-oauth20 library

Install check 🤞

Login from the frontend: http://localhost:3000/login.

Grant admin role to your user

Connect to database :

docker-compose exec postgresql psql -d theodercafe -U the
UPDATE "users" SET "isAdmin"=true;

You should be able to see http://localhost:3000/admin#/questions page.

Add questions

Add questions from frontend with the '+' button on bottom right.

From the admin panel, mark them as Validated for asakai.

Toggle Live Mode : you should see an asakai set with validated questions.

Features

Live Mode (or Asakai Mode)

Asakai Mode provides a new set quesitons every day. These quesitions are randomly chosen among "validated questions".

It is also named Live Mode because you can see others choices live.

You can mark a question as Validated for Asakai from the admin panel.

The Asakai Set also depends of the Question Set chosen by the user.

An admin may click changeTodaySet button to renew the Asakai Set.

On the admin panel, mark a question as Classic : the question will necessary be part of the Live Mode set.

Turning on Coach Mode enables a coach to ask the questions to a brand new Theodoer. Indeed, it will:

  • prevent from attaching the choices to the coach's account
  • propose an email form at the end of the questioning to register the new Theodoer. If the email does not exist yet:
    • a new user is created
    • a welcome email is sent
    • choices made during asakai and also asakai alterodo result are attached to the new user

All questions mode

If you Toggle Live Mode to OFF, you may filter questions with the FILTRES menu.

Database

Connexion

  • Dev: docker-compose exec postgresql psql -d theodercafe -U the
  • Prod PGDATABASE=theodercafe gcloud sql connect theodercafe --user=the

Diagram

Diagram here https://dbdiagram.io/d/63c40a1b296d97641d79bfe7.

Dump:

docker-compose exec postgresql pg_dump -d theodercafe -U the -s >schema.sql

Architecture

Services

image

Authentication flow

image

Firebase setup

To run Live Mode features locally, you need to :

  • add a firebase project

  • enable Firestore Database on this project.

  • in the project settings -> service accounts, create a Firebase Admin SDK

    • copy the firebase service account email and paste it into the FIREBASE_SERVICE_ACCOUNT_CLIENT_EMAIL variable of your .env.dev
    • Generate a new private key and paste the secret_key value into variable. For example:
    FIREBASE_SERVICE_ACCOUNT_CLIENT_EMAIL="firebase-adminsdk-xxx@theodercafe.iam.gserviceaccount.com"
    FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY='-----BEGIN PRIVATE KEY-----\nMIIEuaIBADANBgkq...\n-----END PRIVATE KEY-----\n'
    
  • in the Cloud Firestore -> Rules, paste the following rules. It allows any authenticated to read other users' answers. But a user may only modify the answer corresponding to its userId.

    rules_version = '2';
    service cloud.firestore {
      match /databases/{database}/documents {
        match /questioning/{questioningId}/questions/{questionId}/users/{userId}{
          allow write: if request.auth != null && request.auth.uid == userId;
        }
        match /questioning/{questioningId}/questions/{questionId}/{users=**}{
          allow read: if request.auth != null;
        }
      }
    }
    

    Database Entities

    https://dbdiagram.io/d/63c40a1b296d97641d79bfe7