A self-hosted web application for keeping track of the land you own — where each piece is, what shape it is and how big.
Early stage. Hektar is usable today — you can walk a boundary, store it and get its area — but it is a young project. The data model still moves, there are no database migrations yet (a schema change means starting the database over), and everything under Where it is heading is an intention rather than a feature. Expect rough edges and breaking changes.
Hektar is a record of the land you own. Each piece is stored as its outline on a map, with the area worked out from that outline, so you have one place that says what you hold and how much of it there is.
The main way to add a piece of land is to walk it. Take your phone to the property, turn on live GPS mode, and tap to capture a point as you stand on each corner. Hektar joins the points into a shape, draws it on a map, and calculates the area inside — in square metres, shown as hectares and acres. The reading shows the GPS accuracy at each point, so you can see how much to trust it.
You run the whole thing yourself — on a home server, a NAS, a spare machine or a small VPS — so the record of what you own stays on hardware you control. Once it is running, open its address in the browser on your phone and take the phone to the property. There is no app to install and no account with anyone else; the phone only needs to reach the URL. See Walking your land with a phone for the one setup detail that matters.
If you cannot get to the land, or you already have the numbers, there are three other ways in: tap the corners on a satellite map, type the coordinates in decimal degrees or degrees/minutes/seconds, or paste a whole list at once from a handheld GPS or a spreadsheet.
Records are kept in two levels. A zone is one connected piece of land: a single shape with a name, an optional description, its corner points and its area. A collection groups related zones — everything on one property, for example — and shows their combined area. Every account sees only its own data.
The whole thing runs from a single docker compose up, stores data in a local
SQLite file, and depends on no third-party service beyond map tiles. The
interface ships in German (the default) and English.
Measuring land is the first half of the idea. Three things are intended to follow. None of them exists yet — they are here so you know what the project is aiming at, not what it does.
Knowing what your land is worth. The aim is for each zone to carry enough information to estimate what it would fetch if you sold it: the condition of the land, road access and street infrastructure, what is nearby, and the other things that move the price. Today a zone holds its outline, its area and a free-text description, and Hektar puts no value on anything.
A mobile app. Capturing a boundary means being outdoors with a phone, and a browser is an awkward place to do that, and it is the reason for the HTTPS requirement in Walking your land with a phone. The plan is a native app that talks to the same API and replaces the browser for capture work. The shape of the code already points that way: the backend is a plain REST API and the React frontend is only one client of it.
A self-hosted backend. Running your own server is a real barrier for someone who just wants to measure their field. The longer-term intent is a hosted instance that the mobile app talks to, so using Hektar means installing an app rather than administering a service. Self-hosting stays possible either way — the licence and the Compose setup are not going anywhere.
Hektar is for keeping your own records. It is not an official or legal tool. The area is worked out by flattening the coordinates onto a plane (see Measurement accuracy), which is good enough for everyday use but is not survey-grade, and the numbers carry no legal weight. Hektar does not replace a licensed surveyor or professional measuring equipment.
Capturing boundaries
- Tap or click on the map to drop boundary points; tap an existing point to remove it, or drag it to adjust
- Live GPS mode adds your current device position as a boundary point, with an accuracy readout
- Type coordinates in decimal degrees (
47.5162 14.5501) or DMS (47°30'58.3"N 14°33'0.4"E) - Bulk import: paste a whole list of coordinate pairs, one per line
Viewing and measuring
- Satellite and street map layers, backed by OpenStreetMap tiles
- Polygon overlay with numbered boundary markers
- Live area preview that updates as points are added or moved, before saving
- Area shown in hectares and acres; collections show a combined total
- Map thumbnail for each collection
Organising
- Collections group related zones; zones hold the coordinates
- Full create / edit / delete for collections, zones and individual coordinates
- Per-user data isolation — accounts cannot see each other's records
- Duplicate names are rejected within a collection, and across a user's collections
Platform
- Multi-user registration and JWT login, with bcrypt password hashing
- German and English interface, switchable at runtime
- Mobile-friendly layout for use outdoors
- Interactive API documentation generated at
/docs - Runs as two containers via Docker Compose
git clone https://github.com/rsamer/hektar.git
cd hektar
cp .env.example backend/.env # then set SECRET_KEY
docker compose up --build| Service | URL |
|---|---|
| Frontend | http://localhost:5173 |
| API | http://localhost:8000 |
| API documentation | http://localhost:8000/docs |
Or run ./start.sh, which performs the same steps and creates backend/.env
for you if it is missing.
Backend (Python 3.11 or newer recommended):
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp ../.env.example .env
uvicorn app.main:app --reloadFrontend (Node 20 or newer):
cd frontend
npm install
npm run devVite proxies /api to http://localhost:8000, so both servers need to be
running.
Capturing a boundary on foot is the main way to use Hektar, and it needs one thing to be set up correctly.
Live GPS mode only works over HTTPS. Browsers hand out a device's location
only in a secure context, which means an https:// address or localhost. A
self-hosted instance opened on a phone as http://192.168.1.10:5173 will load
and show maps quite happily, but the browser will refuse to give it your
position and live mode will stay empty. This catches people out, because
everything else about the page looks fine.
So:
- Run Hektar somewhere your phone can reach — the same home network is enough, or a small VPS if you want it available away from home.
- Put it behind HTTPS. A reverse proxy such as Caddy or nginx with a certificate is the usual way; a certificate from your own internal authority works too, as long as the phone trusts it.
- Add that address to
CORS_ORIGINS(see Configuration). It must be the exact origin you load in the browser — a wildcard will not do. - On the phone, open the address, log in, start a new zone, and turn on live mode. Walk to each corner of the land, wait for the accuracy reading to settle, and tap to capture the point.
The area updates as you go, so you can see the shape and its size take form before you save anything.
The backend reads its configuration from the environment, or from backend/.env.
Copy .env.example to get started.
| Variable | Default | Purpose |
|---|---|---|
ENVIRONMENT |
development |
Set to production to enforce the SECRET_KEY check |
SECRET_KEY |
(generated per start) | Signing key for JWTs. Generate with openssl rand -hex 32 |
DATABASE_URL |
sqlite:///./hektar.db |
Any SQLAlchemy connection URL |
ACCESS_TOKEN_EXPIRE_MINUTES |
1440 |
Token lifetime in minutes |
CORS_ORIGINS |
http://localhost:5173,http://127.0.0.1:5173 |
Allowed frontend origins, comma-separated or JSON |
Two behaviours are worth knowing:
- When
SECRET_KEYis unset in development, a random key is generated at startup. This keeps first-run setup frictionless, but every restart invalidates existing tokens and forces users to log in again. - When
ENVIRONMENT=productionandSECRET_KEYis unset, the application refuses to start rather than signing tokens with a throwaway key.
CORS_ORIGINS must list exact origins. A wildcard cannot be combined with
credentialed requests — browsers reject the response.
User
└── Collection "Home property" total area across zones
└── Zone "North field" shape + calculated area
└── Coordinate ordered lat/lon points defines the boundary
A zone needs at least three coordinates before it encloses an area. Coordinates
carry an explicit order field, which fixes the sequence the edges are drawn in
— reordering points changes the shape, not just the list.
Area is calculated server-side, not in the browser, so every client gets the same
number and stored areas stay consistent. It is recalculated automatically
whenever a zone's coordinates are created, updated or deleted, and cached on the
zone as area_m2.
The calculation projects the WGS84 longitude/latitude pairs onto a plane using an equirectangular projection centred on each vertex's latitude, then applies the shoelace formula.
The projection above distorts the shape, and the distortion grows with the size of the area and its distance from the equator. For an area of a few hectares at middle latitudes the error is small enough for everyday use; it gets worse for large areas, areas spanning a wide range of latitude, and anything near the poles.
If you need survey-grade numbers, replace calculate_polygon_area in
backend/app/core/geodesy.py with a geodesic
computation on the WGS84 ellipsoid — pyproj.Geod.geometry_area_perimeter is a
drop-in path. This is on the roadmap.
Both input fields and bulk import accept:
| Format | Example |
|---|---|
| Decimal degrees | 47.5162 14.5501 |
| Decimal degrees, comma-separated | 47.5162, 14.5501 |
| DMS with symbols | 47°30'58.3"N 14°33'0.4"E |
| DMS, space-separated | 47 30 58.3 N, 14 33 0.4 E |
| Colon-separated | 47:30:58.3 |
Southern and western coordinates are written with an S/W suffix or a leading
minus sign. Bulk import takes one pair per line, latitude first:
47.5162 14.5501
47.5168 14.5510
47.5171 14.5495
Browser
│ React 18 + TypeScript, Leaflet map, react-i18next
│ Vite dev server on :5173 (nginx in production)
▼
FastAPI on :8000
│ JWT auth · Pydantic validation · SQLAlchemy ORM · Shapely geometry
▼
SQLite (or any SQLAlchemy-supported database via DATABASE_URL)
| Layer | Technology |
|---|---|
| Backend | FastAPI, SQLAlchemy 2, Pydantic 2, Shapely, python-jose, passlib/bcrypt |
| Frontend | React 18, TypeScript, Vite, Leaflet + react-leaflet, Axios, react-i18next |
| Database | SQLite by default; any SQLAlchemy URL |
| Packaging | Docker, Docker Compose, nginx for the production frontend image |
hektar/
├── backend/
│ ├── app/
│ │ ├── api/
│ │ │ ├── auth.py registration, login, token issuing
│ │ │ └── routes.py collections, zones, coordinates
│ │ ├── core/
│ │ │ ├── config.py environment-driven settings
│ │ │ ├── database.py engine and session factory
│ │ │ ├── geodesy.py coordinate parsing and area calculation
│ │ │ └── security.py hashing and JWT encode/decode
│ │ ├── models/models.py SQLAlchemy tables
│ │ ├── schemas/schemas.py request and response models
│ │ └── main.py application setup, CORS, health check
│ ├── tests/ pytest suite
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── components/ Header, MapView, CollectionMapPreview, LanguageSwitcher
│ │ ├── pages/ login, collections, zones, create/edit screens
│ │ ├── contexts/ authentication state
│ │ ├── locales/ de.json, en.json
│ │ ├── utils/ API client, coordinate helpers
│ │ └── styles/
│ ├── nginx.conf production static serving
│ └── Dockerfile multi-stage: development, build, production
├── .github/workflows/ci.yml backend, frontend, docker and secret-scan jobs
├── .githooks/pre-commit blocks committed secrets and .env files
├── .gitleaks.toml secret-scanner rules
├── docker-compose.yml
├── CONTRIBUTING.md
└── DEVELOPMENT.md
| Table | Columns |
|---|---|
users |
id, email (unique), password_hash, created_at |
collections |
id, name, description, user_id, created_at — unique on (name, user_id) |
zones |
id, name, description, collection_id, user_id, area_m2, created_at — unique on (name, collection_id) |
coordinates |
id, longitude, latitude, zone_id, order, created_at |
Deleting a collection cascades to its zones; deleting a zone cascades to its coordinates. Tables are created automatically at startup — there is no migration tool yet, so changing a model means recreating the database.
Interactive documentation is served at /docs while the backend is running.
All endpoints except registration, login and /health require an
Authorization: Bearer <token> header.
| Method | Path | Description |
|---|---|---|
POST |
/api/auth/register |
Create an account. Body: {"email": ..., "password": ...}. Minimum password length is 8 |
POST |
/api/auth/login |
Exchange credentials for a token. Body: {"email": ..., "password": ...} |
| Method | Path | Description |
|---|---|---|
GET |
/api/collections |
List the current user's collections |
POST |
/api/collections |
Create a collection |
GET |
/api/collections/{id} |
Fetch one collection with its zones |
PUT |
/api/collections/{id} |
Rename or re-describe |
DELETE |
/api/collections/{id} |
Delete, cascading to zones |
| Method | Path | Description |
|---|---|---|
POST |
/api/zones |
Create a zone, optionally with its full coordinate list |
GET |
/api/zones/{id} |
Fetch a zone with coordinates and area |
PUT |
/api/zones/{id} |
Update name or description |
DELETE |
/api/zones/{id} |
Delete, cascading to coordinates |
| Method | Path | Description |
|---|---|---|
GET |
/api/zones/{zone_id}/coordinates |
List a zone's coordinates in order |
POST |
/api/zones/{zone_id}/coordinates |
Append a coordinate and recalculate area |
PUT |
/api/coordinates/{id} |
Move a point and recalculate area |
DELETE |
/api/coordinates/{id} |
Remove a point and recalculate area |
curl -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"surveyor@example.com","password":"a-good-password"}'
TOKEN=$(curl -s -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"surveyor@example.com","password":"a-good-password"}' \
| python3 -c "import json,sys; print(json.load(sys.stdin)['access_token'])")
curl -X POST http://localhost:8000/api/collections \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"name":"Home property"}'See DEVELOPMENT.md for detailed setup, and CONTRIBUTING.md for conventions.
# Backend: lint and test
cd backend
pip install -r requirements-dev.txt
ruff check .
pytest -q
# Frontend: type-check and build
cd frontend
npm run typecheck
npm run buildCI runs the same commands on every push and pull request, across Python 3.11 and 3.12, and also builds both Docker images.
Before exposing Hektar to a network:
- Set
SECRET_KEYfromopenssl rand -hex 32 - Set
ENVIRONMENT=productionso a missing key fails loudly - Set
CORS_ORIGINSto your real frontend origin - Terminate TLS in front of the API — credentials and tokens travel in the clear otherwise, and live GPS mode will not work at all without it
- Build the frontend production image (
docker build --target production ./frontend), which serves the static bundle through nginx instead of the Vite dev server - Move off SQLite if more than one backend process will run
- Back up the database volume (
hektar-data) - Put rate limiting in front of
/api/auth/*
- Per-zone details that feed a valuation: condition of the land, road access, street infrastructure, utilities, what borders it
- Estimated sale value from those details, with the reasoning shown rather than a bare number
- A native mobile app for capturing boundaries, talking to the same API
- A hosted backend, so using Hektar does not require running a server
- Geodesic area calculation on the WGS84 ellipsoid
- GeoJSON and KML export, and import from file
- Database migrations (Alembic)
- Distance and bearing between points
- Sharing collections between accounts
- Offline capture for field use without connectivity