Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

284 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Entity Identifier Resolver

Entity Identifier Resolver (EIR) is a local, strongly typed entity database and search engine written in Rust.

It is designed for applications that need to find an entity from names, metadata, or relationships rather than from a single known identifier.

Status

EIR is under active development. The CLI, storage, and search systems are functional and tested. The server is currently a CLI placeholder.

⚠️ Warning: EIR is not encrypted. Do not use it to store sensitive data.


Entity Model

An EIR database contains entities identified by an EntityID.

An entity can have several aliases, tags, sources, attributes, and relationships:

{
  "id": 1001,
  "aliases": [
    "FizzBerry Spark",
    "FizzBerry",
    "Berry Spark"
  ],
  "tags": [
    "drink",
    "berry"
  ],
  "sources": [
    {
      "provider": "Open Food Facts",
      "verified": true
    }
  ],
  "attributes": [],
  "relationships": []
}

Aliases

Aliases are names that can be used to find an entity.

For example, the same entity might be known as:

FizzBerry Spark
FizzBerry
Berry Spark

EIR can search aliases using exact, prefix, and fuzzy matching.

Tags

Tags provide categories or other labels associated with an entity.

FizzBerry Spark
β”œβ”€β”€ drink
└── berry

Tags can also participate in searches.

Sources

Sources record where information about an entity came from.

An entity can have information from several providers, and source information can be used during search and inspection.

Attributes

Attributes describe properties of an entity.

For example:

brand    = FizzBerry
category = Soft Drink
country  = Denmark

Unlike an alias, an attribute describes the entity rather than providing another name for it.

Relationships

Relationships connect one entity to another.

For example:

FizzBerry Spark
      β”‚
      └── manufactured_by ──> FizzBerry Foods

This allows EIR to use information about related entities when resolving a query.


Search

EIR does not use one search algorithm for every query.

A query can be handled by several search operations:

flowchart LR
    QUERY["Query"] --> PLANNER["Planner"]

    PLANNER --> EXACT["Exact Alias"]
    PLANNER --> PREFIX["Prefix Alias"]
    PLANNER --> FUZZY["Fuzzy Alias"]
    PLANNER --> TOKEN["Token"]
    PLANNER --> TAG["Tag"]
    PLANNER --> PROPERTY["Property"]
    PLANNER --> RELATIONSHIP["Relationship"]

    EXACT --> CANDIDATES["Candidates"]
    PREFIX --> CANDIDATES
    FUZZY --> CANDIDATES
    TOKEN --> CANDIDATES
    TAG --> CANDIDATES
    PROPERTY --> CANDIDATES
    RELATIONSHIP --> CANDIDATES

    CANDIDATES --> RANKER["Ranker"]
    RANKER --> RESULTS["Results"]
Loading

The search system records which operations produced each candidate. This makes it possible to see why an entity matched a query.

For example, a result might have matched through:

ExactAlias
Token
Tag

rather than simply returning a score with no explanation.


Database

The database contains the entities and the structures needed to search them.

Database
β”œβ”€β”€ Entities
β”œβ”€β”€ Tag Registry
β”œβ”€β”€ Source Registry
β”œβ”€β”€ Attribute-Key Registry
β”œβ”€β”€ Relationship-Type Registry
└── Indexes

Registries assign internal identifiers to repeated values such as tags, source names, attribute keys, and relationship types.

Indexes provide the structures used to find entities efficiently.

The indexes are built from the current database contents and include structures for aliases, prefixes, fuzzy matching, tokens, tags, sources, attributes, and relationships.


Storage

The logical database is stored using persistent storage managed by the EIR engine.

A database has a layout similar to:

database/
β”œβ”€β”€ database.eir
β”œβ”€β”€ eir.toml
β”œβ”€β”€ segments/
└── wal/

The storage backend uses DEIR segments and a write-ahead log.

The WAL records database mutations so they can be recovered if necessary.

Compaction can later rewrite the stored data to remove obsolete storage.


Architecture

The main runtime object is Engine.

flowchart TB
    CLI["eir-cli"]

    ENGINE["Engine"]

    DATABASE["Database"]
    RESOLVER["Resolver"]
    BACKEND["Backend"]

    QUERY["Query"]
    SEARCH["Search"]
    INDEXES["Indexes"]

    WAL["WAL"]
    SEGMENTS["DEIR Segments"]

    CLI --> ENGINE

    ENGINE --> DATABASE
    ENGINE --> RESOLVER
    ENGINE --> BACKEND

    RESOLVER --> QUERY
    QUERY --> SEARCH
    SEARCH --> INDEXES

    BACKEND --> WAL
    BACKEND --> SEGMENTS

    DATABASE --> INDEXES
Loading

Engine coordinates the database, resolver, and storage backend.

