Update README: document sqlc instead of GORM
This commit is contained in:
parent
c4e3a31b69
commit
7cdc561dcc
1 changed files with 25 additions and 2 deletions
27
README.md
27
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue