Skip to content

Commit 0c97bdf

Browse files
committed
changes to readme
1 parent 892b078 commit 0c97bdf

1 file changed

Lines changed: 110 additions & 34 deletions

File tree

README.md

Lines changed: 110 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,133 @@
11
# ResQTrack
22

3-
ResQTrack is a web-based coordination platform for animal rescue operations connecting citizens, NGOs, volunteers, hospitals, and donors.
3+
ResQTrack is a lightweight, full‑stack web app that coordinates animal rescue across citizens, NGOs, volunteers, animal hospitals and donors. Citizens can quickly report an injured animal, NGOs and volunteers can act, hospitals can be listed, and donors can contribute — all tracked end‑to‑end.
4+
5+
The project is intentionally simple to run locally (no heavy frontend tooling) but still production‑minded on the backend (JWT auth, migrations, mail, uploads, CORS).
6+
7+
## What this project does
8+
- Citizens submit rescue reports (with optional photo/video) to create an incident.
9+
- NGOs/volunteers coordinate response and status updates.
10+
- Hospital directory helps route animals to the right care.
11+
- Donors can record donations with automatic email receipts (if SMTP configured).
12+
- Admin/NGO actions use JWT for protected routes.
413

514
## Tech Stack
6-
- Backend: Python Flask, SQLAlchemy, SQLite by default (override to MySQL with `DATABASE_URL`), JWT, Mail
7-
- Frontend: HTML/CSS/JS (Bootstrap)
15+
- **Backend**: Flask, SQLAlchemy, Alembic (Flask‑Migrate), JWT, Flask‑Mail, Flask‑CORS, SQLite (default) or any SQL via `DATABASE_URL`.
16+
- **Frontend**: HTML + Bootstrap + vanilla JS. No build step. Served as static files.
817

9-
## Getting Started
18+
## Quick Start (Windows‑friendly)
1019

1120
### 1) Prerequisites
1221
- Python 3.11+
13-
- Optional: MySQL 8+ (only if you set `DATABASE_URL` to a MySQL URI)
22+
- Optional: MySQL 8+ if you plan to use MySQL instead of SQLite
1423

15-
### 2) Clone and Install
24+
### 2) Setup Python environment
1625
```bash
1726
python -m venv .venv
18-
.venv\\Scripts\\activate
27+
.venv\Scripts\activate
1928
pip install -r requirements.txt
20-
cp .env.example .env
2129
```
2230

23-
SQLite is used by default. To use MySQL, set `DATABASE_URL` like `mysql://user:pass@host:3306/resqtrack` and install `mysqlclient` (requires MSVC build tools on Windows).
31+
Environment file (optional): copy and adjust if you maintain one.
32+
```bash
33+
# If you have an example env
34+
# copy .env.example .env (PowerShell: cp .env.example .env)
35+
```
36+
37+
Key environment variables (see `backend/config.py` for defaults):
38+
- `SECRET_KEY`, `JWT_SECRET_KEY`
39+
- `DATABASE_URL` (omit to use local SQLite `resqtrack.db`)
40+
- `MAIL_*` (SMTP settings for email receipts)
41+
- `CORS_ORIGINS` (defaults to `*` for local/dev)
2442

25-
### 3) Database Migrations
43+
### 3) Initialize the database
44+
SQLite is default; no server needed.
2645
```bash
2746
set FLASK_APP=backend/wsgi.py
28-
python -m flask db init
29-
python -m flask db migrate -m "init"
3047
python -m flask db upgrade
3148
```
3249

33-
(Optional) Load sample data:
50+
Optional: load sample data (inspect `docs/sql/sample_data.sql`).
51+
52+
### 4) Run the backend (API)
3453
```bash
35-
# With SQLite, use app endpoints or insert manually via scripts
36-
# With MySQL:
37-
# mysql -u <user> -p resqtrack < docs/sql/sample_data.sql
54+
python backend/wsgi.py
3855
```
56+
The API will be available at `http://localhost:5000` (health check at `/health`).
3957

