# DX002A — Supabase Mirror Foundation

## Prepare Supabase Infrastructure for Database Synchronization

---

# ROLE

You are the Lead Software Architect, Database Architect, DevOps Engineer, and Backend Engineer for INVEETAIRE.

Your responsibility is to prepare the Supabase integration layer that will later become the cloud mirror of the existing MySQL database.

Do NOT implement synchronization yet.

This sprint establishes only the infrastructure required by future synchronization features.

---

# OBJECTIVE

Prepare a complete Supabase Foundation inside the existing Developer Console.

The current MySQL database remains the ONLY source of truth.

Supabase will become a cloud mirror in future sprints.

No production data should be modified.

---

# DATABASE STRATEGY

Source of Truth

✓ MySQL

Mirror Database

✓ Supabase PostgreSQL

Rules

• Every application query continues using MySQL.

• Supabase is NEVER queried by the application.

• Supabase is used only for:

    - Database Mirror

    - Cloud Recovery

    - Developer Utilities

    - AI Development

    - Future Disaster Recovery

---

# DEVELOPER CONSOLE

Extend the existing Database page.

Add a new section:

Supabase Mirror

Display:

Connection Status

Project URL

Region

Project Name

Database Version

Last Connection Test

Mirror Status

If Supabase has not been configured, display:

Not Configured

---

# CONFIGURATION

Prepare a secure configuration layer.

Supported values:

SUPABASE_URL

SUPABASE_ANON_KEY

SUPABASE_SERVICE_ROLE_KEY

SUPABASE_PROJECT_REF

Store configuration using the existing application configuration architecture.

Never hardcode credentials.

Configuration should be easily replaceable when moving servers.

---

# CONNECTION TEST

Create a connection verification service.

The Test Connection button should:

Validate credentials.

Verify project availability.

Retrieve project information.

Retrieve PostgreSQL version.

Display success or failure.

Do NOT modify any Supabase data.

This operation must be read-only.

---

# DATABASE INSPECTOR

Create a MySQL inspection service.

Display:

Database Name

Database Version

Character Set

Collation

Storage Engine

Total Tables

Total Rows

Database Size

Documentation Version

Last Documentation Generated

---

# SUPABASE INSPECTOR

Create a Supabase inspection service.

Display:

Project Name

Region

PostgreSQL Version

Available Schemas

Connection Status

Mirror Status

Synchronization Status

At this stage Synchronization Status should display:

Coming in DX002B

---

# DATABASE MAPPING

Prepare the architecture required for future synchronization.

Document the mapping strategy between MySQL and PostgreSQL.

Include examples for:

Primary Keys

Foreign Keys

Auto Increment

Boolean

DateTime

Timestamp

JSON

TEXT

LONGTEXT

ENUM

DECIMAL

No synchronization should occur yet.

---

# SCHEMA FOUNDATION

Prepare internal services capable of:

Reading MySQL schema.

Reading Supabase schema.

Comparing table structures.

Generating schema metadata.

Do NOT generate documentation automatically yet.

That will be implemented in DX002B.

---

# FUTURE PLACEHOLDERS

Prepare disabled buttons for:

Push to Supabase

Pull from Supabase

Verify Mirror

Generate Schema

Compare Schema

Each button should display:

Available in DX002B

---

# SECURITY

Never expose credentials to the browser.

Service Role Key must never be rendered.

Mask sensitive values.

Example:

https://abc*****.supabase.co

Service Role

••••••••••••••••••

Use secure server-side configuration only.

---

# CODE QUALITY

Reuse the existing Developer Console.

Follow existing project architecture.

Separate:

Controllers

Services

Repositories

Views

Configuration

Avoid duplicate logic.

Keep the code modular for DX002B.

---

# VALIDATION

Verify:

✓ Supabase configuration layer created.

✓ Connection test implemented.

✓ MySQL Inspector completed.

✓ Supabase Inspector completed.

✓ Configuration stored securely.

✓ No synchronization performed.

✓ No production database modified.

✓ Placeholder actions prepared for DX002B.

Run PHP lint (`php -l`) on every modified PHP file before completion.

Do not mark this sprint complete until every validation item passes.

---

# IMPORTANT

DX002A prepares the infrastructure only.

Do NOT implement:

- Push

- Pull

- Synchronization

- Conflict Resolution

- Incremental Sync

- Schema Generation

These features belong exclusively to DX002B.