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.tsx
to render the relation and the editor application structurally (check the comments in the files for a detailed cover)
main.tsx
andindex.css
- entrance point files not to be modified: all content ofApp.tsx
andApp.scss
are 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 pipenv
in your terminal. Make surepipenv
is 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 shell
to enter the virtual environment. Executeexit
when you want to leave it. - Once you're in the pip environment, run
pip install -r requirements.txt
to install necessary libraries for database management with Python (runsudo apt-get install libpq-dev
if you face problems on Linux andbrew install postgresql
if 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
pipenv
environment in the folder, you may enable in-editor for VSCode:- Open Command Pallette using
Shift + Command + P
on Mac andCtrl + Shift + P
on Windows/Linux - Search and select "Python: Select Interpreter"
- Select the newly created
pipenv
environment, 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
npm
andvite
. You can select your OS version from this link and see the instructions to installnpm
. - After successfully installing
npm
, run the commandnpm i -g vite
to globally installvite
(tryinstall_npm.sh
to install it on your Linux-based OS).
- Make sure you have Docker installed on your device and you can run
docker-compose
command. You may refer to this link in order to do so. - You may want to modify the
POSTGRES_PASSWORD
environment variable in thedocker-compose.yml
file if you're going to deploy it to public for security purposes. - In the project directory, run
docker-compose up -d
ordocker compose up -d
to 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:7890
in 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 ps
command to see the similar view in the shell.
- You can run
app.py
in debug mode in VSCode (F5
key), or alternatively, usepython app.py
in the terminal wherepipenv
environment is activated - For the view part, you can simply run
vite
command from the shell in the project directory. If you want to debug in detail, go topackage.json
file 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.py
related to Postgres libraries, try to install psycopg2 again as:pip uninstall psycopg2
pip install --no-binary :all: psycopg2