Storx uses Drizzle ORM on top of Neon serverless PostgreSQL to store all file and folder metadata. ImageKit holds the actual file bytes; the database tracks ownership, hierarchy, and flags for every file and folder a user creates.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/Storx/llms.txt
Use this file to discover all available pages before exploring further.
Creating a Neon Database
Sign up at neon.tech
Go to neon.tech and create a free account. Neon’s free
tier includes a single project with up to 0.5 GB of storage — enough for
development and small deployments.
Create a new project
From the Neon console, click New Project. Choose a region close to your
deployment environment, give the project a name (e.g.
storx), and confirm.
Neon automatically provisions a default database named neondb.Copy the connection string
In the project dashboard, navigate to Connection Details. Select the
Pooled connection string for application use. It looks like:Make sure
sslmode=require is present — Neon requires SSL for all connections.Database Schema
Storx uses a singlefiles table that represents both files and folders. Folders are differentiated from files via the is_folder boolean flag, and the parent_id column enables an arbitrary-depth folder hierarchy through a self-referential foreign key relationship.
The initial migration SQL that creates this table is:
drizzle/0000_woozy_exodus.sql
Column Groups
| Group | Columns | Purpose |
|---|---|---|
| Identity | id | UUID primary key, auto-generated with gen_random_uuid() |
| Basic info | name, size, type | Display name, byte size, and MIME type (or "folder" for folders) |
| Storage | file_url, thumbnail_url | Public ImageKit delivery URL and optional thumbnail URL |
| Ownership | user_id, parent_id | Clerk user ID of the owner; UUID of the parent folder (null for root items) |
| Flags | is_folder, is_starred, is_trash | Distinguish folders from files; track starred and trashed states |
| Timestamps | created_at, updated_at | Auto-set on insert; updated_at must be manually refreshed on writes |
lib/db/schema.ts:
lib/db/schema.ts
Running Migrations
Storx ships three database scripts. Choose the one that matches your workflow:| Command | What it does |
|---|---|
npm run db:migrate | Executes lib/db/migrate.ts using tsx, which applies all pending SQL migration files from the ./drizzle folder against your Neon database. Use this in CI/CD and production deployments. |
npm run db:push | Runs drizzle-kit push to diff the current schema against the live database and apply changes directly — without generating a migration file. Ideal for rapid iteration during local development. |
npm run db:generate | Runs drizzle-kit generate to produce a new SQL migration file under ./drizzle whenever you change lib/db/schema.ts. Commit the generated file alongside your schema change. |
Drizzle Studio
Drizzle Kit ships a browser-based database GUI called Drizzle Studio. Run it locally to browse and edit rows without writing SQL:https://local.drizzle.studio) and opens a visual interface connected to your Neon database via DATABASE_URL.
Schema Types
Drizzle infers TypeScript types directly from the table definition. Storx exports two types fromlib/db/schema.ts for use in API routes and server actions:
lib/db/schema.ts
FileType represents a fully hydrated database row (all columns present).
NewFileTYpe represents the shape of data you pass to db.insert(files).values(...) —
optional columns like thumbnailUrl, imagekitFileId, and parentId are typed as
optional in this variant.