The App requires:
-
Node.js v16+ to run (^16.14.2).
-
Yarn.js v1+ to run (^1.22.19).
-
Docker (in case that you desire to start app with docker).
-
Azure Active Directory B2C installed and configured in Azure Subscription
-
PostgreSql (windows installation, linux installation).
-
The Smart Contracts from Blockchain project deployed in Polygon Testnet Network.
-
You could check version of packages (node, yarn) with these comamnds:
node -v yarn -v
You can set up the database either running manually installing the database on your local machine or running docker-compose
command.
You need to have postgreSql installed.
Then:
- Set postgres database password to the same in .env file (or vice versa). If you need to change password:
# linux: sudo -u postgres psql, windows: psql. Then:
# Important: use the same user name (here "postgres") that you put in .env file.
ALTER USER postgres PASSWORD 'p@ssword';
- Ensure that your postgres port is the same that .env file (default postgres port: 5432, actual in .env 54322 (additional "2")).
- Connect to postgresql and then create a database called unicef_giga
- Create user admin with any password (e.g.: p@ssword) and be sure that you put that user and password in .env file.
# command to create user with password in command lin
# important: use the same user name (here "postgres") that you put in .env file
psql -c "CREATE USER postgres WITH PASSWORD 'p@ssword';"
-
Create the database schema and insert the initial and mock data, running all the scripts in the following folder:
./database/scripts
- Schema & Initial Data: ./database/scripts/initial-data
- Mock Data: ./database/scripts/mock-data
Important: The 00_shema.sql script is using the admin user to leave as owner of the tables. That user has to be created in your local database (or put the one you have, in the script, before running it). Example:
alter table countries owner to admin;
- Alternatively, you could start up the database with docker-compose:
docker-compose up -d
SQL Files located on folder ./database/scripts
will be executed automatically during docker-compose
start-up
This command executes SQL scripts alphabetically
The default docker-compose.yml file, start database with schema and initial data.
If you want to include mock data (e.g.: dev environment), you must use docker-compose-mocks.yml.
docker-compose -f docker-compose-mock.yml up
- yarn install # with yarn
- npm i OR npm i --legacy-peer-deps # with NPM
If you have troubles with dependencies, try this:
set http_proxy=
set https_proxy=
npm config rm https-proxy
npm config rm proxy
npm config set registry "https://registry.npmjs.org"
yarn cache clean
yarn config delete proxy
yarn --network-timeout 100000
Create a .env file running the command in terminal
touch .env
The environment variables bellow needs to be set in the .env file when project is running locally.
SKIP_PREFLIGHT_CHECK=true
PG_USER=admin
PG_PASSWORD=some password
PG_DB_NAME=unicef-giga
Note: You can find more info about the others required
.env
variables inside theexample_env
file.
- yarn dev
# or
- npm run dev
- Improve scalability in the face of data growth (for example: schools) so that there is no impact on performance.
- Move hardcoded sql code to database.
See ./doc/, for documentation about source code and database commands.
-
Convert JSON Data to SQL Inserts command - This link is useful to convert data from the project connect API to postgresql