The database contains the entity data and indexes, while the resolver uses those indexes to perform searches.


Whole System

flowchart TB
    USER["Application / CLI"]

    ENGINE["Engine"]

    DATABASE["Database"]
    ENTITIES["Entity Documents"]
    REGISTRIES["Registries"]
    INDEXES["Search Indexes"]

    QUERY["Query"]
    PLANNER["Planner"]
    EXECUTOR["Executor"]
    RANKER["Ranker"]
    RESULTS["Search Results"]

    STORAGE["Storage Backend"]
    WAL["Write-Ahead Log"]
    SEGMENTS["DEIR Segments"]

    USER --> ENGINE

    ENGINE --> DATABASE
    ENGINE --> STORAGE

    DATABASE --> ENTITIES
    DATABASE --> REGISTRIES
    DATABASE --> INDEXES

    ENGINE --> QUERY
    QUERY --> PLANNER
    PLANNER --> EXECUTOR
    EXECUTOR --> INDEXES
    EXECUTOR --> RANKER
    RANKER --> RESULTS

    STORAGE --> WAL
    STORAGE --> SEGMENTS
Loading

This is the overall flow:

Entity data
    β”‚
    β–Ό
Database
    β”‚
    β”œβ”€β”€ Registries
    └── Search indexes
             β”‚
             β–Ό
          Resolver
             β”‚
             β–Ό
           Query
             β”‚
             β–Ό
          Results

CLI

The eir CLI provides tools for working with databases.

Current commands include:

init
build
stats
inspect
search
insert
remove
update
compact
merge
server
completions

For example:

cargo eir init data nutrition

cargo eir build \
  --input entities.json \
  --database data/nutrition

cargo eir search \
  data/nutrition/nutrition.eir \
  "FizzBerry"

See docs/cli.md for the complete command reference.


Project Structure

EntityIdentifierResolver/
β”œβ”€β”€ crates/
β”‚   β”œβ”€β”€ eir-core/
β”‚   β”œβ”€β”€ eir-cli/
β”‚   └── eir-version/
β”œβ”€β”€ apps/
β”œβ”€β”€ docs/
└── fixtures/

eir-core

The core database and search engine.

It contains the entity model, engine, storage, indexing, query, and search systems.

eir-cli

The command-line interface built on top of eir-core.

eir-version

Version-related functionality used by the database and merge system.


Development

Clone the repository:

git clone https://github.com/HandsOnDigits/EntityIdentifierResolver.git
cd EntityIdentifierResolver

Check the workspace:

cargo check --workspace

Run the tests:

cargo test --workspace

Format the code:

cargo fmt --all

Documentation


License

See LICENSE for the license.


Design Goals

EIR is designed around a few simple principles:

  • Local β€” no remote service required
  • Structured β€” entities contain more than just names
  • Fast β€” specialized indexes for different search operations
  • Explainable β€” search results expose matching signals
  • Embeddable β€” the core engine is independent of the CLI
  • Recoverable β€” persistent storage uses snapshots and WAL

Entity Identifier Resolver β€” TODO

πŸ—οΈ Core Architecture

Completed

  • Rust workspace
  • eir-core crate
  • eir-cli crate
  • eir-version crate
  • Entity model
  • EntityID
  • EntityType
  • Entity aliases
  • Tags
  • Sources
  • Attributes
  • Relationships
  • Registries / interners
  • Database abstraction
  • Engine abstraction
  • Resolver abstraction

Planned

  • Stabilize public core API
  • Document core architecture
  • Define database compatibility/versioning policy
  • Improve error model

πŸ”Ž Search & Entity Resolution

Completed

  • Exact alias search
  • Prefix alias search
  • Fuzzy alias search
  • Token search
  • Tag search
  • Attribute/property search
  • Relationship search
  • Alias index
  • Prefix trie
  • Fuzzy/BK-tree index
  • Token inverted index
  • Posting lists
  • Query parser
  • Query intent
  • Query filters
  • Search planner
  • Search executor
  • Search stages
  • Candidate collection
  • Search signals
  • Ranking
  • Search explanations
  • Search tests

Planned

  • Improve ranking quality
  • Tune fuzzy matching
  • Add more query operators
  • Improve relationship queries
  • Improve search explanations
  • Benchmark search performance
  • Test against larger real-world datasets
  • Add configurable ranking strategies

πŸ’Ύ Database & Storage

Completed

  • Database lifecycle
  • Database creation
  • Database opening
  • .eir database identity
  • eir.toml configuration
  • Storage configuration
  • DEIR storage format
  • Storage segments
  • Segment manager
  • Backend abstraction
  • Write-ahead log (WAL)
  • WAL replay
  • Database recovery
  • Snapshot persistence
  • Flush
  • Index rebuilding
  • Database statistics

✏️ Entity Mutations

