A comprehensive, production-ready framework for building scalable multi-tenant SaaS applications with Flutter frontend and NestJS backend.
This is a monorepo containing:
- Backend: NestJS + Fastify + TypeORM + PostgreSQL
- Frontend: Flutter + Dart (mobile + web)
- Database: PostgreSQL with multi-tenancy support
- Containerization: Docker for development and production
- Node.js 18+ and npm 8+
- Flutter 3.0+
- Docker and Docker Compose
- PostgreSQL 14+
# Clone and setup
git clone <repository-url>
cd saas-framework
# Install dependencies
npm run setup
# Start database only
npm run start:db
# Start full development stack (database + backend)
npm run start:dev
# Start development servers
npm run dev# Run the complete setup and customization script
./setup.sh
# Or follow the detailed guide
# See: docs/development/project-customization-checklist.md# Start PostgreSQL + pgAdmin
npm run start:db
# Stop services
npm run stop:db
# Reset database (removes all data)
npm run reset:db# Start database + backend (with hot reload)
npm run start:dev
# Stop all services
npm run stop:dev
# View logs
docker-compose -f docker/docker-compose.yml logs -f backend# Database only
docker-compose -f docker/docker-compose.yml up -d
# Full development stack
docker-compose -f docker/docker-compose.yml --profile development up -d- PostgreSQL:
localhost:5432(database:saas_framework) - pgAdmin:
localhost:5050(admin@saasframework.com / admin) - Backend API:
localhost:3000(development profile only)
- Monorepo Architecture - Overall system design and structure
- Multi-tenancy Design - Multi-tenant architecture patterns
- Clean Architecture - Architectural principles and patterns
- Database Design - Database schema and relationships
- Development Setup - Environment setup and configuration
- Project Customization - How to customize for your business
- Framework Customization - Complete list of entities, classes, and docs to update/delete
- Development Workflow - How to develop features
- Testing Strategy - Testing approach and tools
- Contributing Guidelines - How to contribute
- Database Overview - Complete database documentation
- Schema Overview - High-level database design
- Entity Documentation - Individual entity specifications
- Relationships - Table relationships and constraints
- Migrations - Migration history and guidelines
- Database Diagrams - Visual schema representations
- Entity Management - Entity management endpoints
- Multi-tenant Authentication - Tenant management APIs
- API Client - Frontend API client patterns
- Backend Documentation Overview - Complete backend documentation hub
- Backend Architecture - Detailed backend architecture
- Backend Setup - Backend-specific setup guide
- Backend Testing - Backend testing guide
- Backend API Endpoints - Complete backend API documentation
- Backend API Documentation - Complete backend API documentation
- Frontend Documentation Overview - Complete frontend documentation hub
- Flutter Clean Architecture - Flutter Clean Architecture implementation
- State Management Guide - Riverpod state management patterns
- Error Handling Architecture - Comprehensive error handling system
- Flutter Setup Guide - Complete Flutter development setup
- Localization Guide - Multi-language support with ARB files
- Navigation Guide - GoRouter navigation patterns
- Performance Guide - Performance optimization strategies
- Deployment Guide - Build and deploy across platforms
- Flutter Testing Guide - Comprehensive Flutter testing strategy
- Test Tagging Guide - Advanced test organization and execution
- Design System - Material Design implementation and UI components
- Loading Widgets - Shared loading components and scenarios
- API Integration Guide - Backend API communication patterns
npm run dev # Start both backend and frontend
npm run dev:backend # Start backend only
npm run dev:frontend # Start frontend onlynpm run build # Build both backend and frontend
npm run build:backend # Build backend only
npm run build:frontend # Build frontend onlynpm run test:backend # Run backend tests
npm run test:frontend # Run frontend testsnpm run start:db # Start PostgreSQL database
npm run stop:db # Stop database
npm run reset:db # Reset database (removes all data)npm run docs:build # Build all shared documentation
npm run docs:serve # Serve shared documentation locally
npm run docs:architecture # View architecture documentation
npm run docs:development # View development documentation
npm run docs:api # View API documentationnpm run lint:backend # Lint backend code
npm run clean # Clean all build artifacts
npm run setup # Initial project setup# Framework compliance checkers
npm run check:framework:backend # Check backend framework compliance
npm run check:framework:frontend # Check Flutter framework compliance
npm run check:framework:watch # Watch backend for changes
npm run check:framework:frontend:watch # Watch frontend for changes
npm run check:all # Run all framework checkers
# Hardcoded content checkers
npm run check:hardcoded:frontend # Check for hardcoded text/styling
npm run check:hardcoded:frontend:watch # Watch for hardcoded violationsThis project includes automated checkers to maintain code quality and enforce design patterns.
# Check backend code for framework compliance
npm run check:framework:backend
# Watch mode - automatically check on file changes
npm run check:framework:watch
# Check specific path
npm run check:framework:backend -- apps/backend/src/modules/userWhat it checks:
- Clean Architecture violations
- Generic terminology usage
- Multi-tenancy patterns
- Error handling compliance
- Type safety issues
# Check Flutter code for framework compliance
npm run check:framework:frontend
# Watch mode - automatically check on file changes
npm run check:framework:frontend:watch
# Check specific path
npm run check:framework:frontend -- apps/frontend/lib/features/homeWhat it checks:
- Clean Architecture patterns
- State management compliance
- Error handling with FrameworkException
- Multi-tenancy implementation
- Accessibility compliance
# Check for hardcoded text and styling
npm run check:hardcoded:frontend
# Watch mode - automatically check on file changes
npm run check:hardcoded:frontend:watch
# Check specific path
npm run check:hardcoded:frontend -- apps/frontend/lib/features/homeWhat it checks:
- Hardcoded user-facing text (should be in ARB files)
- Hardcoded colors (should use theme colors)
- Hardcoded sizes (should use AppStyles constants)
- Missing localization imports
- Direct styling instead of theme-based styling
All checkers provide detailed output with:
- File locations and line numbers
- Violation types (ERROR, WARNING, INFO)
- Specific suggestions for fixes
- Code snippets showing the issue
- Summary statistics (total violations, warnings, etc.)
The checkers are designed to be run:
- During development - Use watch mode for real-time feedback
- Before commits - Run all checkers to ensure compliance
- In CI/CD - Automated checking in GitHub Actions
- Code reviews - Verify compliance before merging
- Reusable: Works for any SaaS business domain
- Multi-tenant: Built-in tenant isolation and management
- Scalable: Clean Architecture patterns for enterprise growth
- Type-safe: Strict TypeScript throughout
- Production-ready: Comprehensive error handling and monitoring
- Clean Architecture: Domain, Application, Infrastructure, Presentation
- Multi-tenancy: Generic tenant management
- Event-driven: Domain events and event bus
- Comprehensive Logging: Structured logging with context
- API Validation: DTO validation with class-validator
- Error Handling: Global exception filters
- Testing: Unit and integration test framework
- Cross-platform: Mobile and web support
- State Management: Provider/Riverpod patterns
- Responsive Design: Material Design 3
- Generic Components: Reusable UI components
- Loading System: Smooth transitions with localization support
- API Integration: Type-safe API client
This framework is designed for SaaS applications:
- Tenant Isolation: Complete data separation by tenant
- Scalable Multi-tenancy: Support for unlimited SaaS customers
- Secure: Proper tenant context validation and access control
- Subscription-ready: Built for SaaS billing and subscription models
- Framework: NestJS with Fastify
- Language: TypeScript (strict mode)
- Database: PostgreSQL with TypeORM
- Validation: class-validator + class-transformer
- Testing: Jest + Testcontainers
- Logging: Custom LoggerService
- Framework: Flutter
- Language: Dart
- State Management: Provider/Riverpod
- UI: Material Design 3
- Testing: Flutter Test
- Containerization: Docker + Docker Compose
- Database: PostgreSQL
- CI/CD: GitHub Actions (planned)
saas-framework/
βββ apps/
β βββ backend/ # NestJS API
β β βββ src/
β β β βββ core/ # Domain layer
β β β βββ application/ # Application layer
β β β βββ infrastructure/ # Infrastructure layer
β β β βββ presentation/ # Presentation layer
β β β βββ common/ # Shared utilities
β β βββ test/ # Backend tests
β β βββ .cursorrules # Backend development rules
β βββ frontend/ # Flutter app
β βββ lib/
β βββ test/
β βββ .cursorrules # Frontend development rules
βββ docs/ # Documentation
βββ docker/ # Docker configuration
β βββ docker-compose.yml # Docker services
β βββ Dockerfile.backend # Backend container
βββ package.json # Root package.json
βββ .cursorrules # Project-wide rules
- Read the Contributing Guidelines
- Follow the Backend Development Rules
- Follow the Frontend Development Rules
- Write tests for new features
- Update documentation as needed
MIT License - see LICENSE file for details.
- Documentation: Check the docs/ directory
- Issues: Create a GitHub issue
- Discussions: Use GitHub Discussions for questions
Built with β€οΈ for scalable, multi-tenant SaaS applications