บริการ cloud ที่จำเป็นสำหรับการพัฒนาและ deploy ระบบ Half-Stack
Core Cloud Stack
1. Supabase (Backend as a Service)
Supabase ให้บริการ:
├─ PostgreSQL Database
├─ Authentication & Authorization
├─ Real-time Subscriptions
├─ Edge Functions
├─ File Storage
└─ Auto-generated APIs
ข้อดีสำหรับธุรกิจไทย:
✅ Free tier ใช้งานได้จริง
✅ ไม่ต้องดูแล database
✅ Real-time สำหรับ chat
✅ ใช้งานง่ายกว่า Firebase
2. Vercel (Frontend & Serverless)
Vercel ให้บริการ:
├─ Static Site Hosting
├─ Serverless Functions
├─ Edge Network
├─ Automatic Deployments
└─ Performance Analytics
ข้อดีสำหรับ Half-Stack:
✅ Deploy จาก GitHub อัตโนมัติ
✅ Serverless functions ฟรี
✅ Global CDN
✅ เหมาะกับ Next.js
3. Railway (Backend Hosting)
Railway ให้บริการ:
├─ Docker Container Hosting
├─ PostgreSQL Databases
├─ Static IP Addresses
├─ Custom Domains
└─ Environment Variables
ข้อดีสำหรับ n8n:
✅ รัน n8n ได้ง่าย
✅ มี IP คงที่สำหรับ webhook
✅ Auto-scaling
✅ ราคาเป็นธรรม
Service Comparison
| Feature | Supabase | Vercel | Railway | n8n Cloud |
|---|---|---|---|---|
| Database | ✅ PostgreSQL | ❌ | ✅ PostgreSQL | ❌ |
| Auth | ✅ Built-in | ❌ | ❌ | ❌ |
| Functions | ✅ Edge Functions | ✅ Serverless | ✅ Docker | ❌ |
| Storage | ✅ File Storage | ❌ | ❌ | ❌ |
| Free Tier | ✅ Generous | ✅ Good | ❌ Limited | ❌ |
| Thai Support | ✅ Good | ✅ Good | ✅ Good | ✅ Good |
Getting Started
Step 1: Supabase Setup
- สร้าง project ที่ supabase.com
- ดู connection string ใน Settings → Database
- สร้าง table ผ่าน SQL Editor:
CREATE TABLE customers (
id SERIAL PRIMARY KEY,
line_user_id VARCHAR(255) UNIQUE,
name VARCHAR(255),
phone VARCHAR(20),
email VARCHAR(255),
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
order_id VARCHAR(50) UNIQUE,
customer_id INTEGER REFERENCES customers(id),
items JSONB,
total_amount DECIMAL(10,2),
status VARCHAR(50),
created_at TIMESTAMP DEFAULT NOW()
);
Step 2: Vercel Setup
- เชื่อมต่อ GitHub repository
- ตั้งค่า environment variables
- Deploy อัตโนมัติทุกครั้งที่ push
- ใช้ serverless functions สำหรับ API
Step 3: Railway Setup
- สร้าง project และเชื่อม GitHub
- ตั้งค่า Dockerfile สำหรับ n8n:
FROM n8nio/n8n
ENV N8N_ENCRYPTION_KEY=your-key
ENV WEBHOOK_URL=https://your-app.railway.app/
Cost Analysis
Free Tier Limits
Supabase:
├─ 500MB Database
├─ 50MB File Storage
├─ 2GB Bandwidth
├─ 60,000 API calls/month
└─ 2 Edge Functions
Vercel:
├─ 100GB Bandwidth
├─ 100 Serverless Function invocations
├─ 1 Static Site
└─ Unlimited projects
Railway:
├─ $5 credit/month
├─ 500 hours compute
└─ 100GB data transfer
Estimated Monthly Costs
Small Business:
├─ Supabase: $0 (Free tier)
├─ Vercel: $0 (Free tier)
├─ Railway: $5-20 (n8n hosting)
└─ Total: $5-20/month
Growing Business:
├─ Supabase: $25 (Pro tier)
├─ Vercel: $20 (Pro tier)
├─ Railway: $20-50 (multiple services)
└─ Total: $65-95/month
Enterprise:
├─ Supabase: $599+ (Team tier)
├─ Vercel: $100+ (Team tier)
├─ Railway: $100+ (multiple apps)
└─ Total: $799+/month
Integration Examples
Example 1: LINE Chatbot Architecture
LINE OA → n8n (Railway) → Custom API (Vercel) → Supabase Database
Data Flow:
- LINE ส่ง message ไปที่ n8n webhook
- n8n ประมวลผลและเรียก API บน Vercel
- Vercel function บันทึก/อ่านข้อมูลจาก Supabase
- n8n ส่ง reply กลับไปที่ LINE
Example 2: Order Processing System
Customer → Frontend (Vercel) → API (Vercel) → Supabase → n8n (Railway) → Notifications
Components:
- Frontend: Vercel static site (Next.js)
- API: Vercel serverless functions
- Database: Supabase PostgreSQL
- Automation: n8n on Railway
- Notifications: LINE, Email via n8n
Example 3: Real-time Dashboard
Sensors → API (Vercel) → Supabase (Real-time) → Dashboard (Vercel) → n8n (Alerts)
Features:
- Real-time updates ด้วย Supabase subscriptions
- Dashboard บน Vercel
- Automated alerts ผ่าน n8n
- Data processing บน Vercel functions
Security Best Practices
Environment Variables
# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_KEY=your-service-key
# Vercel
NEXT_PUBLIC_SUPABASE_URL=your-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
# Railway
DATABASE_URL=postgresql://user:pass@host:port/db
N8N_ENCRYPTION_KEY=your-encryption-key
API Security
// Vercel Function - Protect with API key
export default async function handler(req, res) {
const apiKey = req.headers['x-api-key'];
if (apiKey !== process.env.API_KEY) {
return res.status(401).json({ error: 'Unauthorized' });
}
// Your API logic here
}
Database Security
-- Supabase RLS (Row Level Security)
ALTER TABLE customers ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users can view own data" ON customers
FOR SELECT USING (auth.uid() = line_user_id);
CREATE POLICY "Users can update own data" ON customers
FOR UPDATE USING (auth.uid() = line_user_id);
Monitoring & Analytics
Supabase Dashboard
- Database performance
- API usage statistics
- Storage usage
- Real-time connections
Vercel Analytics
- Page views and visitors
- Web Vitals (performance)
- Function execution time
- Error tracking
Railway Monitoring
- Container health
- Resource usage
- Deployment logs
- Network metrics
Custom Monitoring with n8n
Schedule Trigger → Health Check Functions → IF Node → Alert System
Backup & Recovery
Supabase Backups
- Automatic daily backups
- Point-in-time recovery
- Export to SQL
- 30-day retention
Application Backups
# Backup Vercel deployment
vercel pull --environment=production
# Backup Railway data
railway logs > app-logs.txt
# GitHub backup (code)
git push origin main
Disaster Recovery Plan
- Database: Restore from Supabase backup
- Application: Redeploy from GitHub
- Configuration: Restore environment variables
- Data: Sync from backup systems
Migration Guide
From Local to Cloud
# Export local database
pg_dump local_db > backup.sql
# Import to Supabase
psql $DATABASE_URL < backup.sql
# Update environment variables
# Deploy to Vercel/Railway
From Other Providers
Firebase → Supabase:
├─ Export Firestore data
├─ Convert to SQL schema
├─ Import to Supabase
└─ Update authentication
Heroku → Railway:
├─ Export database
├─ Create Dockerfile
├─ Deploy to Railway
└─ Update DNS
Next Steps
- Supabase Basics - ใช้งาน Supabase
- Vercel Deployment - Deploy แอปพลิเคชัน
- APIs & Webhooks - การเชื่อมต่อ API
ต้องการความช่วยเหลือ? ติดต่อเราได้ที่ ShantiLink.com 💬