Completed

  • Insert entities
  • Remove entities
  • Update entities
  • Duplicate entity detection
  • Entity validation
  • Index rebuild after mutation
  • WAL support for insert
  • WAL support for remove
  • WAL support for update
  • Mutation recovery tests

🧹 Compaction

Completed

  • Compact command
  • Segment rewrite
  • Remove obsolete storage data
  • Report storage size before/after
  • Report reclaimed space
  • Compaction tests

Planned

  • Add automatic compaction policy
  • Add configurable compaction thresholds

πŸ”€ Database Merge

Completed

  • Merge command
  • Merge two databases
  • Duplicate entity ID detection
  • Reject output/input collisions
  • Combine entity collections
  • Rebuild merged indexes
  • Merge tests

Planned

  • Support merging more than two databases
  • Improve merge performance
  • Add merge conflict strategies
  • Document registry remapping
  • Add large-database merge benchmarks

πŸ–₯️ CLI

Completed

  • CLI with Clap
  • init
  • build
  • stats
  • inspect
  • search
  • insert
  • remove
  • update
  • compact
  • merge
  • server command structure
  • Shell completions
  • CLI integration tests
  • Database lifecycle tests

Planned

  • Finish server implementation
  • Improve CLI output formatting
  • Add machine-readable output
  • Improve error messages
  • Improve command help
  • Add CLI benchmarks
  • Add support for CSV file import

🌐 Server / API

Completed

  • Server command scaffold
  • Server lifecycle command structure

Planned

  • HTTP API
  • Search endpoint
  • Entity lookup endpoint
  • Entity insertion endpoint
  • Entity update endpoint
  • Entity removal endpoint
  • Database statistics endpoint
  • Health endpoint
  • API documentation
  • Authentication strategy
  • Request validation
  • API integration tests

πŸ“¦ Data & Fixtures

Completed

  • JSON entity fixtures
  • Test entities
  • Test sources
  • Test tags
  • Test attributes
  • Test relationships
  • Larger test database
  • CLI lifecycle fixture tests

Planned

  • CSV entity fixtures

πŸ§ͺ Testing

Completed

  • Unit tests
  • Database lifecycle tests
  • Persistence tests
  • WAL recovery tests
  • Insert tests
  • Remove tests
  • Update tests
  • Compaction tests
  • Merge tests
  • Search tests
  • Query tests
  • CLI tests
  • Duplicate ID tests
  • Output/input collision tests

Planned

  • Large dataset tests
  • Performance benchmarks
  • Search relevance benchmarks
  • Storage benchmarks
  • Fuzz testing
  • Crash/recovery testing
  • Concurrency testing

πŸ“š Documentation

Completed

  • CLI documentation
  • Architecture documentation
  • Search architecture documentation
  • Storage documentation
  • Mermaid architecture diagrams
  • README architecture overview

Planned

  • Keep README aligned with source
  • Keep CLI docs aligned with commands
  • Database format documentation
  • Entity schema documentation
  • Search/query documentation
  • Storage format specification
  • API documentation
  • Contributor guide
  • Architecture decision records

πŸš€ Performance

Planned

  • Benchmark database creation
  • Benchmark inserts
  • Benchmark updates
  • Benchmark deletes
  • Benchmark search
  • Benchmark fuzzy search
  • Benchmark index building
  • Benchmark database opening
  • Benchmark WAL replay
  • Benchmark compaction
  • Benchmark merge
  • Memory usage profiling
  • Large-dataset testing
  • Investigate GPU acceleration

πŸ” Security & Privacy

Current

  • Local-first architecture
  • No search history by default
  • No external service required for core search
  • No telemetry in the core engine

Planned

  • Document security model
  • Document filesystem permissions
  • Optional database encryption strategy
  • API authentication
  • API authorization
  • Security audit

🎯 Project Milestones

Phase 1 β€” Core Engine

  • Entity model
  • Database
  • Storage
  • Indexing
  • Resolver
  • Search

Phase 2 β€” Database Lifecycle

  • Persistence
  • WAL
  • Recovery
  • Insert
  • Update
  • Remove
  • Compaction
  • Merge

Phase 3 β€” CLI

  • Database creation
  • Build
  • Search
  • Inspect
  • Stats
  • Mutations
  • Maintenance commands

Phase 4 β€” Production Readiness

  • Performance benchmarks
  • Large dataset testing
  • Complete documentation
  • Stable public API
  • Error handling review
  • Recovery testing

Phase 5 β€” API & Applications

  • HTTP server
  • API
  • TypeScript client

License

See the repository for the current license.

The documentation was created with the help of AI, but otherwise, all the code was written by humans.

About

A fast, compact, configurable, thread-safe, and strongly typed entity-based search engine and resolver database designed for content search and metadata analytics, built in pure Rust.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages