The application consists of a database, api, and client. Follow the steps below to run each service
- Navigate to the db directory
- Create an environment variable file from the example
cp example.env .env
- Set the env variables to unique values
- Start the docker container
docker run -p 5432:5432 --name postgis_app --env-file .env postgis
- Navigate to the project root
- Initialize a virtual environment
python -m venv venv
- Activate the virtual environment
source venv/bin/activate
- Install the python requirements
pip install -r requirements.txt
- Navigate to the api directory
- Create an environment variable file from the example
cp example.env .env
- Set the environment variables
ENVIRONMENT=dev
SECRET_KEY=
some randomly generated sequencePOSTGRES_USER=
the value set in the DB env filePOSTGRES_PASSWORD=
the value set in the DB env file
- Run the database migrations
python manage.py migrate
- Load the data into the database
- Activate the python shell
python manage.py shell
- Import the load scripts
from ada_stations.load_scripts import all
- Run the load scripts
all.run()
- Quit the shell
quit()
- Activate the python shell
- Run the server on port 8001
python manage.py runserver 8001
- navigate to the client directory
- Create an environment variable file from the example
cp example.env .env
- Set the environment variables
NEXT_PUBLIC_MAPLIBRE_TOKEN=
Generated maptiler keyNEXT_PUBLIC_API_DOMAIN=localhost:8001
(to match the local API port)
- Install the required packages
- Ensure node 18 is installed
- Install the required node modules
npm i
- Run the application
npm run dev
- Data models:
- Load scripts:
- subway routes example api/ada_stations/load_scripts/subwayroutes.py
- load all models api/ada_stations/load_scripts/all.py
- API Endpoints:
- All views api/ada_stations/views.py
- Subway buffer view api/ada_stations/views.py#L81
- Rankings view api/ada_stations/views.py#L122
- Rankings endpoint test script
- Buffer analysis
- Analysis of gap to next accessible station
- Betweenness centrality analysis
From root directory
python -m venv venv
source venv/bin/activate
sudo dnf install libpq-devel python3-devel gcc gdal
pip install -r requirements.txt
From top api directory
python manage.py runserver 8001
gunicorn api.wsgi -b :8001 --daemon
ps ax|grep gunicorn
pkill gunicorn
From db directory
docker build -t postgis .
docker run -p 5432:5432 --name postgis_app --env-file .env postgis
To start and stop existing container:
docker stop postgis_app
docker start postgis_app
From top api directory
python manage.py migrate
python manage.py shell
from ada_stations.load_scripts import busroute
load_busroute.run()
From top api directory
python manage.py createsuperuser
From client directory
pnpm i
pnpm dev
Prod server
pm2 start npm --name "client" -- start
dnf provides semanage
setsebool -P httpd_can_network_connect 1
sudo semanage port --add --type http_port_t --proto tcp 8001
sudo semanage port --list
systemctl status nginx
systemctl start nginx
copy tangled_city.conf to ~/etc/nginx/conf.d
sudo nginx -t
sudo nginx -s reload