Changes for README.md: 85 added lines, 0 removed lines.
Original line number
Diff line number
Diff line
# Farm Energy Management System
This monorepo combines two Python services that share a single data directory:
1.**`data-fetcher-project/`** polls public and private APIs (energy prices, weather, SuomiConnect metering, Volter predictions) and writes the results into CSVs under `data/`, while rotating historical snapshots into `archive/`.
2.**`ui-project-v2/`** is the Gradio 5 powered dashboard serving operators in production.
Both services run under Python 3.12 and are orchestrated with Docker Compose for parity between local development and production use.
## Repository layout
```
.
├── data-fetcher-project/
│ ├── data/ # latest CSVs (volume-shared)
│ ├── archive/ # historical CSV backups
│ └── src/ # domain fetchers + common helpers
├── ui-project-v2/ # Main UI Application
│ ├── app/ # Gradio layout, config, and helpers
│ └── content/ # Operator-editable site context notes (EN/FI)
├── docker-compose.yml
└── .env.example
```
## Quick start
1. Create a `.env` in the repository root using `.env.example` as a template.
2. Install Docker + Docker Compose.
3. Bring everything up:
```bash
docker-compose up --build
```
The fetcher will populate `data-fetcher-project/data/` while the UI serves Gradio on <http://localhost:7860>.
### Local UI without Docker
```bash
cd ui-project-v2
python -m venv venv
source venv/bin/activate
pip install-r requirements.txt
DEBUG_PLOTS=1 python app.py # listens on 7860
```
### One-off data ingestion
```bash
cd data-fetcher-project
python -m venv venv
source venv/bin/activate
pip install-r requirements.txt
python main.py
```
### Test & lint shortcuts
-`cd ui-project-v2 && python -m pytest` – regression pass for the upgraded Gradio 5 stack.
-`docker-compose logs -f` – tail both services when validating changes inside containers.
## Configuration
The root `.env` file is loaded by both services. Key variables:
All timestamps must remain in UTC inside stored CSVs; the UI converts to local time on display through `app/time_utils.py` and documents the exact observation times in the “Current Data” panel.
### Editable site context & operator notes
Static operational constraints shown to the LLM live in `ui-project/content/site_context_en.md` and `ui-project/content/site_context_fi.md`. Update those files whenever on-site limits change (e.g., CHP capacity, grid policies). The UI automatically picks the language that matches the current selection.
## Development workflows
-**Fetchers:** add a new `src/<domain>/fetch.py`, register it in `FETCHERS` within `data-fetcher-project/main.py`, and ensure the output schema remains backward compatible (update archives if not).
-**UI:** extend the modular helpers under `ui-project-v2/app/`. Keep `app.py` as a thin orchestration layer.
-**LLM prompts:** the context builder now computes a price severity scale, daylight conditions, and grid guidance. Reuse helpers in `app/context_builder.py` when expanding prompt content.
-**Testing / smoke checks:**
-`docker-compose up` – end-to-end validation
-`DEBUG_PLOTS=1 python app.py` – desktop UI run with additional diagnostics
- Inspect `logs/` for service output when running via Docker