Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions docs/backend_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Backend Setup Guide

This guide covers setting up the LifeLine-ICT FastAPI backend locally.

## Prerequisites

- Python 3.11+
- pip

## Installation

```bash
cd backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
```

## Running the API

```bash
uvicorn backend.app.main:app --reload
```

API available at: `http://127.0.0.1:8000`
Swagger docs at: `http://127.0.0.1:8000/docs`

## Database Migrations

```bash
alembic upgrade head
```

## Running Tests

```bash
pytest backend/tests
```

## API Endpoints

| Method | Endpoint | Description |
|--------|---------------------------------|------------------------------|
| GET | /api/v1/projects | List all ICT projects |
| POST | /api/v1/projects | Create a new project |
| GET | /api/v1/projects/{id} | Get project by ID |
| PUT | /api/v1/projects/{id} | Update a project |
| DELETE | /api/v1/projects/{id} | Delete a project |
| GET | /api/v1/resources | List all ICT resources |
| POST | /api/v1/resources | Create a new resource |
| GET | /api/v1/locations | List all locations |
| POST | /api/v1/locations | Create a location |
| GET | /api/v1/maintenance-tickets | List maintenance tickets |
| POST | /api/v1/maintenance-tickets | Create a maintenance ticket |
| GET | /api/v1/sensor-sites | List IoT sensor sites |
| POST | /api/v1/sensor-sites | Create a sensor site |

## Business Rules

- A resource **cannot be deleted** while it has open maintenance tickets
- Closing a ticket **requires** a resolution note
- Sensor sites must be linked to an existing resource and location
46 changes: 46 additions & 0 deletions docs/iot_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# IoT Sensor Setup Guide

This guide covers setting up the ESP32 sensor nodes and the Flask logging service.

## Flask Logger Setup

```bash
cd iot/logging
python -m venv .venv
source .venv/bin/activate
pip install flask
python app.py
```

Logger runs at: `http://0.0.0.0:5000`

## Endpoints

| Method | Endpoint | Description |
|--------|-----------|------------------------------|
| POST | /log | Receive sensor telemetry |
| GET | /health | Check logger status |
| GET | /logs | View recent log entries |

## Sending Data from ESP32

Configure your ESP32 sketch with:
```cpp
const char* serverUrl = "http://YOUR-SERVER-IP:5000/log";
```

## Sample Payload

```json
{
"sensor_id": "ESP32-001",
"temperature": 24.5,
"humidity": 68.2,
"flood_level": 12.3,
"timestamp": "2026-04-21T10:30:00Z"
}
```

## Data Storage

Telemetry is stored in SQLite at `iot/logging/telemetry.db`
Loading