FCA_Backend
Repository to manage code for the FCA Backend API and Backoffice
Overview
RestAPI service to be the gateway that other applications use to interface with the FCA manage Apps, Users, Tenants and Authorization.
Includes Backoffice that makes direct human interaction mor manageable for Apps, Users, Tenants and Authorization management
How to make it work locally
Download the code run npm install
Create a .env file in the project root directory with the following data:
NODE_ENV=development
MAIN_MONGODB_URL=mongodb://{your-mongo-db-url}/{your-mongodb-name}
MAIN_TENANT_ID=edafcd67-1e73-4869-b200-ca38fae09ad5
NUM_CLUSTERS=4
PORT=2000
FCA_ANALYSIS_API_URL=https://localhost:5001
FCA_IDENTITY_API_URL=http://localhost:4000
FCA_STORAGE_API_URL=http://localhost:3000
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=secret
MONGO_INITDB_DATABASE=shiseidodb
Run the application with node . or npm start
Run in a container
If you are running the application in the embeded container, replace localhost with host.docker.internal in the file abobe, and use scripts build.bat and run.bat for build and execution
Also, you will need to remove the line .env from dockerignore file in the project root for the container to accept and integrate the environment variables
Alternatively, you can also use the Makefile
. Make sure to install mkcert
(don't forget to run mkcert -install
), make
and docker-compose
, which will
allow you to setup a fully functional dev environment with valid HTTPS cert.
Run make build
to build the images (and generate required CA certs) and then
run make start
to start the dev environment.
You're free to use the previously mentioned host.docker.internal
host, or you can edit your
/etc/hosts (or system32/drivers/etc/hosts
in Windows) and add the following:
# API
127.0.0.1 shiseido.lc
# Mongo GUI
127.0.0.1 mongo.shiseido.lc
Analysis
Analysis API. It's used to create new analysis, set context data for the analysis and retrieve the results
Entry points
- POST - /analysis - Request a new analysis
- GET - /analysis/{analysisId} - Get the results of a given analysis
- PUT - /analysis/{analysisId}/params - Set the parameters of an existing analysis
- GET - /analysis/{analysisId}/images/{imageType} - Get the result image of a given primary analysis type, or the source image.
- GET - /analysis/{analysisId}/recommendation - Get the recommendation for the given analysis
- POST - /analysis/{analysisId}/quizz - Run next step of the quizz
Secondary Formula
Secondary Formula management for dynamically defining Secondary Analysis Measures
Entry points
- GET - /tenants/{tenantId}/formulas - Get all the formulas of a tenant as an object
- GET - /tenants/{tenantId}/formulas/{formulaId} - Get the script of a formula from a tenant
- PUT - /tenants/{tenantId}/formulas/{formulaId} - Set the script of a formula for a tenant
- DELETE - /tenants/{tenantId}/formulas/{formulaId} - Remove one formula from a tenant
- GET - /tenants/{tenantId}/formulasinfo - Get all the information from every formula
- GET - /tenants/{tenantId}/formulasinfo/locale/{locale} - Get all the information from every formula
- PUT - /tenants/{tenantId}/formulasinfo/{formulaId} - Set the information of a formula for a tenant
- DELETE - /tenants/{tenantId}/formulasinfo/{formulaId} - Remove one formula information from a tenant
- PUT - /tenants/{tenantId}/formulasinfo/{formulaId}/locale/{locale} - Set the locale information of a formula for a tenant
- DELETE - /tenants/{tenantId}/formulasinfo/{formulaId}/locales/{locale} - Remove one formula information from a tenant
App
Applications management. Applications represents subsystems able to communicate with the global API and use some endpoints.
Entry points
- GET - /apps - Get all the apps
- POST - /apps - Insert a new app
- GET - /apps/{appId} - Get one Application
- PUT - /apps/{appId} - Update an existing app
- PATCH - /apps/{appId} - Update a part of an existing app
- DELETE - /apps/{appId} - Delete an existing app
Auth
Authentication management.
Entry points
- POST - /auth/user/login - Create a token for the user
- POST - /auth/app/login - Create a token for an Application
- POST - /auth/user/refresh - Refresh a token for the user
- POST - /auth/app/refresh - Refresh a token for an Application
- GET - /auth/user/whoami - Get information about the user
- GET - /auth/app/whoami - Get information about the application
ChannelUser
ChannelUsers management
Entry points
- GET - /channelUsers - Get all the channelUsers
- POST - /channelUsers - Insert a new channelUser
- GET - /channelUsers/{id} - Get one channelUser
- PUT - /channelUsers/{id} - Update an existing channelUser
- DELETE - /channelUsers/{id} - Delete an existing channelUser
- GET - /channelUsers/byChannel/{channel} - Get all the channelUsers from a given channel
- GET - /channelUsers/byChannel/{channel}/{channelUserId} - Get one user by channel and channelUserId
- GET - /channelUsers/{id}/context - Get the context of a user
- PUT - /channelUsers/{id}/context - Update the context of an existing channelUser
- PATCH - /channelUsers/{id}/context - Partially update the context of an existing channelUser
- DELETE - /channelUsers/{id}/context - Delete the context of an existing channelUser
- GET - /channelUsers/{id}/context/all - Get all the contexts related to this channel user
- GET - /channelUsers/{id}/context/consolidated - Get a consolidated context for this channel user
- POST - /channelUsers/link - Link 2 channel users (can generate a link user), 1 channel user with 1 user, or 2 users
- POST - /channelUsers/unlink - Unlink 1 channelUser from their parent user
Database Connections
Management of the databases connection for the tenants.
Entry points
- GET - /databases - Get all the databases connections
- POST - /databases - Insert a new database connection
- GET - /databases/{databaseId} - Get one database connection
- PUT - /databases/{databaseId} - Update an existing database connection
- PATCH - /databases/{databaseId} - Patch an existing database connection
- DELETE - /databases/{databaseId} - Delete an existing database connection
Storage Connections
Management of the storages connections for the tenants.
Entry points
- GET - /storages - Get all the storages connections
- POST - /storages - Insert a new storage connection
- GET - /storages/{storageId} - Get one storage connection
- PUT - /storages/{storageId} - Update an existing storage connection
- PATCH - /storages/{storageId} - Patch an existing storage connection
- DELETE - /storages/{storageId} - Delete an existing storage connection
Tenant
Tenant management. Tenants represents a brand and market. Every tenant has an associated database and storage.
Entry points
- GET - /tenants - Get all the tenants
- POST - /tenants - Insert a new tenant
- GET - /tenants/{tenantId} - Get one tenant
- PUT - /tenants/{tenantId} - Update an existing tenant
- PATCH - /tenants/{tenantId} - Update a part of an existing tenant
- DELETE - /tenants/{tenantId} - Delete an existing tenant
- PUT - /tenants/{tenantId}/rotate - Rotate the keys of an existing tenant
- GET - /tenants/{tenantId}/info - Public access to get tenant information including public key
- GET - /tenants/info - Public access of all tenants
User
Users management
Entry points
- GET - /users - Get all the users
- POST - /users - Insert a new user
- GET - /users/{userId} - Get one user
- PUT - /users/{userId} - Update an existing user
- PATCH - /users/{userId} - Patch an existing user
- DELETE - /users/{userId} - Delete an existing user
Product
Products management
Entry points
- GET - /products - Get all the products
- POST - /products - Insert a new product
- GET - /products/{productId} - Get one product
- PUT - /products/{productId} - Update an existing product
- PATCH - /products/{productId} - Patch an existing product
- DELETE - /products/{productId} - Delete an existing product
- GET - /tenants/{tenantId}/products - Get all the products
- POST - /tenants/{tenantId}/products - Insert a new product
- GET - /tenants/{tenantId}/products/{productId} - Get one product
- PUT - /tenants/{tenantId}/products/{productId} - Update an existing product
- PATCH - /tenants/{tenantId}/products/{productId} - Patch an existing product
- DELETE - /tenants/{tenantId}/products/{productId} - Delete an existing product
- POST - /products/batch - Perform a batch update based on the provided list of products
Question
Question management
Entry points
- GET - /questions - Get all the questions
- POST - /questions - Insert a new question
- GET - /questions/{questionId} - Get one question
- PUT - /questions/{questionId} - Update an existing question
- PATCH - /questions/{questionId} - Patch an existing question
- DELETE - /questions/{questionId} - Delete an existing question
- GET - /tenants/{tenantId}/questions - Get all the questions
- POST - /tenants/{tenantId}/questions - Insert a new question
- GET - /tenants/{tenantId}/questions/{questionId} - Get one question
- PUT - /tenants/{tenantId}/questions/{questionId} - Update an existing question
- PATCH - /tenants/{tenantId}/questions/{questionId} - Patch an existing question
- DELETE - /tenants/{tenantId}/questions/{questionId} - Delete an existing question
Database
Database management. Single point to interact with the databases configured by tenant.
Entry points
- GET - /database/{collectionName} - Gets a list from the collection using the filter provided
- POST - /database/{collectionName} - Insert a new item in the collection.
- GET - /database/{collectionName}/findOne - Gets one item from the specified collection using the filter provided
- GET - /database/{collectionName}/{itemId} - Gets the item from the collection with the id provided.
- PUT - /database/{collectionName}/{itemId} - Update a value from an entry in the collection.
- PATCH - /database/{collectionName}/{itemId} - Update a value from an entry in the collection.
- DELETE - /database/{collectionName}/{itemId} - Delete an item from the collection.
Storage
storage management. Single point to interact with storages configured by tenant.
Entry points
- GET - /storage/{containerName}/{fileId} - Gets the file specified
- DELETE - /storage/{containerName}/{fileId} - Delete an existing file.
- GET - /storage/image/{containerName}/{fileId} - Gets the specified image.
- POST - /storage/{containerName} - Insert a new file.
- POST - /storage/image/{containerName} - Insert a new image.