Skip to content
Merged
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
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# garge-api

ASP.NET Core 8 REST API for the Garge garage monitoring system. Handles authentication, sensor data persistence, automation rule evaluation, and orchestrates switch commands to garge-operator via webhooks.

## What it does

- Stores sensor readings (battery voltage, temperature, humidity) in PostgreSQL
- Evaluates automation rules and triggers switch commands (e.g. start charger when battery drops below 12.5 V)
- Fetches hourly electricity prices from Nord Pool for demand-responsive automations
- Sends webhooks to garge-operator when a switch should toggle
- Manages user accounts and authentication (JWT + refresh tokens)

## Tech stack

- **ASP.NET Core 8** Web API
- **PostgreSQL** — Entity Framework Core 9 (Npgsql)
- **ASP.NET Identity** + JWT Bearer tokens
- **AutoMapper** — entity ↔ DTO mapping
- **Serilog** — structured logging
- **Swagger** — API docs at `/swagger`

## Configuration

Secrets are set via environment variables (or .NET User Secrets in development):

| Key | Description |
|-----|-------------|
| `ConnectionStrings__DefaultConnection` | PostgreSQL connection string |
| `Jwt__Key` | Secret key for signing JWT tokens |
| `Jwt__Issuer` / `Jwt__Audience` | JWT issuer and audience |
| `Email__ApiKey` | SendGrid or Brevo API key |

## Running

```bash
dotnet ef database update # apply migrations
dotnet run
```

API docs available at `http://localhost:5277/swagger`.