Skip to main content

Persistence

Vectra uses Entity Framework Core for data persistence. Two providers are supported out of the box: SQLite (default, zero-config) and PostgreSQL.


Entities

Agent

Stores registered agents and their current state.

ColumnTypeDescription
IdGuid (PK)Agent identifier
NamestringAgent name
OwnerIdstring?Owner identifier
StatusintAgentStatus enum value
PolicyNamestring?Assigned policy name
ClientSecretHashstringBcrypt-hashed client secret
TrustScoredoubleCurrent trust score
CreatedAtDateTimeOffsetCreation timestamp (from AuditableEntity)
UpdatedAtDateTimeOffset?Last update timestamp

AgentHistory

Time-series log of agent request activity used by the risk scoring engine.

ColumnTypeDescription
IdGuid (PK)
AgentIdGuid (FK → Agent)
MethodstringHTTP method
PathstringRequest path
TimestampDateTimeOffsetWhen the request was made
DecisionTypeintAllow / Deny / Hitl

AuditTrail

Immutable audit log of every decision made by the gateway.

ColumnTypeDescription
IdGuid (PK)
AgentIdGuid
DecisionTypeint
Reasonstring?Decision reason
Methodstring
Pathstring
TargetUrlstring
RiskScoredouble
TimestampDateTimeOffset

Repositories

All repositories implement interfaces defined in Vectra.Application.Abstractions.Persistence:

InterfaceImplementationDescription
IAgentRepositoryAgentRepositoryCRUD for agents
IAgentHistoryRepositoryAgentHistoryRepositoryAppend and query recent history
IAuditRepositoryAuditRepositoryAppend-only audit log

Database Initialisation

On startup, SqliteDatabaseInitializer (which implements IDatabaseInitializer) is called by EnsureApplicationDatabaseCreated(). This runs dbContext.Database.EnsureCreatedAsync(), creating the schema if it does not exist.


Configuration

SQLite (Default)

"System": {
"Storage": {
"Database": {
"DefaultProvider": "Sqlite",
"Providers": {
"Sqlite": { "ConnectionString": "Data Source=vectra.db" }
}
}
}
}

PostgreSQL

"System": {
"Storage": {
"Database": {
"DefaultProvider": "Postgres",
"Providers": {
"Postgres": {
"ConnectionString": "Host=localhost;Database=vectra;Username=vectra;Password=secret"
}
}
}
}
}
note

PostgreSQL support requires the Vectra.Infrastructure.Persistence.PostgreSQL package (if available) to be registered in the DI container.