This guide explains how to run the dashboard locally on your Mac.
- Node.js: Required to run the frontend. Download from nodejs.org.
- Python 3: Required to run the data update scripts. (Usually pre-installed on macOS).
-
Unzip the project: Extract the
prociv_plans_dashboard.zipfile to a location of your choice. -
Open Terminal: Open the Terminal app and navigate to the project folder:
cd path/to/prociv_plans_dashboard -
Install Dependencies: Run the following command to install the required Node.js packages:
npm install
(Note: If you don't have
pnpminstalled,npmworks fine. If you preferpnpm, runnpm install -g pnpmfirst, thenpnpm install). -
Install Python Dependencies: The data update scripts require a few Python libraries. Install them using pip:
pip3 install requests beautifulsoup4 python-dateutil
- Start the Development Server:
This will start the local server, usually at
npm run dev
http://localhost:5173. Open this URL in your browser to view the dashboard.
The dashboard data is static, meaning it doesn't fetch from the official website in real-time (to avoid overloading their server). Instead, you run a script to update the data locally.
To update the data:
-
Run the Update Script:
./scripts/update_data.sh
This script will:
- Scrape the latest data from
planos.prociv.pt. - Categorize the plans.
- Update the historical data (for the chart).
- Update the
client/src/lib/plans-data-pt.tsfile which the dashboard uses.
Once the script finishes, the dashboard (if running) will automatically reload with the new data.
- Scrape the latest data from
You can set up a "cron job" to run the update script automatically every day.
- Type
crontab -ein Terminal. - Add a line like this (replace
/path/to/...with the actual path):This runs the update every day at 9:00 AM.0 9 * * * /path/to/prociv_plans_dashboard/scripts/update_data.sh >> /path/to/prociv_plans_dashboard/update.log 2>&1
- Permission Denied: If
./scripts/update_data.shfails with permission denied, run:chmod +x scripts/update_data.sh
- Python Errors: Ensure you installed the dependencies (
requests,beautifulsoup4,python-dateutil).