A modern, scalable multi-tenant workspace management system built with Next.js 15, AWS DynamoDB, S3, and shadcn/ui. Perfect for organizations that need isolated workspaces for different teams or clients with secure file management capabilities.
- Custom username/password authentication system
- Secure password hashing with bcrypt (12 rounds)
- Complete user data isolation
- Session-based authentication with React Context
- Users can create multiple isolated workspaces
- Workspaces contain multiple projects
- Projects manage files with secure access control
- Hierarchical permission system ensuring data isolation
- Secure file uploads to AWS S3
- Pre-signed URLs for secure downloads (1-hour expiry)
- File size and count limitations
- Organized file structure:
users/{userId}/workspaces/{workspaceId}/projects/{projectId}/{fileName}
- Workspaces per user: 10 (configurable)
- Projects per workspace: 10 (configurable)
- Files per project: 5 (configurable)
- File size limit: 2MB per file (configurable)
- Easy configuration via
src/config/global-config.ts
- Responsive design built with Tailwind CSS
- shadcn/ui components for consistent, accessible design system
- Beautiful, customizable UI components (buttons, cards, dialogs, forms)
- Real-time limit indicators in the UI
- Loading states and error handling
- Intuitive breadcrumb navigation
- Dark/light mode compatible design tokens
This project features a comprehensive, production-ready test suite that ensures reliability and maintainability:
- 100% Test Suite Success Rate: All 10 test suites passing
- 61 Individual Tests: Complete coverage of all functionality
- 6 Snapshot Tests: UI consistency verification
- Zero Test Failures: Robust, reliable test implementation
- Web API Polyfills: Custom mocks for Next.js API route testing
- AWS Service Mocking: Complete isolation from external dependencies
- User-Centric Testing: Focus on user interactions and behavior
- Error Scenario Coverage: Comprehensive error handling validation
- Accessibility Testing: Built-in a11y compliance checks
- Unit Tests: Component-level testing with React Testing Library
- Integration Tests: End-to-end user flow validation
- API Tests: Next.js route handler testing with custom polyfills
- Snapshot Tests: UI regression prevention
- Mock Strategy: Sophisticated mocking for external dependencies
- Node.js 18+
- npm or yarn
- AWS Account with programmatic access
- AWS DynamoDB and S3 access
-
Clone the repository
git clone https://github.com/your-username/multi-tenancy-aws.git cd multi-tenancy-aws -
Install dependencies
npm install
-
Set up environment variables
Create a
.env.localfile in the root directory:# AWS Configuration AWS_ACCESS_KEY_ID=your_access_key_here AWS_SECRET_ACCESS_KEY=your_secret_access_key_here AWS_REGION=ap-southeast-2 # DynamoDB Table Names DYNAMODB_USERS_TABLE=multi-tenancy-users DYNAMODB_WORKSPACES_TABLE=multi-tenancy-workspaces DYNAMODB_PROJECTS_TABLE=multi-tenancy-projects # S3 Configuration S3_BUCKET_NAME=multi-tenancy-files-bucket
-
Start the development server
npm run dev
-
Set up AWS resources
After the server is running, create the required DynamoDB tables and S3 bucket:
# Create DynamoDB tables curl -X POST http://localhost:3000/api/setup-tables # Create S3 bucket curl -X POST http://localhost:3000/api/setup-s3
-
Open your browser
Navigate to http://localhost:3000 and start using the application!
- Register a new account or login with existing credentials
- Create a workspace for your team or project
- Add projects within your workspace
- Upload and manage files for each project
All system limits can be easily configured in src/config/global-config.ts:
export const LIMITS = {
WORKSPACES_PER_USER: 10,
PROJECTS_PER_WORKSPACE: 10,
FILES_PER_PROJECT: 5,
MAX_FILE_SIZE_BYTES: 2 * 1024 * 1024, // 2MB
MAX_FILE_SIZE_MB: 2,
} as const- Frontend: Next.js 15 with React 19 and TypeScript
- Backend: Next.js API Routes
- Database: AWS DynamoDB with Global Secondary Indexes
- File Storage: AWS S3 with hierarchical organization
- UI Framework: Tailwind CSS + shadcn/ui component library
- Components: Radix UI primitives with custom styling
- Authentication: Custom implementation with bcrypt
- Styling: CSS-in-JS with Tailwind utility classes
User
โโโ Workspaces (max 10)
โ โโโ Projects (max 10 per workspace)
โ โ โโโ Files (max 5 per project, 2MB each)
- DynamoDB Tables: Users, Workspaces, Projects
- S3 Bucket: Organized file storage with user isolation
- IAM: Proper permissions for DynamoDB and S3 access
# Development
npm run dev # Start development server with Turbopack
npm run build # Production build
npm run start # Start production server
# Testing
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage
# Code Quality
npm run lint # Run ESLintsrc/
โโโ app/ # Next.js App Router
โ โโโ api/ # API routes
โ โโโ globals.css # Global styles
โโโ components/ # React components
โ โโโ ui/ # shadcn/ui components
โ โโโ __tests__/ # Component tests
โโโ config/ # Configuration files
โ โโโ global-config.ts # System limits and settings
โโโ contexts/ # React contexts
โโโ lib/ # Utility libraries
โ โโโ auth.ts # Authentication logic
โ โโโ aws-config.ts # AWS SDK configuration
โ โโโ project.ts # Project management
โ โโโ storage.ts # S3 file operations
โ โโโ workspace.ts # Workspace management
โโโ types/ # TypeScript type definitions
The project includes a comprehensive test suite with 100% test coverage:
- โ Unit Tests: Individual component testing (AuthForm, WorkspaceList, FileManager)
- โ Integration Tests: End-to-end user flows (auth flow, workspace-project flow)
- โ API Tests: Next.js route handler testing (auth, workspaces, projects)
- โ Snapshot Tests: UI consistency verification
- โ Test Coverage: 61 tests passing across 10 test suites
Test Results:
- ๐ข 10 test suites passed (100% success rate)
- ๐ข 61 tests passed (all individual tests working)
- ๐ข 6 snapshots passed (all snapshot tests working)
Run tests:
npm test # All tests
npm test components # Component tests only
npm test integration # Integration tests only
npm test api # API tests only
npm run test:coverage # Run with coverage reportTest Features:
- Complete Web API polyfills for Next.js API route testing
- Comprehensive mocking strategy for AWS services
- User-centric testing with React Testing Library
- Error scenario coverage for all critical paths
- Accessibility testing included
- Complete User Isolation: All data is scoped to individual users
- Secure File Storage: S3 keys enforce hierarchical access control
- Password Security: bcrypt hashing with high salt rounds
- Pre-signed URLs: Time-limited secure file access
- Input Validation: Server-side validation for all inputs
- Error Handling: Secure error responses without data leakage
- Push your code to GitHub
- Connect your repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy automatically on every push
npm run build
npm start- Use separate AWS resources for production (
-prodsuffix) - Implement proper monitoring and logging
- Set up backup strategies for DynamoDB
- Configure CORS for production domains
- Review and adjust rate limiting
All limits are configurable and enforced both client-side and server-side:
| Setting | Default | Description |
|---|---|---|
WORKSPACES_PER_USER |
10 | Maximum workspaces per user |
PROJECTS_PER_WORKSPACE |
10 | Maximum projects per workspace |
FILES_PER_PROJECT |
5 | Maximum files per project |
MAX_FILE_SIZE_MB |
2 | Maximum file size in MB |
Control which limits are displayed to users:
export const UI_CONFIG = {
SHOW_LIMITS: {
WORKSPACE_COUNT: true,
PROJECT_COUNT: true,
FILE_COUNT: true,
FILE_SIZE: true,
},
} as constWe welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style (ESLint configuration)
- Write tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
Comprehensive documentation is available in the /docs directory:
- Development Guide - Complete development workflow and best practices
- Testing Guide - Comprehensive testing strategy and implementation
- Testing Achievements - Test suite accomplishments and technical solutions
- Implementation Overview - Technical architecture and features
- Vercel Deployment Guide - Step-by-step deployment instructions
- Documentation: Check the
/docsdirectory for detailed guides - Issues: Report bugs or request features via GitHub Issues
- Questions: Start a discussion in GitHub Discussions
- OAuth provider integration (Google, GitHub, etc.)
- File preview functionality
- Real-time collaboration features
- Advanced permission system
- Audit logging and activity tracking
- File versioning support
- Workspace sharing between users
- API documentation with OpenAPI
- Docker containerization
- Kubernetes deployment guides
Perfect for:
- Development Teams: Separate projects for different clients
- Agencies: Isolated workspaces for each client
- Educational Institutions: Student project management
- Small Businesses: Department-based file organization
- Consultants: Client-specific document management
Built with โค๏ธ using Next.js, AWS, and modern web technologies.
Star โญ this repository if you find it helpful!