From 7cdc561dcce056e0b8d12ba21f3907eae8704cb8 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 29 Mar 2026 14:47:48 +0200 Subject: [PATCH] Update README: document sqlc instead of GORM --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dde9711..dc5adec 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A self-sufficient web application to manage an ISPmail (Postfix, Dovecot, Rspamd ## Tech Stack -- **Backend**: Go with Gin framework, GORM for database +- **Backend**: Go with Gin framework, sqlc for type-safe SQL - **Frontend**: SvelteKit - **Database**: MariaDB/MySQL (shared with mail server ISPmail schema) - **Auth**: JWT-based authentication @@ -40,7 +40,9 @@ imc-vibe/ │ │ └── handlers/ # HTTP handlers │ ├── auth/ # JWT authentication │ ├── config/ # Configuration loading -│ ├── db/ # Database models and operations +│ ├── db/ # Database access layer +│ │ ├── queries/ # SQL query files (sqlc source) +│ │ └── sqlc/ # Generated type-safe Go code │ └── mail/ # Mail server integration (postqueue, logs, quota) ├── frontend/ # SvelteKit frontend │ ├── src/ @@ -121,6 +123,26 @@ The app creates these tables automatically: Existing ISPmail tables (`virtual_domains`, `virtual_users`, `virtual_aliases`) are used for mail data. +### Database Access with sqlc + +The app uses [sqlc](https://sqlc.dev/) for type-safe database access: + +- SQL queries are defined in `backend/internal/db/queries/*.sql` +- Type-safe Go code is generated with `sqlc generate` into `backend/internal/db/sqlc/` +- **Do not edit files in `sqlc/`** - they are regenerated from queries + +To regenerate after changing queries: + +```bash +cd backend && sqlc generate +``` + +Enable SQL query logging in development: + +```bash +USE_EMBEDDED=false ./build/imc +``` + ## Systemd Service Example service file at `/etc/systemd/system/imc.service`: @@ -151,6 +173,7 @@ WantedBy=multi-user.target - Go 1.21+ - Bun (for frontend development) +- sqlc (for database code generation) - MariaDB/MySQL - Postfix (with postqueue/postsuper) - systemd-journald (for log viewing)