SAMO = same old shit -- is dead. A reference architecture dedicated to the work of Jean-Michel Basquiat.
Source: Sotheby's Auction
A microservice architecture organized around Kafka event streams.
- Monorepo code organization
- Separates reads and writes (inspired by CQS)
- Realtime-first with Socket.IO
- Purifies code by describing effects as data
- Deploys to any kubernetes cluster with skaffold
When running any complex system, engineers are inevitably asked, "What happened?". We then attempt to coherently answer this question by piecing togther logs and error reports -- but this is more difficult than it needs to be. Rather, let's anticipate this question by building for observability from the start. To this end, SAMO takes an event-driven approach using Kafka on the backend and Redux Saga user action reporting on the front end.
Engineers variously proxy system quality to metrics around test coverage. A better approach is to gauge testability. That is, how testable is the code we're writing? Code that lends itself to being tested is much more likely to actually be tested and meaningfully so. "Test-hostile" code and code which requires significant mocking suppresses test coverage and adds testing complexity. The use of mocks points to the presence of one or more side-effects in the system under test. We can step around this complexity by re-writing side-effects as data. That is, write side-effects as simple data messages to an effects processor. Code written this way can be tested almost exclusively using simple equality assertions.
export APP_NAME=samo
(set the APP_NAME to whatever you want)./scripts/setup.sh
skaffold dev -p dev
minikube dashboard
(separate terminal)
k9s
(separate terminal)
kubectl get pods
kubectl exec -it [name-of-the-ksql-pod] -c cp-ksql-server -- /bin/bash ksql
ksql
list topics;
./scripts/teardown.sh
To better understand this architecture, let's define a few terms:
- Edge Socket: A dual-channel SocketIO socket exposed to clients.
- Edge View: A federated GraphQL endpoint exposing a unified, query-only interface to all views.
- Effect: An impure instruction which depends on or modifies external state.
- Event: A message sent from any socket or view. Some events can be broadcast to server-side or client consumers. They can be sent to all consumers, a namespace containing many consumers or an individual consumer.
- Interpreter: A subsystem which actually executes effects. This allows code to be written and tested without side-effects.
- Query: A normal GraphQL query.
- Socket: A dual-channel SocketIO socket exposed to the edge.
- View: A GraphQL endpoint exposing a particular slice of the graph.