TFile System:
The Zero-Config Embedded Backend

Documentation for the Tfkity integrated data engine. Based on a modified fork of PocketBase (v0.28.0), TFile provides a single-file, SQL-based backend that auto-negotiates connection with the client.

SYSTEM_ONLINE
tfile_instance_01
HARDWARE_ACCESS
> tfile init --mode=embedded --force
[INFO] Loading PocketBase v0.28.0 (Modified)
[INFO] Mounting SQL driver... OK
[INFO] Auto-discovery: Client found on :5173
[AUTH] Handshake established.
Realtime Service: Active (SSE)
Mail Service: Ready
Collections: 14 Loaded
_

1. Embedded Architecture

Tfkity is a Full-Stack Engine. It does not require you to spin up a separate Docker container for your database. We embed TFile, a highly optimized binary fork of PocketBase (v0.28.0), directly into the development runtime.

TFile uses a portable SQLite wal-mode architecture. This means your entire backend—data, schema, and migrations—is contained within a single file (`pb_data.db`). There are no external dependencies, no complex connection strings, and zero configuration files required to start.

2. The Auto-Connect SDK

Because Tfkity controls both the rendering engine and the database process, we eliminate the need for API tokens during development. The `tfile` global object is automatically injected into your JavaScript context with pre-negotiated credentials.

auth_logic.js
// No imports needed. 'tfile' is global.

async function handleLogin() {
    try {
        // Direct integration with TFile Auth Store
        const authData = await tfile.Authenticate.WithEmailAndPassword(
            "[email protected]", 
            "securePassword123"
        );
        
        console.log("Logged in as:", authData.record.id);
    } catch (err) {
        console.error("Auth failed:", err);
    }
}
data_fetch.js
// Real-time subscriptions are built-in
tfile.collection('messages').subscribe('*', (e) => {
    if (e.action === 'create') {
        renderMessage(e.record);
    }
});

// Simple CRUD without Axios/Fetch boilerplate
const records = await tfile.collection('products').getList(1, 50, {
    filter: 'status = "active"',
    sort: '-created'
});

3. Included Services

Authentication Engine

Pre-configured email/password auth, plus OAuth2 providers (Google, GitHub, Apple) ready to toggle. No Firebase required.

Realtime Engine

Built-in SSE (Server-Sent Events) broadcasting. Any change in the database is instantly pushed to connected clients.

Typed Records

Create collections schema via UI. TFile validates data types (Text, Number, Relation, JSON) before insertion.

Built-in Mailer

Send system emails (Password Reset, Verification) or custom transactional emails using the system SMTP queue.

4. Deployment Strategy

When moving from Development (Localhost) to Production, you do not need to rewrite your connection logic. You simply change one input flag during the build process.

Build Configuration

In your tfkity.config.js, define the remote host URL. The TFaada compiler will replace the local auto-connect loop with a secure remote connection string in the final binary.

module.exports = {
  app_name: "MyApp",
  
  // Dev Mode
  backend: "embedded", 

  // Prod Mode (Uncomment to build)
  // backend: "https://api.myapp.com",
};

2025 Tfkity Co.