Skip to content

Latest commit

Β 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ—οΈ Nirman

The Next-Generation, Open Source Backend-as-a-Service (BaaS)

Authentication, Database Collections, Realtime Sync, and a unique Plug-and-Play Integrations Hub.

Nirman is a high-performance, polyglot microservices platform built for modern development. Need to switch from Twilio to MSG91 or from SendGrid to Resend? Do it instantly from the Dashboard without touching a single line of application code.

Languages

🌟 Architecture & Tech Stack

Nirman follows a polyglot microservices architecture where each service is optimized for its job.

Layer Service Stack Purpose
API Layer Gateway Go, Chi, PostgreSQL, Redis Auth, project APIs, API key validation, routing/proxy
Integration Layer Hub Bun, Hono, TypeScript Provider adapters (OTP, Email, Maps, Notifications, Storage)
Async Layer Workers Python, Celery, Redis Background jobs, retries, cleanup schedules
Realtime Layer Realtime Go, WebSockets, Redis Pub/Sub Live updates and project-scoped realtime channels
UI Layer Dashboard Next.js, React, TypeScript Admin panel for projects, keys, integrations
Infra Layer Infra Docker Compose, Nginx, PostgreSQL, Redis Orchestration, reverse proxy, persistence, messaging
Provider System packages/provider-sdk TypeScript Interface contract for all plug-and-play providers
Provider Registry nirman-registry JSON (separate repo) Public listing of community-contributed providers

Core Technologies

  • Go: High-performance API and realtime services
  • Bun + Hono: Fast integrations execution engine
  • Python + Celery: Reliable async task processing
  • PostgreSQL: Primary relational data store
  • Redis: Caching, broker, and pub/sub transport
  • Next.js: Dashboard and developer control plane
  • Docker Compose: Local self-hosted deployment

πŸ“‚ Project Structure