40-
### 4) Run Server
58+
### 5) Run the frontend (static)
59+
From the `frontend/` directory, serve files with a simple HTTP server:
4160
```bash
42-
python backend/wsgi.py
61+
cd frontend
62+
python -m http.server 8000
4363
```
44-
Visit `http://localhost:5000/health`.
64+
Visit `http://localhost:8000/index.html`.
65+
66+
Front‑to‑back integration is configured via `frontend/assets/js/api.js`:
67+
```js
68+
const API_BASE = 'http://localhost:5000';
69+
```
70+
71+
### Frontend UX notes
72+
- Images are responsive (`img { max-width: 100%; height: auto; }`) and hero/card media use object‑fit to avoid distortion.
73+
- The story popup on CTA buttons is disabled; buttons now navigate directly to their target pages.
74+
75+
## End‑user flows
76+
- **Report**: `Report` page posts a case with optional file; returns a `case_code` for reference.
77+
- **Donate**: `Donate` page records a donation and sends a receipt email when SMTP is configured.
78+
- **Register**: `Register` page has tabs for NGO and Volunteer applications.
79+
- **Hospitals**: `Hospitals` page lists directory entries; admins/NGOs can add via API.
80+
81+
## API Reference
82+
83+
Base URL: `http://localhost:5000`
84+
85+
### Health
86+
- `GET /health``{ status: "ok" }`
87+
88+
### Auth
89+
- `POST /auth/login` body `{ email, password, role }``{ access_token }`
90+
- roles: `ADMIN`, `NGO`, `VOLUNTEER`
91+
92+
### Cases
93+
- `POST /cases` (public)
94+
- Accepts JSON or multipart form data. Fields: `reporter_name?`, `reporter_phone`, `reporter_email?`, `location`, `latitude?`, `longitude?`, `animal_type?`, `urgency?`, `notes?`, and optional `file`.
95+
- Response `201`: `{ message, case_id, case_code, media_url? }`
96+
- `PATCH /cases/<case_id>/status` (JWT required)
97+
- Body `{ status }` where status is one of backend `CaseStatus` enums.
98+
99+
### Registrations
100+
- `POST /register/ngo``201 { message, ngo_id }`
101+
- `POST /register/volunteer``201 { message, volunteer_id }`
102+
- `409` on duplicate `email`.
103+
104+
### Hospitals
105+
- `GET /hospitals``{ items: [...] }`
106+
- `POST /hospitals` (JWT required) → `201 { message, id }`
107+
108+
### Donations
109+
- `POST /donations``201 { message, id }`
110+
- If `donor_email` is provided and SMTP is configured, a receipt email is sent.
111+
112+
### Uploads
113+
- `POST /uploads` (multipart, field `file`) → `201 { filename, url }`
114+
- `GET /uploads/<filename>` → serves the uploaded file
115+
116+
### Common Errors
117+
- `400` Missing/invalid fields
118+
- `401` Invalid credentials or missing token
119+
- `409` Duplicate resource (e.g., `email` already registered)
45120

46-
### 5) Frontend
47-
Open `frontend/index.html` in your browser. Forms call the backend APIs.
121+
## Data model (high‑level)
122+
- `AnimalCase` with `case_code`, contact/location, type, urgency, notes, optional `media_url`, and `status`.
123+
- `NGO`, `Volunteer`, `Hospital`, `Donation` entities with essential fields.
124+
- See `docs/architecture/ERD.md` and `backend/app/models.py` for complete definitions.
48125

49-
## API Overview
50-
- GET `/health`
51-
- POST `/auth/login`
52-
- POST `/cases`, PATCH `/cases/<id>/status`
53-
- POST `/register/ngo`, POST `/register/volunteer`
54-
- GET/POST `/hospitals`
55-
- POST `/donations`
56-
- POST `/uploads`, GET `/uploads/<filename>`
126+
## Configuration & Operations
127+
- CORS is enabled (credentials supported). Tune origins via `CORS_ORIGINS`.
128+
- File uploads stored in `uploads/` by default; override `UPLOAD_FOLDER`. You can front this with a CDN or adapt to S3.
129+
- Mail uses standard SMTP. For Gmail, use App Passwords and set `MAIL_USERNAME`/`MAIL_PASSWORD`.
130+
- Migrations are managed via Alembic (Flask‑Migrate). Commit migration scripts in `migrations/` for schema changes.
57131

58132
## Project Structure
59133
```
@@ -68,17 +142,19 @@ backend/
68142
wsgi.py
69143
frontend/
70144
index.html report.html register.html donate.html hospitals.html
71-
assets/css styles.css
72-
assets/js api.js
145+
assets/css/styles.css
146+
assets/js/api.js app.js
73147
docs/
74148
PRD.md
75149
architecture/ERD.md, DFD.md
76150
sql/schema.sql, sample_data.sql
77151
```
78152

79-
## Notes
80-
- Emails use SMTP; for Gmail, enable App Passwords and set `MAIL_USERNAME`/`MAIL_PASSWORD`.
81-
- File uploads are stored under `uploads/`. For S3, configure AWS env vars and extend storage logic.
153+
## Contributing
154+
1. Fork + branch from `main`.
155+
2. Make changes with clear commits.
156+
3. If you change the database, add a migration: `flask db migrate -m "..."` then `flask db upgrade` locally and include the generated script.
157+
4. Open a PR describing the change, rationale, and testing steps.
82158

83159
## License
84160
MIT

0 commit comments

Comments
 (0)