Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

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

Repository files navigation

Modern Multi-Tenant ScaleNest

A complete, production-ready multi-tenant ScaleNest built with the MERN stack (MongoDB, Express, React, Node.js) featuring authentication, workspace management, and a modern dashboard.

πŸš€ Features

Authentication & Security

  • JWT-based authentication
  • Secure password hashing with bcrypt
  • Protected routes and API endpoints
  • Multi-tenant data isolation

Multi-Tenant Architecture

  • Create and manage multiple workspaces
  • Invite team members via invite codes
  • Role-based access control (Admin, Member, Viewer)
  • Seamless workspace switching

Project & Task Management

  • Create and organize projects
  • Kanban-style task management
  • Priority levels and status tracking
  • Team collaboration features

Analytics & Insights

  • Interactive charts and visualizations
  • Team performance metrics
  • Progress tracking
  • Activity monitoring

Modern UI/UX

  • Beautiful landing page with pricing tiers
  • Responsive design (mobile, tablet, desktop)
  • Smooth animations with Framer Motion
  • Tailwind CSS styling
  • Collapsible sidebar navigation

πŸ›  Tech Stack

Frontend

  • React 18.2 - UI library
  • Vite - Build tool
  • React Router DOM - Routing
  • Tailwind CSS - Styling
  • Framer Motion - Animations
  • Recharts - Data visualization
  • Axios - HTTP client
  • Context API - State management

Backend

  • Node.js - Runtime environment
  • Express - Web framework
  • MongoDB - Database
  • Mongoose - ODM
  • JWT - Authentication
  • bcryptjs - Password hashing
  • CORS - Cross-origin resource sharing

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v16 or higher)
  • MongoDB (v5 or higher)
  • npm or yarn

πŸ”§ Installation & Setup

1. Clone the Repository

git clone <repository-url>
cd saas-platform

2. Backend Setup

cd backend

# Install dependencies
npm install

# Create .env file
cp .env.example .env

# Edit .env with your configuration
# Required variables:
# - MONGODB_URI: Your MongoDB *** string
# - JWT_SECRET: A strong random secret key
# - PORT: Backend server port (default: 5000)

Example .env configuration:

PORT=5000
MONGODB_URI=mongodb://localhost:27017/saas-platform
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
JWT_EXPIRE=7d
NODE_ENV=development

3. Frontend Setup

cd ../frontend

# Install dependencies
npm install

4. Database Setup

Make sure MongoDB is running on your system:

# For macOS (with Homebrew)
brew services start mongodb-community

# For Linux
sudo systemctl start mongod

# For Windows
# MongoDB should start automatically, or use MongoDB Compass

πŸš€ Running the Application

Development Mode

Terminal 1 - Backend:

cd backend
npm run dev

Backend will run on http://localhost:5000

Terminal 2 - Frontend:

cd frontend
npm run dev

Frontend will run on http://localhost:3000

Production Build

Backend:

cd backend
npm start

Frontend:

cd frontend
npm run build
npm run preview

πŸ“ Project Structure

saas-platform/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── database.js          # MongoDB ***
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ authController.js    # Authentication logic
β”‚   β”‚   β”œβ”€β”€ workspaceController.js
β”‚   β”‚   β”œβ”€β”€ projectController.js
β”‚   β”‚   └── taskController.js
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ auth.js              # JWT verification
β”‚   β”‚   └── tenant.js            # Multi-tenant isolation
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   β”œβ”€β”€ Workspace.js
β”‚   β”‚   β”œβ”€β”€ Membership.js
β”‚   β”‚   β”œβ”€β”€ Project.js
β”‚   β”‚   └── Task.js
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js
β”‚   β”‚   β”œβ”€β”€ workspaceRoutes.js
β”‚   β”‚   β”œβ”€β”€ projectRoutes.js
β”‚   β”‚   └── taskRoutes.js
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── generateToken.js
β”‚   β”œβ”€β”€ .env.example
β”‚   β”œβ”€β”€ package.json
β”‚   └── server.js
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ DashboardLayout.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.jsx
β”‚   β”‚   β”‚   └── ProtectedRoute.jsx
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthContext.jsx
β”‚   β”‚   β”‚   └── WorkspaceContext.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Overview.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Projects.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Tasks.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Team.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Analytics.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Settings.jsx
β”‚   β”‚   β”‚   β”‚   └── Billing.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Landing.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Register.jsx
β”‚   β”‚   β”‚   └── WorkspaceSetup.jsx
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ main.jsx
β”‚   β”‚   └── index.css
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   β”œβ”€β”€ postcss.config.js
β”‚   └── vite.config.js
β”‚
└── README.md

πŸ”‘ API Endpoints

The lists below include all backend GET and POST routes grouped by area.

Root

  • GET / - Health check / welcome message

Authentication (/api/auth)

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/me - Get current user

Workspaces (/api/workspaces)

  • POST /api/workspaces - Create workspace
  • POST /api/workspaces/switch - Switch active workspace
  • POST /api/workspaces/join - Join workspace with invite code
  • GET /api/workspaces/my - Get user's workspaces
  • GET /api/workspaces/:id - Get workspace details
  • GET /api/workspaces/:id/members - Get workspace members

