Skip to content

ProMehedi/api-builder

Repository files navigation

API Builder

Warning

🚧 Work in Progress β€” This project is under active development and not yet production-ready. Features may be incomplete, APIs may change, and bugs are expected. Use at your own risk!

Build REST APIs in Minutes β€” No Backend Code Required

License: MIT Next.js TypeScript Tailwind CSS

API Builder Preview


✨ Features

πŸ—ƒοΈ Collection Management

  • Create Collections β€” Define your data structure with a visual schema builder
  • Multiple Field Types β€” String, Number, Boolean, Email, URL, Date, DateTime, Text, Select, JSON, and Relations
  • Drag & Drop Fields β€” Reorder fields with intuitive drag-and-drop
  • Field Validation β€” Set required fields, default values, and descriptions

πŸ”— Relations

  • Single Relations (Many-to-One) β€” Link items to a single related item
  • Multiple Relations (Many-to-Many) β€” Link items to multiple related items
  • Configurable Population β€” Control which fields to populate in API responses
  • Smart Display β€” Choose display fields for better UX

πŸš€ Auto-Generated REST APIs

Every collection automatically gets full CRUD endpoints:

Method Endpoint Description
GET /api/{collection} List all items
GET /api/{collection}/{id} Get single item
POST /api/{collection} Create new item
PUT /api/{collection}/{id} Update item
DELETE /api/{collection}/{id} Delete item

πŸ” Route Settings

  • Enable/Disable Routes β€” Toggle individual API endpoints
  • Custom Paths β€” Rename API endpoints
  • API Key Protection β€” Secure routes with API keys
  • Population Control β€” Configure default relation population

πŸ‘€ Multi-Tenant Workspaces

  • User Subdomains β€” Each user gets their own workspace (e.g., username.localhost:3000)
  • Isolated Data β€” Collections and items are scoped to workspaces
  • Custom Usernames β€” Choose and change your workspace subdomain

🎨 Modern UI/UX

  • Directus/Strapi Inspired β€” Clean, professional admin interface
  • Sidebar Navigation β€” Quick access to all collections
  • Dark/Light Mode β€” Toggle between themes
  • Responsive Design β€” Works on desktop and mobile

πŸ› οΈ Tech Stack

Category Technology
Framework Next.js 15 (App Router)
Language TypeScript 5
Styling Tailwind CSS 4
UI Components shadcn/ui + Radix UI
State Management Zustand
Data Fetching React Query (TanStack Query)
Authentication Better Auth
Database SQLite (better-sqlite3)
Storage File-based JSON storage
Drag & Drop dnd-kit

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ or Bun runtime
  • Git

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/api-builder.git
    cd api-builder
  2. Install dependencies

    bun install
    # or
    npm install
  3. Set up environment variables

    cp .env.example .env

    Edit .env and configure:

    BETTER_AUTH_SECRET=your-super-secret-key-here
    BETTER_AUTH_URL=http://localhost:3000
  4. Run database migrations

    bunx @better-auth/cli migrate
  5. Start the development server

    bun dev
    # or
    npm run dev
  6. Open the app

    Visit http://localhost:3000


πŸ“ Project Structure

api-builder/
β”œβ”€β”€ app/                      # Next.js App Router
β”‚   β”œβ”€β”€ (auth)/               # Auth pages (login, signup)
β”‚   β”œβ”€β”€ api/                  # API routes
β”‚   β”‚   β”œβ”€β”€ [collection]/     # Dynamic collection endpoints
β”‚   β”‚   β”œβ”€β”€ auth/             # Better Auth handlers
β”‚   β”‚   └── sync/             # Client-server sync
β”‚   β”œβ”€β”€ collections/          # Collection pages
β”‚   β”‚   └── [id]/             # Collection detail, edit, items
β”‚   β”œβ”€β”€ settings/             # User settings
β”‚   β”œβ”€β”€ layout.tsx            # Root layout
β”‚   └── page.tsx              # Dashboard
β”œβ”€β”€ components/               # React components
β”‚   β”œβ”€β”€ ui/                   # shadcn/ui primitives
β”‚   β”œβ”€β”€ app-sidebar.tsx       # Main navigation
β”‚   β”œβ”€β”€ app-topbar.tsx        # Breadcrumbs & actions
β”‚   β”œβ”€β”€ dashboard.tsx         # Home page content
β”‚   β”œβ”€β”€ data-table.tsx        # Items table
β”‚   β”œβ”€β”€ field-editor.tsx      # Schema field editor
β”‚   └── ...
β”œβ”€β”€ lib/                      # Utilities & stores
β”‚   β”œβ”€β”€ auth.ts               # Better Auth server config
β”‚   β”œβ”€β”€ auth-client.ts        # Better Auth client
β”‚   β”œβ”€β”€ store.ts              # Zustand store
β”‚   β”œβ”€β”€ storage.ts            # File-based storage
β”‚   β”œβ”€β”€ types.ts              # TypeScript types
β”‚   └── ...
β”œβ”€β”€ data/                     # JSON data storage (gitignored)
└── public/                   # Static assets

πŸ”§ Configuration

Environment Variables

Variable Description Required
BETTER_AUTH_SECRET Secret key for JWT signing Yes
BETTER_AUTH_URL Base URL of your app Yes

Subdomain Setup (Development)

For local development with subdomains, your browser needs to resolve *.localhost domains. Most modern browsers handle this automatically.

Testing subdomains:

http://localhost:3000          # Main app
http://username.localhost:3000 # User workspace

πŸ“– API Documentation

List Items

GET /api/{collection}

Query Parameters:

  • populate β€” Comma-separated relation fields to populate

Example:

curl http://localhost:3000/api/posts?populate=author,tags

Get Single Item

GET /api/{collection}/{id}

Query Parameters:

  • populate β€” Comma-separated relation fields to populate

Create Item

POST /api/{collection}
Content-Type: application/json

{
  "fieldName": "value",
  "relationField": "related-item-id"
}

Update Item

PUT /api/{collection}/{id}
Content-Type: application/json

{
  "fieldName": "updated value"
}

Delete Item

DELETE /api/{collection}/{id}

Protected Routes

For routes with API key protection:

curl -H "X-API-Key: your-api-key" http://localhost:3000/api/posts

🎯 Roadmap

  • Webhooks support
  • GraphQL API generation
  • File/Media field type
  • Role-based access control
  • API rate limiting
  • Export/Import collections
  • Audit logs
  • Real-time updates (WebSockets)

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 API Builder

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

πŸ™ Acknowledgments


Built with ❀️ by Mehedi Hasan

GitHub β€’ Website β€’ Twitter

About

No-code API builder - Build fully funtional REST APIs in Minutes

Resources

License

Stars

Watchers

Forks

Languages