Skip to content

kamaravichow/postbase

Repository files navigation

PostBase — Firestore-like NoSQL Database Console

A Firestore-like NoSQL database console called PostBase, with a strict black-and-white, squared-edge UI built using shadcn/ui components. Users can browse collections, view/edit/delete documents in a table, configure security rules, and interact via an SDK API.

Architecture

graph TD
    A[Browser UI] --> B[Next.js App Router]
    B --> C[API Routes]
    C --> D[MongoDB]
    C --> E[Security Rules Engine]
    E --> D
    F[External SDK] --> G[POST /api/sdk]
    G --> E
Loading

Features

1. Document Field Builder & ID Generator

  • Fully typed document editor replaces raw JSON.
  • Supports adding arrays, objects (maps), strings, numbers, booleans, and nulls.
  • Documents can have an auto-generated UUID or a user-specified custom unique ID (_id).

2. Subcollections Support (users/123/posts)

  • The Next.js API Routes use query parameters (/api/documents?collection=users/123/posts) to gracefully handle slashes natively without fighting Next.js App Router Catch-all constraints.
  • Visual Hierarchy matches Firestore: The sidebar only shows root collections, while navigating into a document's details panel shows a nested graphical list of its subcollections.
  • Breadcrumb navigation rendered in the toolbar to quickly jump back to parent collections from deep subcollections.
  • Seamless creation logic for adding nested collections directly to a document.

3. API & SDK Ecosystem

  • A fully functional REST API allowing full CRUD on collections, subcollections, and documents.
  • Detailed Security Rules to authorize requests dynamically evaluating rule statements like auth != null.
  • Fully documented SDK interface right in the UI to give examples natively.

How to Run

  1. Start MongoDB (must be running on localhost:27017, or set MONGODB_URI env var). By default, assuming local instance.
  2. Install dependencies with pnpm install if not already installed.
  3. Start the application: pnpm dev — starts Next.js dev server on http://localhost:3000
  4. Create collections from the sidebar, add documents, configure security rules.
  5. Use the SDK endpoint at POST /api/sdk for programmatic access.

Project Structure

Database Layer

File Purpose
lib/types.ts Shared types: document structures, SDK requests, rules
lib/db.ts MongoDB connection manager, collection CRUD, meta collection
lib/security-rules.ts Rules engine: get/set rules, evaluate expressions

API Routes

Route Methods Purpose
/api/collections GET, POST, DELETE List, create, or drop collections
/api/documents GET, POST List (paginated) / create documents
/api/documents/[id] GET, PUT, DELETE Single document CRUD
/api/rules GET, PUT Security rules management
/api/sdk POST SDK endpoint (get/set/query/update/delete) with rule enforcement

Frontend

Page / Component Purpose
components/app-sidebar.tsx Sidebar with root collection list, create/delete dialogs
app/(console)/page.tsx Dashboard with stats & collection overview
app/(console)/collections/[...path]/page.tsx Document table + detail panel (subcollections support)
app/(console)/rules/page.tsx Security rules JSON editor
app/(console)/sdk/page.tsx API/SDK reference with tabbed code examples

Theme & UI

  • Built with Tailwind CSS and shadcn/ui.
  • Setting --radius: 0 for squared edges everywhere.
  • Nova preset (neutral/grayscale) for strict black & white aesthetic.
  • Typography powered by Geist Sans & Geist Mono.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors