The role of this small web relation management application is to be a standard where the student may extend the capabilities integrating more relational operations. The view of the application is written in a compact view (front-end) library React, in TypeScript. Feel free to check the detailed comments on the code to get to know what it does. The main part, the back-end operations are written in Python, using the library flask, and PostgresQL is used as the database engine. The directory structure and program architecture is given below and to activate/setup the environment, follow the instructions below.
docker-compose.yaml- Docker compose file used to build the Postgres environment and its admin interfaceapp.py- codebase of the backend API and database integration. SQL statements to be written hereview/src/api.ts- codebase communicating the view with the main api (namely functionalities ofapp.py)view/App.tsx- main view file where the relation data gathered from the database is renderedview/components/<View>.tsx- auxiliary view components used inApp.tsxto render the relation and the editor application structurally (check the comments in the files for a detailed cover)
main.tsxandindex.css- entrance point files not to be modified: all content ofApp.tsxandApp.scssare compiled into them respectively- Files including
vite- config files for a fast build tool Vite tsconfig.json- compiler configuration for TypeScriptpackage.json- includes names and versions of the necessary view libraries used in the application.gitignore;index.html;node_modules- keeps unnecessary files away from version control; main entry point for the browser; folder storing necessary installed JavaScript libraries
- On Windows / MacOS / Linux machines - make sure you've installed Python and
python(orpython3) executable is accessible from the terminal (bash, batch or powershell). Many Linux-based OS's have Python already installed. On Windows installation, make sure to check the highlighted box. Click here to see a full installation guide for Windows / MacOS / Linux machines
- To install
pipenv- Python pip environment manager, runpip install pipenvin your terminal. Make surepipenvis also in your OS path and accessible from your shell. Note that isolated environments are for protecting your system packages written in Python, in case anything crashes. It also separates your different projects using different names and versions of pip packages. - In the current project directory, use
pipenv shellto enter the virtual environment. Executeexitwhen you want to leave it. - Once you're in the pip environment, run
pip install -r requirements.txtto install necessary libraries for database management with Python (runsudo apt-get install libpq-devif you face problems on Linux andbrew install postgresqlif you get errors withpip install psycopg2). - If you're using VSCode with its Python extension as your development environment (which is preferable for this project), after creating the
pipenvenvironment in the folder, you may enable in-editor for VSCode:- Open Command Pallette using
Shift + Command + Pon Mac andCtrl + Shift + Pon Windows/Linux
- Search and select "Python: Select Interpreter"
- Select the newly created
pipenvenvironment, which'll have the name of the folder to which you've added the project in it
- Then you can debug your code in full capacity
- Open Command Pallette using
- Only thing needed to be installed is
npmandvite. You can select your OS version from this link and see the instructions to installnpm. - After successfully installing
npm, run the commandnpm i -g viteto globally installvite(tryinstall_npm.shto install it on your Linux-based OS).
- Make sure you have Docker installed on your device and you can run
docker-composecommand. You may refer to this link in order to do so. - You may want to modify the
POSTGRES_PASSWORDenvironment variable in thedocker-compose.ymlfile if you're going to deploy it to public for security purposes. - In the project directory, run
docker-compose up -dordocker compose up -dto build the virtual containers for PostgreSQL and its adminer interface. - Default port for the Postgres DBMS is given
5432, and for admin interface application it's7890. You can go to0.0.0.0:7890in your browser to visually interact with the DBMS. Note that it's only done for the verification purposes to check if your code works. - If both successful, you should see Running status for both container (names may differ) in you Docker Desktop application.

- Alternatively, you may run
docker pscommand to see the similar view in the shell.
- You can run
app.pyin debug mode in VSCode (F5key), or alternatively, usepython app.pyin the terminal wherepipenvenvironment is activated - For the view part, you can simply run
vitecommand from the shell in the project directory. If you want to debug in detail, go topackage.jsonfile in VSCode and run by clicking the hovered Debug button:
- Now refer to the code to get more closely acquainted!
- In case you face an error while running
app.pyrelated to Postgres libraries, try to install psycopg2 again as:pip uninstall psycopg2pip install --no-binary :all: psycopg2
