refactor(API): Relspect integration
Some checks failed
CI / Test (1.23) (push) Failing after -22m46s
CI / Test (1.22) (push) Failing after -22m32s
CI / Build (push) Failing after -23m30s
CI / Lint (push) Failing after -23m12s

This commit is contained in:
Hein
2026-02-05 13:39:43 +02:00
parent 71f26c214f
commit f9773bd07f
33 changed files with 7512 additions and 58 deletions

56
PLAN.md
View File

@@ -9,30 +9,44 @@ Whet a hook is called, it must send a message to whatsapp.
Name the hooks and enpoints correctly.
Two way communication is needed.
First Phase:
First Phase: COMPLETED
Instance / Config level hooks and whatsapp accounts.
Text/HTML messages only for a start.
- config package: That contains all configuration data for the application, including database connection information, API keys, etc.
- logging package: This package should handle logging in a structured way. It should be able to log errors, warnings, and other messages with different levels of severity.
- whatsapp package: This package must use https://github.com/tulir/whatsmeow to connect to multiple whatsapp accounts.
- whatsapp api package: This package must use the official whatsapp business api for sending messages to whatsapp accounts.
- whatshook server command: The server should start and connect to a given whatsapp accounts via config. New message must be pushed to all created hooks.
- whatshook cli command: Do connection via server, and push new message to hooks via server. Check server health. Add accounts. Add hooks.
events system: Whatsapp api events must be sent / received via the event system. The events system must publish to the hooks and whatsapp apis.
For example, whatsapp notifies of connect,disconnect message received events etc.
Web handlers for hooks to send whatsapp messages. Events must then be publish on successfull or failes sends.
Document/Images message and other types of messages.
- config package: Configuration via viper, loaded from config.json. Covers server host/port, whatsapp accounts, hooks, MQTT, and WhatsApp Business API credentials.
- logging package: Structured logging with severity levels using zerolog.
- whatsapp package (whatsmeow): Connects to personal WhatsApp accounts via tulir/whatsmeow. Handles QR code auth flow, session persistence, and message send/receive.
- whatsapp package (businessapi): WhatsApp Business API integration. Supports sending messages, templates, extended sending, business profile and catalog management.
- server command: HTTP server exposing hook endpoints, health check (/health), and QR code streaming for account pairing. Runs on configurable port (default 8825).
- cli command: Cobra-based CLI for server interaction — health checks, account management, hook management, and pushing messages via the server.
- events system: Pub/sub event bus for whatsapp lifecycle events (connect, disconnect, message received, send success/failure). Events flow between whatsmeow, business API, hooks, and MQTT.
- hooks package: Webhook registration and HTTP dispatch. Incoming whatsapp messages are forwarded to all registered hook URLs.
- cache package: In-memory message caching layer.
- event logger: Persistent event logging to disk for debugging and audit.
- MQTT support: Optional MQTT broker integration for event routing and message delivery.
- Docker: Dockerfile and docker-compose with health checks, session/config volume mounts, and resource limits.
- CI/CD: GitHub Actions workflows with lint and test steps.
- Static pages: Privacy policy and terms of service served via the server.
Second Phase:
User level hooks and whatsapp accounts.
- webserver package: Must provide a web server that can serve the application's frontend and API endpoints. based on https://github.com/bitechdev/ResolveSpec
- webserver template subpackage: Must contain all templates for the application.
- api subpackage: Must contain all API endpoints and implement https://github.com/bitechdev/ResolveSpec
- auth package: This package should handle authentication in a secure way. It should be able to authenticate users, generate tokens, and verify user credentials.
- Setup a tooldoc folder for you if not exists to save summaries of the tools you must use. Reference what is there as well. Update it if you found new tools or more information on tools.
- Save library and tools usage instructions for you.
- Make a code guideline for you
- Use makefile to build, test and migrate. For backend and frontend. e.g. build build-ui build-server etc.
- Storage in postgresql and sqlite based on user selection.
- Use relspecgo to convert dbml database models to BUN models. https://git.warky.dev/wdevs/relspecgo
- Place sql in sql/ folder, dbml models in sql/schema.dbml file
- Scripts in sql/postgres and sql/sqlite folders
- Place models in models package
- webserver package: Use https://github.com/bitechdev/ResolveSpec It has a server package. Its has security and authentication as well. Use as much as you can from ResolveSpec for the project.
- Link: https://github.com/bitechdev/ResolveSpec
- Use BUN ORM
- Use React with Mantine and Tanstack Start for the admin site.
- api subpackage: Must contain all API endpoints and implement https://github.com/bitechdev/ResolveSpec
- Use oranguru for grids and forms. -> https://git.warky.dev/wdevs/oranguru
- Interface:
- auth package: This package should handle authentication in a secure way. It should be able to authenticate users, generate tokens, and verify user credentials. Use Resolvespec for API Auth.
- User login
- API Keys per user.
- User interace to setup user level hooks and whatsapp accounts.