System Architecture - ljcom/operadb GitHub Wiki
π§± System Architecture β OperaDB
OperaDB is built on an event-driven, replayable, and modular architecture, designed to support scalable applications and workflows without the need to mutate the underlying database state directly.
π§ Core Principles
Principle | Description |
---|---|
Event Sourcing | All data changes are stored as immutable events |
Reducer Pattern | Events are processed using reducers to build final state |
Replayable State | The state of any entity can be rebuilt from its event history |
Schema Modularization | Entities are defined via JSON-like schema, versioned and extendable |
Actor-Centric Model | All actions are performed in the context of an actor (user/system) |
π Architectural Layers
+--------------------------+
| Frontend UI | β React (Explorer)
+--------------------------+
|
v
+--------------------------+
| API Layer | β RESTful endpoints (Node.js/Express)
+--------------------------+
|
v
+--------------------------+
| Event Dispatcher & Core | β Validates, routes, and stores events
+--------------------------+
|
v
+--------------------------+
| Reducer Engine | β Converts events to state snapshots
+--------------------------+
|
v
+--------------------------+
| State Database | β MongoDB / JSON store / vector DB
+--------------------------+
π Key Components
1. Actor
Represents the user, bot, or system module initiating an action. Each event is tagged with its actor ID for traceability.
2. Schema
Defines the format of an entityβs data structure, validations, and field-level properties. Schemas are versioned and modular.
3. Reducer
Contains logic to process events (create
, update
, transfer
, etc.) into a consistent state. Reducers are assigned per schema.
4. Event
Each action (like creating a user, issuing a coin, transferring an asset) is recorded as an event. Events are immutable and timestamped.
5. State
The current representation of an entity, computed by replaying its event history using the appropriate reducer.
π Data Flow
User Action β API β Event Created β Stored β Reducer Runs β State Saved/Updated β UI Reflects State
π§© Modularity & Plug-and-Play
OperaDB is schema-first. This means:
- New modules (like
coin
,contract
,asset
) can be added by writing schema + reducer only. - No need to write new database tables or REST routes.
- Everything is versioned and namespaced by account.
βοΈ Deployment Options
- π Can run in single-instance or multi-tenant mode
- π§ͺ Local development using
npm run dev
- π¦ Docker-based deployment (coming soon)
- π Future: support for vector database integration (Weaviate / Milvus)
π Security Model
- Events can be validated with signatures
- Actor permissions are verified before processing reducers
- Optional: token/session-based authorization layer
Next: Learn about Core Concepts such as actors, events, reducers, and schemas in detail.