Fractal

A powerful Dart package for creating dynamic, interconnected data models with automatic database table generation for PostgreSQL or SQLite. The fractal package simplifies building complex data structures for applications, including AI-driven systems, by providing a flexible object model where each object corresponds to a database table with attributes so its all easily programmable.

Features

  • Automatic Table Generation: Define data models as Dart classes, and fractal automatically creates corresponding tables in PostgreSQL or SQLite.
  • Interconnected Object Model: Objects like NodeFractal, Attr, EventFractal, and Catalog are hierarchically linked, enabling rich relationships and extensibility.
  • Attribute System: Define attributes that map directly to database columns with customizable formats, constraints, and defaults.
  • Extensibility: Extend base classes like Fractal, EventFractal, and NodeFractal to create custom models tailored to your application.
  • AI-Friendly: Designed for easy integration into AI applications with flexible data linking and cataloging.
  • Cross-Platform: Supports both web (WebSqlite) and native environments, as well as PostgreSQL.
  • Companion Package: Pair with fractal_socket (not covered here) for seamless data synchronization between devices.

Installation

Add fractal to your pubspec.yaml:

dependencies:
  fractal: ^<latest_version>

Simple example

import 'package:fractal/index.dart';

Future<void> main() async {
  // Initialize SQLite (WebSqlite for web, NativeSqlite for native)
  await DBF.initiate(constructDb('fractal'));

  // Or initialize PostgreSQL
  await DBF.initiate(PostgresFDBA(
    'fractal',
    username: 'name',
    password: 'psw',
  ));

  // Set up core models and system
  await SignedFractal.init(); // Basic model
  await DeviceFractal.initMy(); // Associate current device
  await FSys.setup(); // Initialize the system

    await UserFractal.init();

  // Create a new user
  final user = UserFractal(
    name: 'john_doe',
    email: 'john@example.com',
    domain: 'example.com',
    password: 'secure123',
  );

  // Persist to database
  await user.synch();
}

Libraries

access/abstract
access/async
access/fs
access/native
access/postgres
access/sqlite
access/unsupported
access/web
afi/afi
afi/call
afi/ff
afi/index
afi/pulse
afi/transformers
c
controllers/controllers
controllers/events
controllers/fractal
controllers/index
controllers/node
controllers/user
data
db
enums/index
enums/kind
extensions/in
extensions/index
extensions/signer
extensions/sql
extensions/stored
extensions/string
extensions/user
filter/filterable
filter/index
filter/match
filters/index
filters/type
fr
frac/completer
frac/fnotifier
frac/frac
frac/index
frac/listenable
frac/ref
frac/string
frac/types
frac/utils
frac/word
fractal_base
index
interfaces/container
interfaces/index
lib
map
mixins/consumable
mixins/consumer
mixins/events
mixins/extendable
mixins/fbase
mixins/filterable
mixins/flow
mixins/hashed
mixins/hierarchy
mixins/index
mixins/map
mixins/mpf
mixins/notifications
mixins/on
mixins/signing
mixins/value
models/app
models/attr
models/catalog
models/connection
models/context
models/ctrl
models/device
models/event
models/filter
models/fractal
models/group
models/index
models/interaction
models/network
models/node
models/post
models/rewriter
models/table
models/user
models/word
native
policies/index
policies/list
policies/policies
policies/storage
ref
security/codec/index
security/codec/private_key_codec
security/codec/public_key_codec
security/generator/index
security/generator/key_pair_generator
security/generator/mnemonic_key_pair_generator
security/generator/random_key_pair_generator
security/index
security/key_pair
services/fs
services/fs/content
services/fs/ff
services/fs/ff_ext
services/fs/file
services/fs/fractal
services/fs/fs
services/fs/index
services/fs/interface
services/fs/node
services/fs/platform/native/node
services/fs/platform/web/node
services/fs/types
services/index
services/map
services/signer
services/sorted
services/verifier
signed_fractal
sys
types/axi
types/file/file_unsupported
types/file/idb
types/file/io
types/filter
types/icon
types/image
types/index
types/make
types/map
types/mp
types/ref
types/skin
types/stored
types/thing
utils
utils/bits
utils/index
utils/random
utils/task
web