Welcome to our 2024's Hackathon project!
This week we'll be working on a new notification solution: WebHooks!! 🎉
I hope you're all excited for this, we'll need motivation to endure the hardships ahead.
We're facing some tough challenges, so we should prepare ourselves first.
Here's a list of topics that will come up in our journey:
Y'all found this repository with an initial structure, this doesn't mean that the structure won't change, but if it does please update this document to reflect the latest structure.
.vscode
VSCode configscmd
CLI Commandscall
Call Webhooks Grpcserve
Run Application
demo
Examplesgrpc
Create Messages from gRPCpubsub
Create Messages from PubSubtemporal
Create Messages from Temporal
package
Generic Codeactor
Lifecycle Managercron
Base Cron Adapternet
Network Modulesgrpc
Grpc Actorsserver
Grpc Adapterclient
Grpc Provider
http
Http Actorsserver
Http Adapterclient
Http Provider
third
Third party portstemporal
client
Provider for temporalworker
Adapter for Activities and Workflows
vault
Provider for Vault
app
Application Utilitiescfg
Configuration Utilitiescmd
Command Line Utilitiesflag
Flag Utilities
util
Generic Utilities
webhooks
Implementationadapt
Application Adapterscron
Cron for Workersgrpc
Internal APIv1
Grpc Definition
http
External APIv1
OAPI Definition
pub
Publisherv1
Produced Message Definition
subs
Subscriberv1
Consumed Message Definition
work
Workflows and Activitiesv1
Workflow or Activity Message Definition
provide
Provider Implementationspub
Publisherrepo
Postgres Accessmigrations
Database DDLqueries
Database DQL/DML
secrets
Vault Access
render
HTML renderscomponents
Reusable Atomic Componentsatom
Simple Composable Componentsmolecule
Encapsulation of Components
layouts
Reusable Aggregate Dispositionspages
Pages to Renderscripts
Reusable JavaScriptstyles
Style Definitionsutils
Utility Methods
Since it's not easy to understand the organization of an application from the folder structure alone, here's a little drawing to help you get a high level idea of the pieces of this service and how they're conected.
graph LR
Temporal
Activity
Topic
Grpc
API
Activity --> Repo
Activity --> PubSub
Temporal --> Activity
Customers --> API
GraphQL --> Grpc
PubSub --> Topic
Activity --> Secrets
Cron --> Secrets
Grpc --> Secrets
API --> Secrets
Cron --> Repo
Grpc --> Repo
API --> Repo
Topic --> Repo
Cron --> Endpoints
Since you'll be persisting data you need to be aware of the structure and relations that the data has, for that purpose you can use the following diagram to refresh your memory. TODO: This section is still incomplete, please update it when possible.
erDiagram
EventType {
string key
}
Channel {
string key
}
Application {
string key
}
Endpoint {
string key
}
Message {
string key
}
Attempt {
string key
}
Secret {
string key
}
Message }o--|| EventType : "has one"
Message }o--|| Channel : "has one"
Message }o--|| Application : "has one"
Attempt }o--|| Message : "has one"
Attempt }o--|| Endpoint : "has one"
Application ||--o{ Secret : "has"
Endpoint }o--|| Application : "has one"
Endpoint }o--o{ Channel : "has many"
Endpoint }o--o{ EventType : "filter"
Endpoint }o--o| Secret : "use"
In order to make your developement experience more pleasant this repository makes use of some third-party tools.
You can check the following links for more documentation on each:
make
alias formake down db gen
make up
alias fordocker-compose up -d
make down
alias fordocker-compose down
make wait CONTAINER=...
waits for container to be healthymake gen
alias formake gen/grpc gen/api gen/db
make gen/grpc
Generates gRPC structursmake gen/api
Generates HTTP structuresmake gen/db
Generates SQL structures
make db
alias formake db/up db/push
make db/up
starts db and waits for it to be healthymake db/push
runs db migrations
postgres
databasevault
secret manager
OpenAPI Client and Server Code Generator
Database migrations written in Go
Generate type safe Go methods from Postgres SQL queries
An HTML templating language for Go that has great developer tooling
- Clone:
git clone https://github.com/andrestielau/web-of-hooks
- Enter:
cd web-of-hooks
- Bootstrap:
make
(yes, justmake
) - Run:
make dev
Unless migrations change, you only need to change this. - Test
https://port3000.[your-name].anchorlabs.dev/health
- Adapters
- Http
- Grpc
- Subs
- Work
- Services
- Manager
- Worker
- Providers
- Repo
- Secrets
- onboard tenants (create applications) (grpc + db)
- register event-types (CRUD event-types) (grpc + db)
- manage configs (edit application + CRUD endpoint) (http/grpc + db)
- register messages (create message) (grpc/http/pubsub/temporal + db)
- worker calls (dequeue + submit)
- Integrate grpc with GraphQL (grpc + graphql)
- Integrate with existing workflows (temporal)
- Integrate with existing API (http)
- Integrate with Backoffice Dashboard
- Integrate with Client Dashboard
- Reusable Secrets
- Publish Errors and/or Successes
- OTEL Metrics
- Store Responses (and maybe requests) in FileStorage
Content-Type
Negotiator (get preferred content type fromAccept
headers and response formats for each endpoint)
When you get the error listen tcp :3000: bind: address already in use
Run: netstat -nlp | grep 3000
You'll see something like: tcp6 0 0 :::3000 :::* LISTEN {PID}/web-of-hooks
Then run: kill -9 {PID}
Why separate secret management from endpoint configuration?
- Decoupled storage: instead of salting, hashing, or alike and store secrets on the database, these can be stored in vault so that they're never exposed.
- Reusability since some clients might want to receive webhooks in different endpoints on the same server, they might also want to use the same secret.
- Using Authorized API Key, customer requests latest validation keys for endpoints
- Whenever a customer endpoint receives a message, they can use the endpoint's key to