# Getting Started Guide This guide will help you get the Multi-Tenant SaaS Platform up and running quickly. ## Prerequisites ### System Requirements - **OS**: Linux/Unix (Ubuntu 20.04+ recommended) - **RAM**: Minimum 8GB (16GB recommended) - **CPU**: 4 cores (8 cores recommended) - **Storage**: 100GB free space - **Network**: Stable internet connection ### Software Requirements - **Python**: 3.9+ - **Node.js**: 16+ - **PostgreSQL**: 13+ - **Redis**: 6+ - **Docker**: 20.10+ (optional) - **Git**: Latest version ### Malaysian Specific Requirements - **Domain**: Registered domain name - **SSL**: SSL certificate for HTTPS - **Payment Gateway**: Malaysian payment provider account - **Data Center**: Malaysian data center or cloud region ## Quick Setup ### 1. Clone the Repository ```bash git clone https://github.com/your-org/multi-tenant-saas.git cd multi-tenant-saas ``` ### 2. Install System Dependencies ```bash # Ubuntu/Debian sudo apt update sudo apt install -y python3-pip python3-venv nodejs npm postgresql redis-server # CentOS/RHEL sudo yum install -y python3-pip nodejs npm postgresql-server redis ``` ### 3. Create Virtual Environment ```bash python3 -m venv venv source venv/bin/activate ``` ### 4. Install Python Dependencies ```bash pip install -r requirements.txt pip install -r requirements-dev.txt ``` ### 5. Install Node Dependencies ```bash cd frontend npm install cd .. ``` ### 6. Configure Environment ```bash cp .env.example .env cp frontend/.env.example frontend/.env ``` Edit the `.env` files with your configuration: ```bash # Backend .env DEBUG=False SECRET_KEY=your-secret-key-here DATABASE_URL=postgresql://user:password@localhost:5432/multi_tenant_saas REDIS_URL=redis://localhost:6379/0 ALLOWED_HOSTS=localhost,your-domain.com CORS_ALLOWED_ORIGINS=http://localhost:3000,https://your-domain.com # Malaysian Configuration TIMEZONE=Asia/Kuala_Lumpur CURRENCY=MYR SST_RATE=0.06 DEFAULT_COUNTRY=Malaysia ``` ### 7. Set Up Database ```bash # Create database sudo -u postgres createdb multi_tenant_saas sudo -u postgres createuser multi_tenant_user # Set database password sudo -u postgres psql -c "ALTER USER multi_tenant_user PASSWORD 'your-password';" # Run migrations python manage.py migrate # Create superuser python manage.py createsuperuser ``` ### 8. Set Up Redis ```bash # Start Redis service sudo systemctl start redis sudo systemctl enable redis ``` ### 9. Load Initial Data ```bash # Load initial data python manage.py load_initial_data # Create sample tenant python manage.py create_sample_tenant ``` ### 10. Start Development Servers ```bash # Start backend python manage.py runserver # In another terminal, start frontend cd frontend npm start ``` ### 11. Access the Application - Frontend: http://localhost:3000 - Backend API: http://localhost:8000 - Admin Panel: http://localhost:8000/admin/ ## Docker Quick Start ### 1. Using Docker Compose ```bash # Copy environment files cp .env.example .env cp frontend/.env.example frontend/.env # Start all services docker-compose up -d # View logs docker-compose logs -f ``` ### 2. Access Services - Frontend: http://localhost:3000 - Backend API: http://localhost:8000 - PostgreSQL: localhost:5432 - Redis: localhost:6379 ## Production Setup ### 1. Environment Configuration ```bash # Production environment cp .env.production .env cp frontend/.env.production frontend/.env # Edit with production settings vim .env vim frontend/.env ``` ### 2. Database Setup ```bash # Production database sudo -u postgres createdb multi_tenant_saas_prod sudo -u postgres createuser multi_tenant_prod_user # Set strong password sudo -u postgres psql -c "ALTER USER multi_tenant_prod_user PASSWORD 'strong-password';" # Run production migrations python manage.py migrate --settings=config.production ``` ### 3. SSL Configuration ```bash # Install Certbot sudo apt install certbot python3-certbot-nginx # Obtain SSL certificate sudo certbot --nginx -d your-domain.com -d www.your-domain.com ``` ### 4. Web Server Setup ```bash # Install Nginx sudo apt install nginx # Configure Nginx sudo cp deployment/nginx.conf /etc/nginx/sites-available/multi-tenant-saas sudo ln -s /etc/nginx/sites-available/multi-tenant-saas /etc/nginx/sites-enabled/ # Test and restart Nginx sudo nginx -t sudo systemctl restart nginx ``` ### 5. Process Management ```bash # Install Gunicorn pip install gunicorn # Create systemd service sudo cp deployment/gunicorn.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable gunicorn sudo systemctl start gunicorn ``` ## Malaysian Configuration ### 1. Payment Gateway Setup ```bash # Configure Malaysian payment gateways # Edit settings/local.py or environment variables PAYMENT_GATEWAYS = { 'touch_n_go': { 'enabled': True, 'api_key': 'your-touch-n-go-api-key', 'secret': 'your-touch-n-go-secret' }, 'grabpay': { 'enabled': True, 'api_key': 'your-grabpay-api-key', 'secret': 'your-grabpay-secret' } } ``` ### 2. Timezone Configuration ```bash # Set Malaysian timezone sudo timedatectl set-timezone Asia/Kuala_Lumpur ``` ### 3. SST Configuration ```bash # Configure SST settings SST_SETTINGS = { 'rate': 0.06, 'enabled': True, 'tax_id': 'your-sst-registration-number' } ``` ## Verification ### 1. Health Checks ```bash # Backend health check curl http://localhost:8000/health/ # Database connectivity python manage.py dbshell --command="SELECT 1;" # Redis connectivity redis-cli ping ``` ### 2. Application Testing ```bash # Run tests python manage.py test # Frontend tests cd frontend npm test ``` ### 3. Production Readiness ```bash # Check security python manage.py check --deploy # Check performance python manage.py check --settings=config.performance ``` ## Troubleshooting ### Common Issues 1. **Database Connection Errors** ```bash # Check PostgreSQL status sudo systemctl status postgresql # Check database logs sudo tail -f /var/log/postgresql/postgresql-13-main.log ``` 2. **Port Conflicts** ```bash # Check running services sudo netstat -tlnp | grep :8000 sudo netstat -tlnp | grep :3000 ``` 3. **Permission Issues** ```bash # Fix file permissions sudo chown -R $USER:$USER /path/to/project sudo chmod -R 755 /path/to/project ``` 4. **Memory Issues** ```bash # Check memory usage free -h # Check process memory ps aux --sort=-%mem | head ``` ## Support Resources ### Documentation - API Documentation: `/docs/api/` - Module Documentation: `/docs/modules/` - Deployment Guides: `/docs/deployment/` ### Community Support - GitHub Issues: https://github.com/your-org/multi-tenant-saas/issues - Community Forum: https://community.yourplatform.com - Discord Server: https://discord.gg/yourplatform ### Professional Support - Email: support@yourplatform.com - Phone: +60123456789 - Emergency: emergency@yourplatform.com ## Next Steps 1. **Customize Modules**: Enable and configure specific industry modules 2. **Set Up Monitoring**: Configure monitoring and alerting 3. **Configure Backups**: Set up automated backup procedures 4. **Deploy to Production**: Follow production deployment guide 5. **Configure Security**: Set up SSL, firewall, and security measures ## Malaysian SME Setup ### 1. Business Registration - Register your business with SSM - Obtain necessary licenses and permits - Set up business bank account ### 2. Tax Registration - Register for SST with LHDN - Obtain SST registration number - Set up tax accounting procedures ### 3. Payment Gateway - Sign up with Malaysian payment providers - Complete KYC verification - Configure payment methods ### 4. Compliance Setup - PDPA compliance procedures - Data protection policies - Privacy policy creation