nirman-baas/
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ package.json                          # Root NPM workspace manifest
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ turbo.json                            # Turborepo build pipelines
β”œβ”€β”€ docker-compose.yml                    # Full-stack container orchestration
β”‚
β”œβ”€β”€ gateway/                              # Go API Gateway (Chi + pgxpool)
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ go.mod
β”‚   β”œβ”€β”€ cmd/
β”‚   β”‚   └── server/
β”‚   β”‚       └── main.go                   # Entry point, graceful shutdown
β”‚   └── internal/
β”‚       β”œβ”€β”€ auth/
β”‚       β”‚   β”œβ”€β”€ jwt.go                    # Issue/verify JWT + refresh
β”‚       β”‚   β”œβ”€β”€ apikey.go                 # Generate + validate API keys
β”‚       β”‚   β”œβ”€β”€ oauth.go                  # OAuth stubs (Google/GitHub/Apple)
β”‚       β”‚   └── middleware.go             # JWT + API Key middleware
β”‚       β”œβ”€β”€ cache/
β”‚       β”‚   └── redis.go                  # Redis client + rate limit helpers
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   └── config.go                 # Env vars, all settings
β”‚       β”œβ”€β”€ database/
β”‚       β”‚   β”œβ”€β”€ postgres.go               # pgxpool connection
β”‚       β”‚   β”œβ”€β”€ query.go                  # Dynamic query builder
β”‚       β”‚   └── schema.go                 # Create/drop collections
β”‚       β”œβ”€β”€ handlers/
β”‚       β”‚   β”œβ”€β”€ handlers.go              # Base handler + helpers
β”‚       β”‚   β”œβ”€β”€ response.go              # JSON response utilities
β”‚       β”‚   β”œβ”€β”€ auth.go                  # Register/Login/Refresh
β”‚       β”‚   β”œβ”€β”€ collections.go           # Full CRUD + schema mgmt
β”‚       β”‚   └── integrations.go          # Proxy to Hub + storage + projects
β”‚       β”œβ”€β”€ middleware/
β”‚       β”‚   └── middleware.go            # Logger, RateLimit, Recover
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   β”œβ”€β”€ user.go
β”‚       β”‚   β”œβ”€β”€ project.go
β”‚       β”‚   β”œβ”€β”€ api_key.go
β”‚       β”‚   └── integration.go
β”‚       └── router/
β”‚           └── router.go                # All routes registered
β”‚
β”œβ”€β”€ hub/                                  # Integrations Hub (Bun + Hono)
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ bunfig.toml
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── src/
β”‚       β”œβ”€β”€ index.ts                      # Hono server entry
β”‚       β”œβ”€β”€ middleware/
β”‚       β”‚   └── auth.ts                   # Internal-only auth guard
β”‚       β”œβ”€β”€ vault/
β”‚       β”‚   └── credentials.ts            # AES-256-GCM credential store
β”‚       β”œβ”€β”€ registry/
β”‚       β”‚   └── providers.ts              # Dynamic provider loader
β”‚       └── integrations/
β”‚           β”œβ”€β”€ otp/
β”‚           β”‚   β”œβ”€β”€ index.ts
β”‚           β”‚   └── providers/
β”‚           β”‚       β”œβ”€β”€ twilio.ts
β”‚           β”‚       β”œβ”€β”€ msg91.ts
β”‚           β”‚       └── twofactor.ts
β”‚           β”œβ”€β”€ email/
β”‚           β”‚   β”œβ”€β”€ index.ts
β”‚           β”‚   └── providers/
β”‚           β”‚       β”œβ”€β”€ sendgrid.ts
β”‚           β”‚       β”œβ”€β”€ resend.ts
β”‚           β”‚       └── ses.ts
β”‚           β”œβ”€β”€ maps/
β”‚           β”‚   β”œβ”€β”€ index.ts
β”‚           β”‚   └── providers/
β”‚           β”‚       β”œβ”€β”€ googlemaps.ts
β”‚           β”‚       β”œβ”€β”€ mapbox.ts
β”‚           β”‚       └── ola.ts
β”‚           β”œβ”€β”€ notifications/
β”‚           β”‚   β”œβ”€β”€ index.ts
β”‚           β”‚   └── providers/
β”‚           β”‚       β”œβ”€β”€ fcm.ts
β”‚           β”‚       β”œβ”€β”€ apns.ts
β”‚           β”‚       └── onesignal.ts
β”‚           β”œβ”€β”€ payments/
β”‚           β”‚   β”œβ”€β”€ index.ts
β”‚           β”‚   └── providers/
β”‚           β”‚       β”œβ”€β”€ razorpay.ts
β”‚           β”‚       β”œβ”€β”€ stripe.ts
β”‚           β”‚       └── payu.ts
β”‚           β”œβ”€β”€ ai/
β”‚           β”‚   β”œβ”€β”€ index.ts
β”‚           β”‚   └── providers/
β”‚           β”‚       β”œβ”€β”€ openai.ts
β”‚           β”‚       β”œβ”€β”€ gemini.ts
β”‚           β”‚       └── claude.ts
β”‚           └── storage/
β”‚               └── providers/
β”‚                   └── s3.ts
β”‚
β”œβ”€β”€ workers/                              # Background Workers (Python + Celery)
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ pyproject.toml
β”‚   └── app/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ celery.py                     # Celery app + Redis broker
β”‚       β”œβ”€β”€ config.py                     # Environment config
β”‚       β”œβ”€β”€ database.py                   # PostgreSQL connection helpers
β”‚       └── tasks/
β”‚           β”œβ”€β”€ __init__.py
β”‚           β”œβ”€β”€ webhook_task.py           # HMAC-signed webhook delivery
β”‚           β”œβ”€β”€ email_task.py             # Queued email sending
β”‚           β”œβ”€β”€ notification_task.py      # Push notification dispatch
β”‚           └── cleanup_task.py           # Scheduled data cleanup
β”‚
β”œβ”€β”€ realtime/                             # WebSocket Server (Go + Redis Pub/Sub)
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ go.mod
β”‚   β”œβ”€β”€ cmd/
β”‚   β”‚   └── server/
β”‚   β”‚       └── main.go                   # WS server entry
β”‚   └── internal/
β”‚       β”œβ”€β”€ auth/
β”‚       β”‚   └── jwt.go                    # Token validation for WS
β”‚       β”œβ”€β”€ hub/
β”‚       β”‚   β”œβ”€β”€ hub.go                    # Connection manager
β”‚       β”‚   └── client.go                 # Per-client read/write pumps
β”‚       └── pubsub/
β”‚           └── redis.go                  # Redis subscriber β†’ broadcast
β”‚
β”œβ”€β”€ dashboard/                            # Admin UI (Next.js 15)
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ next.config.ts
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”œβ”€β”€ postcss.config.mjs
β”‚   β”œβ”€β”€ eslint.config.mjs
β”‚   └── src/
β”‚       β”œβ”€β”€ app/
β”‚       β”‚   β”œβ”€β”€ layout.tsx                # Root layout (dark theme)
β”‚       β”‚   β”œβ”€β”€ page.tsx                  # Dashboard overview
β”‚       β”‚   └── globals.css               # Tailwind v4 base
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   └── ui/
β”‚       β”‚       └── button.tsx            # Shadcn button
β”‚       └── lib/
β”‚           └── utils.ts                  # cn() class merger
β”‚
β”œβ”€β”€ sdk/
β”‚   β”œβ”€β”€ typescript/                       # Official TS Client (@nirman/sdk)
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”‚   └── src/
β”‚   β”‚       └── index.ts                  # NirmanClient class
β”‚   └── python/                           # Official Python Client
β”‚       β”œβ”€β”€ pyproject.toml
β”‚       β”œβ”€β”€ README.md
β”‚       └── src/
β”‚           └── nirman/
β”‚               β”œβ”€β”€ __init__.py
β”‚               └── client.py             # NirmanClient (httpx)
β”‚
β”œβ”€β”€ shared/                               # Cross-boundary TS interfaces
β”‚   β”œβ”€β”€ package.json
β”‚   └── index.ts
β”‚
β”œβ”€β”€ packages/
β”‚   └── provider-sdk/                     # [NEW] Interface contract for all providers
β”‚       β”œβ”€β”€ package.json
β”‚       β”œβ”€β”€ tsconfig.json
β”‚       └── src/
β”‚           β”œβ”€β”€ index.ts                  # Public exports
β”‚           β”œβ”€β”€ types.ts                  # Shared provider types & interfaces
β”‚           └── base/
β”‚               └── provider.ts           # BaseProvider abstract class
β”‚
β”œβ”€β”€ database/                             # Original SQL init script
β”‚   └── init.sql
β”‚
β”œβ”€β”€ infra/                                # Infrastructure configs
β”‚   β”œβ”€β”€ nginx/                            # Reverse proxy config
β”‚   β”œβ”€β”€ postgres/                         # Migration SQL files
β”‚   β”œβ”€β”€ redis/                            # Redis config
β”‚   └── scripts/                          # Utility scripts
β”‚
└── docs/                                 # Platform documentation
		β”œβ”€β”€ lists/
		β”œβ”€β”€ references/
		β”œβ”€β”€ sdks/
		β”œβ”€β”€ services/
		β”œβ”€β”€ specs/
		└── tutorials/


πŸš€ Getting Started

1. Prerequisites

  • Docker & Docker Compose
  • Node.js (v20+)

2. Setup

git clone https://github.com/yourusername/nirman-baas.git
cd nirman-baas
npm install

3. Run

docker compose up --build -d

4. Ports

Service URL
Admin Dashboard http://localhost:3001
API Gateway http://localhost:8080
Integrations Hub (Internal) http://localhost:3000
Realtime Server ws://localhost:8000
PostgreSQL localhost:5432
Redis localhost:6379

πŸ“š SDK Usage

TypeScript

import { NirmanClient } from "@nirman/sdk";
const client = new NirmanClient("nk_live_your_api_key_here");
await client.otp.send("+919876543210");

Python

from nirman import NirmanClient
client = NirmanClient(api_key="nk_live_your_api_key_here")
client.otp.send(phone="+919876543210")

πŸ“„ License

BSD 3-Clause License. See LICENSE for details.

About

The Open Source Backend-as-a-Service (BaaS) Platform

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Sponsor this project

Contributors

Languages