Projects (/api/projects)

  • POST /api/projects - Create project
  • GET /api/projects - Get all projects
  • GET /api/projects/my - Get projects for current user
  • GET /api/projects/:id - Get project details

Tasks (/api/tasks)

  • POST /api/tasks - Create task
  • GET /api/tasks - Get all tasks (with filters)
  • GET /api/tasks/project/:projectId - Get tasks for a project
  • GET /api/tasks/:id - Get task details

Analytics (/api/analytics)

  • GET /api/analytics - Get analytics summary

Notifications (/api/notifications)

  • GET /api/notifications - Fetch notifications
  • GET /api/notifications/export - Export notifications
  • POST /api/notifications/:id/accept-invite - Accept invite from notification
  • POST /api/notifications/:id/reject-invite - Reject invite from notification

Alerts (/api/alerts)

  • GET /api/alerts/tasks - Fetch task deadline alerts
  • POST /api/alerts/check-deadlines - Trigger deadline check

Audit Logs (/api/admin)

  • GET /api/admin/audit-logs - Get audit logs
  • GET /api/admin/audit-logs/stats - Get audit log stats
  • GET /api/admin/audit-logs/export - Export audit logs
  • GET /api/admin/audit-logs/:id - Get audit log by id

Tenant Branding (/api/tenant)

  • POST /api/tenant/logo - Upload workspace logo
  • POST /api/tenant/create - Create workspace with branding
  • GET /api/tenant/settings - Get tenant settings

Invitations (/api)

  • GET /api/invite/info/:token - Get invite info (public)
  • POST /api/invite/accept/:token - Accept invite
  • POST /api/invite/reject/:token - Reject invite
  • POST /api/projects/:id/invite - Send project invite
  • GET /api/projects/:id/invitations - Get project invitations
  • POST /api/projects/:id/invite/:inviteId/resend - Resend project invite
  • GET /api/projects/:id/members - Get project members

Chats (/api/chats)

  • POST /api/chats/direct - Create direct chat
  • POST /api/chats/group - Create group chat
  • POST /api/chats/group/project - Create project group chat
  • GET /api/chats - Get workspace chats

Messages (/api/messages)

  • POST /api/messages - Send message
  • POST /api/messages/:id/react - Add reaction to message
  • POST /api/messages/upload - Upload message attachments
  • GET /api/messages/:chatId - Get messages for a chat

Billing (/api/billing)

  • GET /api/billing/info - Get billing info
  • POST /api/billing/upgrade - Upgrade plan
  • GET /api/billing/usage - Get usage stats
  • GET /api/billing/invoices - Get invoices
  • GET /api/billing/invoices/:invoiceId/download - Download invoice

🎨 Application Flow

  1. Landing Page β†’ User sees features, pricing, and testimonials
  2. Registration/Login β†’ User creates account or logs in
  3. Workspace Setup β†’ User creates or joins a workspace
  4. Dashboard β†’ User accesses their workspace dashboard
  5. Project Management β†’ Create and manage projects
  6. Task Management β†’ Organize tasks across projects
  7. Team Collaboration β†’ Invite members and assign work
  8. Analytics β†’ Track progress and performance

πŸ” Multi-Tenant Architecture

The platform implements true multi-tenancy with:

  • Data Isolation: Each workspace's data is completely separated
  • Workspace Context: All API requests include workspace ID
  • Membership Roles: Fine-grained access control
  • Invite System: Secure workspace joining via invite codes

🎯 Usage Examples

Creating a Workspace

POST /api/workspaces
{
  "name": "My Company"
}

Adding a Task

POST /api/tasks
Headers: { "x-workspace-id": "workspace_id" }
{
  "title": "Implement authentication",
  "description": "Add JWT authentication",
  "priority": "high",
  "status": "todo"
}

🀝 Contributing

Contributions are welcome! Please follow these steps:

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

πŸ“ Environment Variables

Backend (.env)

PORT=5000
MONGODB_URI=mongodb://localhost:27017/saas-platform
JWT_SECRET=your_secret_key_here
JWT_EXPIRE=7d
NODE_ENV=development

πŸ› Troubleshooting

MongoDB Connection Issues

  • Ensure MongoDB is running
  • Check MONGODB_URI in .env
  • Verify MongoDB is accessible on the specified port

CORS Errors

  • Backend CORS is configured to allow all origins in development
  • For production, update CORS settings in server.js

Port Already in Use

  • Change PORT in backend .env
  • Change port in frontend vite.config.js

πŸ“„ License

This project is licensed under the MIT License.

πŸ™ Acknowledgments

  • React community for amazing tools
  • MongoDB for flexible database
  • Tailwind CSS for beautiful styling
  • Framer Motion for smooth animations

πŸ“§ Support

For support, please open an issue in the repository or contact the development team.


Built with ❀️ using the MERN stack

About

ScaleNest is a production-ready multi-tenant SaaS platform built using the MERN stack. The idea is similar to platforms like Notion, Slack, or Jira, where multiple companies use the same application but each company can only access its own data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages