The code is organized into three folders: backend, frontend and database.
This folder contains the Javascript files used to integrate the frontend of the application with the PostgreSQL database server. There are two files of interest:
-
index.js: This file is used to set up the routes, as well as their type of requests from the API to the database tier.
-
queries.js: This file contains the database queries for each route specified in index.js. It takes inputs from HTTP request bodies and parameters, and outputs database query results as JSON rows.
The Dart code in this folder seems to be a lot heavier, however only a few files and subdirectories are important:
-
pubspec.yaml: This is a YAML (Yet Another Markup Language) file, which contains all the imported packages used in the Dart code in the lib folder.
-
lib: This is the subdirectory containing the code for the frontend of the application. There are many subdirectories inside lib.
- pages: This subdirectory contains Dart source files for each page of the application.
- views: This subdirectory contains various widgets and themes that are imported into Dart files in the pages subdirectory.
- models: This subdirectory contains the definition and attributes of the various models used in this application.
- services: This subdirectory contains the middleware of the application. In particular, it contains all the API calls made from the frontend to the backend URLs.
The main.dart file in this directory contains the main function which runs the application.
There are two stages to setting up the application to run, given that the database is already created and populated.
In a terminal window, type the following from the root directory:
$ cd backend
$ npm i
$ npm run server
This will start the Node.js server to handle database requests.
- In Chrome/Chromium based browsers, install the Dart Debug Extension.
- In VS Code, install the Flutter extension.
- Open frontend/lib/main.dart in VS Code and run in debug mode on a webserver. This will render the web application on the browser.
- Click the Dart Debug icon when asked, to complete the rendering and view the application.