This manual outlines the step-by-step instructions for installing, configuring, and starting the server side and frontend of the project.
Note: Some settings are hardcoded in the application, such as the Django
SECRET_KEYand database credentials (see theDATABASESsection insettings.py). You may need to update these values before deploying in production.
- Overview
- Installation on Linux
- Installation on macOS
- Installation on Windows
- Database Setup
- Configuring Django Settings
- Running the Application
- Hardcoded Constants
- Troubleshooting and References
- Frontend Setup
Note: Currently, this project works best on Linux/WSL enviornments.
Parking management system for reserving spaces on a college campus.
Open your terminal and run the following commands (on non-root user):
sudo apt update
sudo apt upgrade -yThen install the necessary packages:
sudo apt install postgresql postgresql-contrib postgis libgdal-dev python3 python3-pip python3-venvSwitch to the postgres user:
sudo -i -u postgresCreate a PostgreSQL user (if needed) and the database:
createuser --interactive
createdb p4edbEnable the PostGIS extension:
psql -d p4edb -c "CREATE EXTENSION postgis;"Exit the postgres user shell:
exitCreate and activate a virtual environment:
python3 -m venv venv
source venv/bin/activateUpgrade pip and install the required Python packages:
pip install --upgrade pip
pip install -r path/to/P4SBU/folder/server/requirements.txtOpen Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Install PostgreSQL and PostGIS:
brew install postgresql postgisInstall GDAL and GEOS:
brew install gdal geosInstall Python3 (if needed):
brew install pythonStart the PostgreSQL service:
brew services start postgresqlCreate a new database and user (adjust <username> as needed):
createuser -s <username>
createdb p4edb
psql -d p4edb -c "CREATE EXTENSION postgis;"Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activateUpgrade pip and install dependencies:
pip install --upgrade pip
pip install -r path/to/P4SBU/folder/server/requirements.txt- Python: Download and install Python. Make sure to check "Add Python to PATH" during installation.
- PostgreSQL: Download and install PostgreSQL. During installation, ensure that PostGIS is selected as an additional component.
- GDAL & GEOS: Install OSGeo4W from OSGeo4W. During the setup, install the GDAL and GEOS packages.
Using the SQL Shell (psql) or pgAdmin, create your database and enable PostGIS:
CREATE DATABASE p4edb;
\c p4edb
CREATE EXTENSION postgis;Open Command Prompt or PowerShell and run:
python -m venv venv
venv\Scripts\activateUpgrade pip and install required packages:
py -m pip install --upgrade pip
py -m pip install -r path/to/P4SBU/folder/server/requirements.txtImportant: Make sure the GDAL and GEOS library paths in your settings.py are correctly set for Windows:
GDAL_LIBRARY_PATH = r'C:\OSGeo4W\bin\gdal310.dll'
GEOS_LIBRARY_PATH = r'C:\OSGeo4W\bin\geos_c.dll'- Database Name:
p4edb - User:
sbu7 - Password:
trvclearfission777@ - Host:
localhost - Port:
5432
These credentials are specified in the DATABASES configuration in settings.py. If necessary, update these values in settings.py for your deployment environment.
Review the settings.py file (located in the project root) for key configurations:
-
Secret Key:
SECRET_KEY = 'django-insecure-vr&bee(#$(f@hsljd#jzoarqhub0$%i3^zz+cvhu!a=&c+d-z#'
Update this key for production. -
Debug Mode:
DEBUG = True
Set toFalsein production environments. -
Database Settings:
The database connection details (name, user, password, etc.) are hardcoded. Update as needed. -
GDAL & GEOS:
Library paths are set conditionally based on the operating system. Verify that the paths match your installation:- Windows:
GDAL_LIBRARY_PATH = r'C:\OSGeo4W\bin\gdal310.dll' GEOS_LIBRARY_PATH = r'C:\OSGeo4W\bin\geos_c.dll'
- macOS:
GDAL_LIBRARY_PATH = '/opt/homebrew/lib/libgdal.dylib' GEOS_LIBRARY_PATH = '/opt/homebrew/lib/libgeos_c.dylib'
- Linux:
GDAL_LIBRARY_PATH = '/usr/lib/x86_64-linux-gnu/libgdal.so' GEOS_LIBRARY_PATH = '/usr/lib/x86_64-linux-gnu/libgeos_c.so'
- Windows:
-
CORS Settings:
The settings allow all origins for development. ModifyCORS_ALLOW_ALL_ORIGINSandCORS_ALLOWED_ORIGINSfor production use.
After setting up the virtual environment and configuring the database, run:
python manage.py makemigrations
python manage.py migrateTo access the Django admin interface:
python manage.py createsuperuserRun the server:
python manage.py runserverThe application will be accessible at http://127.0.0.1:8000/.
The following constants are hardcoded in the code and may need updating:
- SECRET_KEY in
settings.py - Database Credentials:
- Database Name:
p4edb - User:
sbu7 - Password:
trvclearfission777@
- Database Name:
Please update these values in settings.py under the DATABASES section and the top of the file before starting the server.
-
Documentation:
-
Common Issues:
- Verify that PostgreSQL is running and that you have created the
p4edbdatabase. - Check that the GDAL and GEOS library paths in
settings.pymatch the installation directories on your system. - Ensure your Python virtual environment is activated before running Django commands.
- Ensure you are not using the root user for Linux (use whoami command)
- Verify that PostgreSQL is running and that you have created the
If you encounter dependency conflicts or errors during installation, try either steps: (or both)
- Try Installation on Linux again with a fresh install of WSL2
- Use Poetry with the provided
poetry.lockfile. This file ensures that the exact tested package versions are installed.
-
Linux/macOS: Open your terminal and run:
curl -sSL https://install.python-poetry.org | python3 -Follow any additional instructions (such as adding Poetry to your PATH) provided by the installer.
-
Windows: Open PowerShell and run:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
Alternatively, download and run the installer from the Poetry installation page.
In the root directory of your project (where the poetry.lock file is located), run:
poetry installThis command will install all dependencies according to the versions specified in poetry.lock.
-
Update the Lock File (Without Updating Versions): If you run into conflicts, try:
poetry lock --no-update
-
Regenerate the Lock File: If issues persist, you can remove the existing lock file and regenerate it:
- Linux/macOS:
rm poetry.lock poetry install
- Windows:
del poetry.lock poetry install
- Linux/macOS:
-
Consult Documentation: For more detailed troubleshooting, refer to the Poetry documentation.
-
Linux:
Open your terminal and run:sudo apt update sudo apt install nodejs npm
Alternatively, install the latest Node.js via NodeSource.
-
macOS:
If you have Homebrew installed, run:brew install node
-
Windows:
Download and install the latest LTS version of Node.js from the official Node.js website. Ensure npm is included with your installation.
Navigate to the project's root directory and run:
npm installThis command installs all the dependencies specified in the package.json file.
You may also need:
npm install --legacy-peer-depsAfter installing the dependencies, generate a secure authentication secret by running:
npx auth secretThis command will generate and display a secret key inside p4sbu/.env.local
Once the dependencies are installed and the secret has been generated, start the frontend server by running:
npm run devor
npm run build
npm run startAfter the server starts, open your web browser and navigate to http://localhost:3000 to view the application.
If you encounter any issues during this process, please consult the npm documentation or the Node.js website.