Skip to content

Commit 04f93f9

Browse files
committed
changes made
1 parent bd0e351 commit 04f93f9

40 files changed

Lines changed: 6535 additions & 269 deletions

MAP_SETUP.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ResQTrack - Map Integration Setup
2+
3+
## OpenStreetMap + Leaflet.js Integration
4+
5+
The ResQTrack application now uses OpenStreetMap with Leaflet.js for enhanced map functionality. This implementation is completely free and requires no API keys.
6+
7+
### 1. Features Added
8+
9+
#### Map Improvements
10+
- **OpenStreetMap Integration**: Uses free OpenStreetMap tiles with Leaflet.js
11+
- **No API Key Required**: Completely free to use with no billing concerns
12+
- **Enhanced Geocoding**: Uses Nominatim API for accurate location resolution
13+
- **Custom Markers**: Hospital and police station markers with custom icons
14+
- **Interactive Popups**: Click on markers to see detailed information
15+
- **Location Picker**: Interactive map for selecting precise locations
16+
17+
#### Data Management Features
18+
- **CSV File Management**: View and delete uploaded CSV files
19+
- **Bulk Data Clearing**: Clear all data for specific service types (hospitals, police stations, etc.)
20+
- **Individual Entry Deletion**: Delete specific entries from emergency services
21+
- **File Upload Tracking**: Monitor uploaded files with size and modification date
22+
23+
### 2. New API Endpoints
24+
25+
The following new endpoints have been added to the backend:
26+
27+
- `GET /data/uploaded-files` - List uploaded CSV files
28+
- `DELETE /data/delete-file` - Delete a specific CSV file
29+
- `DELETE /data/clear-data/<service_type>` - Clear all data for a service type
30+
- `DELETE /data/delete-entry/<service_type>/<entry_id>` - Delete a specific entry
31+
32+
### 3. Usage
33+
34+
#### Location Picker (`location-picker.html`)
35+
- Search for locations using Nominatim geocoding
36+
- Use device location with geolocation API
37+
- Click on map to select precise coordinates
38+
- Copy coordinates or send to backend
39+
- Mobile-friendly responsive design
40+
41+
#### Hospitals Page
42+
- Switch between List View and Map View
43+
- Click on map markers to see hospital details
44+
- Hospitals are geocoded automatically from their location field
45+
46+
#### Admin Dashboard
47+
- View all emergency services on interactive maps
48+
- Add new locations using the location picker map
49+
- Manage uploaded CSV files
50+
- Clear data or delete individual entries
51+
52+
#### Data Dashboard
53+
- Import CSV files for different service types
54+
- View uploaded files and delete them
55+
- Clear all data for specific service types
56+
- Delete individual emergency service entries
57+
58+
### 4. Technical Implementation
59+
60+
#### Libraries Used
61+
- **Leaflet.js**: Open-source JavaScript library for interactive maps
62+
- **OpenStreetMap**: Free, open-source map data
63+
- **Nominatim**: Free geocoding service for OpenStreetMap
64+
65+
#### Configuration
66+
The map settings are configured in `frontend/config.js`:
67+
```javascript
68+
const CONFIG = {
69+
MAP_DEFAULT_CENTER: { lat: 20.5937, lng: 78.9629 }, // India center
70+
MAP_DEFAULT_ZOOM: 5,
71+
MAP_MAX_ZOOM: 19,
72+
MAP_TILE_LAYER: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
73+
NOMINATIM_BASE_URL: 'https://nominatim.openstreetmap.org',
74+
NOMINATIM_SEARCH_LIMIT: 5,
75+
NOMINATIM_COUNTRY_CODES: 'in'
76+
};
77+
```
78+
79+
### 5. Mobile-Friendly Features
80+
81+
- Responsive design that works on all screen sizes
82+
- Touch-friendly map interactions
83+
- Optimized marker sizes for mobile devices
84+
- Geolocation support for mobile browsers
85+
- Search functionality with autocomplete
86+
87+
### 6. Advantages Over Google Maps
88+
89+
- **No API Key Required**: No need to register or manage API keys
90+
- **No Billing**: Completely free with no usage limits
91+
- **Open Source**: Full control over the implementation
92+
- **Privacy**: No data sent to Google
93+
- **Customizable**: Easy to customize markers, popups, and styling
94+
95+
### 7. Troubleshooting
96+
97+
If maps don't load:
98+
1. Check browser console for error messages
99+
2. Ensure internet connection is available
100+
3. Verify that Leaflet.js is loading correctly
101+
4. Check that OpenStreetMap tiles are accessible
102+
103+
For more information, visit the [Leaflet.js documentation](https://leafletjs.com/) and [OpenStreetMap](https://www.openstreetmap.org/).

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The project is intentionally simple to run locally (no heavy frontend tooling) b
1010
- Hospital directory helps route animals to the right care.
1111
- Donors can record donations with automatic email receipts (if SMTP configured).
1212
- Admin/NGO actions use JWT for protected routes.
13+
- **NEW**: Comprehensive data integration system for emergency services (police, fire, blood banks, etc.)
14+
- **NEW**: Interactive data dashboard for importing, visualizing, and managing multiple datasets.
1315

1416
## Tech Stack
1517
- **Backend**: Flask, SQLAlchemy, Alembic (Flask‑Migrate), JWT, Flask‑Mail, Flask‑CORS, SQLite (default) or any SQL via `DATABASE_URL`.
@@ -49,6 +51,11 @@ python -m flask db upgrade
4951

5052
Optional: load sample data (inspect `docs/sql/sample_data.sql`).
5153

54+
**NEW**: Import comprehensive emergency services data:
55+
```bash
56+
python import_sample_data.py
57+
```
58+
5259
### 4) Run the backend (API)
5360
```bash
5461
python backend/wsgi.py
@@ -63,6 +70,12 @@ python -m http.server 8000
6370
```
6471
Visit `http://localhost:8000/index.html`.
6572

73+
**NEW**: Access the Data Dashboard at `http://localhost:8000/data-dashboard.html` for:
74+
- Import/export CSV datasets
75+
- Visualize emergency services distribution
76+
- Manage NGOs, volunteers, hospitals, police stations, blood banks, fire stations
77+
- View real-time statistics and analytics
78+
6679
Front‑to‑back integration is configured via `frontend/assets/js/api.js`:
6780
```js
6881
const API_BASE = 'http://localhost:5000';
@@ -113,6 +126,14 @@ Base URL: `http://localhost:5000`
113126
- `POST /uploads` (multipart, field `file`) → `201 { filename, url }`
114127
- `GET /uploads/<filename>` → serves the uploaded file
115128

129+
### Data Integration (NEW)
130+
- `POST /data/import/<type>` (JWT required) → `201 { message, stats }`
131+
- types: `ngos`, `volunteers`, `hospitals`, `police-stations`, `blood-banks`, `fire-stations`
132+
- `GET /data/export/<type>` (JWT required) → `200 { message, download_url }`
133+
- `GET /data/statistics` (JWT required) → `200 { statistics, location_distribution }`
134+
- `GET /data/emergency-contacts``200 { contacts: [...] }`
135+
- `GET /data/nearby-services?location=<city>&service_type=<type>``200 { services: [...] }`
136+
116137
### Common Errors
117138
- `400` Missing/invalid fields
118139
- `401` Invalid credentials or missing token
@@ -121,6 +142,7 @@ Base URL: `http://localhost:5000`
121142
## Data model (high‑level)
122143
- `AnimalCase` with `case_code`, contact/location, type, urgency, notes, optional `media_url`, and `status`.
123144
- `NGO`, `Volunteer`, `Hospital`, `Donation` entities with essential fields.
145+
- **NEW**: `PoliceStation`, `BloodBank`, `FireStation`, `EmergencyContact` for comprehensive emergency services.
124146
- See `docs/architecture/ERD.md` and `backend/app/models.py` for complete definitions.
125147

126148
## Configuration & Operations
@@ -138,16 +160,22 @@ backend/
138160
extensions.py
139161
utils.py
140162
mailer.py
163+
data_integration.py # NEW: Data import/export system
141164
config.py
142165
wsgi.py
143166
frontend/
144-
index.html report.html register.html donate.html hospitals.html
167+
index.html report.html register.html donate.html hospitals.html data-dashboard.html # NEW
145168
assets/css/styles.css
146-
assets/js/api.js app.js
169+
assets/js/api.js app.js data-dashboard.js # NEW
147170
docs/
148171
PRD.md
149172
architecture/ERD.md, DFD.md
150173
sql/schema.sql, sample_data.sql
174+
DATA_INTEGRATION.md # NEW: Comprehensive data integration guide
175+
DATA_INTEGRATION_QUICK_REFERENCE.md # NEW: Quick reference
176+
sample_data/ # NEW: Sample CSV files
177+
ngos.csv volunteers.csv hospitals.csv police_stations.csv blood_banks.csv fire_stations.csv
178+
import_sample_data.py # NEW: Data import script
151179
```
152180

153181
## Contributing

backend/app/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .routes.donations import donations_bp
1111
from .routes.uploads import uploads_bp
1212
from .routes.admin import admin_bp
13+
from .routes.data import data_bp
1314

1415

1516
def create_app(config_class: type = Config) -> Flask:
@@ -38,5 +39,6 @@ def create_app(config_class: type = Config) -> Flask:
3839
app.register_blueprint(donations_bp)
3940
app.register_blueprint(uploads_bp)
4041
app.register_blueprint(admin_bp)
42+
app.register_blueprint(data_bp)
4143

4244
return app

0 commit comments

Comments
 (0)