Loading repository data…
Loading repository data…
karanpraja902 / repository
A production-ready SaaS boilerplate for a multi-tenant application. It utilizes a shared MongoDB schema with tenant ID filtering to ensure strict data isolation. Features include Next.js App Router performance optimizations, comprehensive RBAC, feature gating, and a fully containerized Docker deployment setup.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A secure, multi-tenant notes application with JWT authentication, role-based access control, and subscription feature gating.
This application uses a shared schema with tenant ID column approach. All data is stored in shared data structures with tenant isolation enforced through:
All accounts use password: password
admin@acme.test (Admin, Acme tenant)user@acme.test (Member, Acme tenant)admin@globex.test (Admin, Globex tenant)user@globex.test (Member, Globex tenant)GET /api/health - Health checkPOST /api/auth/login - User loginGET /api/notes - List tenant notesPOST /api/notes - Create note (with limits)GET /api/notes/:id - Get specific notePUT /api/notes/:id - Update noteDELETE /api/notes/:id - Delete notePOST /api/tenants/:slug/upgrade - Upgrade tenant (Admin only)Install MongoDB locally (if not already installed):
brew install mongodb-communityStart MongoDB service:
# Windows (if installed as service)
net start MongoDB
# macOS/Linux
brew services start mongodb-community
# or
sudo systemctl start mongod
Configure environment variables:
The .env.local file is already configured with:
MONGODB_URI=mongodb://localhost:27017/multitenantnotesapp
JWT_SECRET=your_jwt_secret_key
Create MongoDB Atlas account at mongodb.com/cloud/atlas
Create a cluster and get your connection string
Update .env.local:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/multitenantnotesapp
Run the setup script to create sample data:
npm run setup-db
This will:
Install dependencies:
npm install
Start development server:
npm run dev
Access the application:
Create a .env.local file in the root directory with the following variables:
# Database
MONGODB_URI=mongodb://localhost:27017/multitenantnotesapp
# or for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/multitenantnotesapp
# JWT Secret (use a strong, random string in production)
JWT_SECRET=your_super_secret_jwt_key_change_in_production
# Next.js
NEXTAUTH_URL=http://localhost:3000
Install Vercel CLI:
npm i -g vercel
Deploy:
vercel
Set environment variables in Vercel dashboard:
MONGODB_URIJWT_SECRETCreate Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
Build and run:
docker build -t multitenant-notes-app .
docker run -p 3000:3000 --env-file .env.local multitenant-notes-app
Build the application:
npm run build
Start production server:
npm start
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Run E2E tests
npm run test:e2e
tests/api/ - Tests for all API endpointstests/e2e/ - End-to-end frontend testsThe test suite covers:
multitenantnotesapp/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── api/ # API routes
│ │ │ ├── auth/ # Authentication endpoints
│ │ │ ├── notes/ # Notes CRUD operations
│ │ │ ├── tenants/ # Tenant management
│ │ │ └── users/ # User management
│ │ ├── dashboard/ # Main dashboard page
│ │ ├── login/ # Login page
│ │ ├── signup/ # Registration page
│ │ └── globals.css # Global styles
│ ├── components/ # React components
│ │ ├── CreateNote.tsx # Note creation form
│ │ ├── NotesList.tsx # Notes display component
│ │ ├── UserManagement.tsx # User management interface
│ │ └── SubscriptionStatus.tsx # Subscription info
│ ├── lib/ # Utility libraries
│ │ ├── auth.ts # JWT authentication
│ │ ├── db.ts # Database operations
│ │ ├── mongodb.ts # MongoDB connection
│ │ ├── rbac.ts # Role-based access control
│ │ └── types.ts # TypeScript interfaces
│ ├── models/ # MongoDB models
│ │ ├── User.ts # User schema
│ │ ├── Tenant.ts # Tenant schema
│ │ └── Note.ts # Note schema
│ └── types/ # TypeScript type definitions
├── tests/ # Test files
│ ├── api/ # API tests
│ ├── e2e/ # End-to-end tests
│ └── setup.js # Test setup
├── scripts/ # Utility scripts
│ └── setup-db.js # Database initialization
├── public/ # Static assets
├── package.json # Dependencies and scripts
├── next.config.ts # Next.js configuration
├── tailwind.config.js # Tailwind CSS configuration
└── tsconfig.json # TypeScript configuration
/api/health for monitoringFork the repository
Clone your fork:
git clone https://github.com/yourusername/multitenantnotesapp.git
cd multitenantnotesapp
Install dependencies:
npm install
Set up environment variables:
cp .env.example .env.local
# Edit .env.local with your configuration
Initialize database:
npm run setup-db
Start development server:
npm run dev
git checkout -b feature/amazing-featurenpm testnpm run buildgit commit -m 'feat: add amazing feature'git push origin feature/amazing-feature# Check MongoDB service status
# Windows
net start MongoDB
# macOS/Linux
brew services start mongodb-community
# or
sudo systemctl start mongod
# Clear Next.js cache
rm -rf .next
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
# Rebuild
npm run build
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ using Next.js, MongoDB, and Tailwind CSS