Clone the repository
Follow all instructions in the πRepository, but choose the 2. repository (opens in a new tab).
If you completed the "Web App Setup" chapter, you can just directly clone the second repository, because you have already configured the SSH key. Implementation is slightly adjusted for this part, so you have to clone the second repository, even though you did the first part.
Install dependencies
- In the terminal, navigate to the client directory and run
npm install
to install all dependencies. - After it is completed, do the same for the server directory.
Initialize Database
For the database, we are using PostgreSQL.
The database server is already running on the VM, so we are just going to create the database, tables and seed the tables with some data.
Before running following commands, terminate (CTRL + C) the running server in the terminal and insert the commands in the server directory
Create a database
In the terminal, run the following command:
npm run db-create
Create tables and insert data
Run the following command:
npm run db-seed
Drop database
If you corrupt the database and data in it during exposing the vulnerabilities, you can drop the database and create it again.
Do not run this command now, because it will erase everything you just created.
npm run db-drop
In case of need, to recreate the database, tables, and records, run npm run db-drop
, npm run db-create
and npm run db-seed
commands.
[Optional] Interact with the database
- To interact with the PostgreSQL database server, you can use
psql
CLI.
- You can type SQL commands to interact with the database, and it also provides meta-commands to interact with the server.
- Second option is to use preinstalled GUI tool called DBeaver, but we strongly recommend using
psql
CLI. A tutorial for these two tools is not part of this tutorial, but there are many available online.
Run the Application
- In the terminal, navigate to the server directory and run
npm run dev
to start the server. - In another terminal, navigate to the client directory and run
npm start
to start the client. - Open the browser and navigate to
http://localhost:3001
and familiarize yourself with the application.