forked from neophiles/KlimaTech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstructions.txt
More file actions
119 lines (95 loc) · 2.63 KB
/
instructions.txt
File metadata and controls
119 lines (95 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
==========================
******** BACKEND *********
==========================
1. Environment Setup
==========================
Create and activate a virtual environment:
python -m venv venv
venv\Scripts\activate # (Windows)
Install dependencies:
pip install -r requirements.txt
Configure environment variables:
- Create a `.env` file in the project root with:
DB_USER=your_postgres_user
DB_PASSWORD=your_postgres_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=heat_project
==========================
2. Database Commands
==========================
Create the PostgreSQL database:
psql -U your_postgres_user
CREATE DATABASE heat_project;
\q
Look inside the database:
\dt
SELECT * FROM heatlog;
SELECT * FROM barangay;
Remove the data's:
TRUNCATE TABLE
barangay,
coolspot,
homebasedprofile,
officeworkerprofile,
outdoorworkerprofile,
report,
studentprofile,
tip,
tiplog,
userprofile,
vote
RESTART IDENTITY CASCADE;
(For SQLite only, to ensure `recorded_at` is TEXT:)
ALTER TABLE heatlog RENAME TO heatlog_old;
CREATE TABLE heatlog (
id INTEGER PRIMARY KEY,
barangay_id INTEGER,
temperature_c REAL,
humidity REAL,
wind_speed REAL,
heat_index_c REAL,
risk_level TEXT,
recorded_at TEXT
);
INSERT INTO heatlog (id, barangay_id, temperature_c, humidity, wind_speed, heat_index_c, risk_level, recorded_at)
SELECT id, barangay_id, temperature_c, humidity, wind_speed, heat_index_c, risk_level, recorded_at
FROM heatlog_old;
DROP TABLE heatlog_old;
==========================
3. Scripts & Data Loading
==========================
Add initial barangays data:
python -m app.scripts.add_barangays
Prepopulate coolspots:
python -m app.scripts.prepopulate_coolspots
==========================
4. Running FastAPI
==========================
Run the FastAPI server:
uvicorn app.main:app --reload
API Docs:
http://localhost:8000/docs
==========================
FRONTEND
==========================
1. Naviagate to the frontend folder
==========================
cd frontend
==========================
2. Install dependencies
==========================
npm install
==========================
3. Run development server
==========================
npm run dev
==========================
4. Access the app (React)
==========================
URL: http://localhost:5173/
==========================
=========================
Run this if service worker issues occur:
=========================
navigator.serviceWorker.getRegistrations().then(rs => rs.forEach(r => r.unregister())).then(() => location.reload());