This is the multi-page printable view of this section. .
Concept
-
1: Overview
-
2: Architecture
-
3: Storage
-
4: Snapshot
-
5: Clone
-
6: Monitoring
-
7: Security
Concept documentation helps you understand the principles and architecture behind Piglet Run.
What You’ll Learn
- How Piglet Run works under the hood
- The design philosophy and architecture
- Key concepts like snapshots, cloning, and storage
Topics
1 - Overview
What is Piglet Run?
Piglet Run is a lightweight runtime environment from Pigsty, designed as a cloud coding sandbox for AI Web Coding. It integrates PostgreSQL database, JuiceFS distributed storage, VS Code, JupyterLab, and more into a unified environment.
Why Piglet Run?
In the age of AI-assisted development, developers need:
- Instant development environments that just work
- Powerful databases with all extensions available
- Safe experimentation with easy rollback
- Seamless collaboration between humans and AI agents
Piglet Run provides all of this in a single package.
Key Features
| Feature | Description |
|---|---|
| 🤖 AI Coding | Pre-installed Claude Code, OpenCode, VS Code, Jupyter |
| 🐘 Data Powerhouse | PostgreSQL 18 + 400+ extensions |
| 💾 Shared Storage | JuiceFS stores workspace in database |
| ⏱️ Time Machine | Database PITR + filesystem snapshots |
| 🔀 Instant Clone | Copy-on-Write database forking |
| 🌐 One-Click Deploy | Built-in Nginx with auto SSL |
| 📊 Full Observability | VictoriaMetrics + Grafana |
| 🇨🇳 China Friendly | Global CDN + China mirrors |
Who is it for?
- Solo developers who want a powerful dev environment
- Teams that need shared development infrastructure
- AI developers using Claude Code or similar tools
- Data scientists working with PostgreSQL and Jupyter
- Learners exploring PostgreSQL and web development
How it works
Next Steps
- Install Piglet Run to get started
- Learn about the Architecture
- Explore the Storage system
2 - Architecture
System Architecture
Piglet Run is built on top of Pigsty, providing a streamlined development environment.
Components
| Component | Role | Port |
|---|---|---|
| Nginx | Reverse proxy, SSL termination | 80, 443 |
| VS Code Server | Web-based IDE | /code |
| JupyterLab | Data science notebook | /jupyter |
| PostgreSQL | Primary database | 5432 |
| JuiceFS | Distributed filesystem | - |
| VictoriaMetrics | Metrics storage | 8428 |
| Grafana | Monitoring dashboards | /ui |
Network Architecture
Storage Architecture
All development work is stored in PostgreSQL via JuiceFS:
Next Steps
3 - Storage
JuiceFS Shared Storage
Piglet Run uses JuiceFS to provide a distributed filesystem backed by PostgreSQL.
Why JuiceFS?
- POSIX Compatible: Works like a normal filesystem
- Database-Backed: Data stored in PostgreSQL
- Snapshots: Point-in-time recovery support
- Multi-User: Share workspace across sessions
How It Works
Features
| Feature | Description |
|---|---|
| Transparent | Use like local filesystem |
| Durable | Data stored in database |
| Concurrent | Multiple users/agents access |
| Snapshots | Point-in-time recovery |
Next Steps
4 - Snapshot
Time Machine
Piglet Run provides point-in-time recovery for both database and filesystem.
Database PITR
PostgreSQL’s built-in PITR (Point-in-Time Recovery) allows you to restore the database to any point in time. Managed by pgBackRest.
Filesystem Snapshots
JuiceFS snapshots preserve the state of your workspace:
Use Cases
| Scenario | Solution |
|---|---|
| AI broke code | Restore filesystem snapshot |
| Bad database migration | Use pig pb restore -t <time> |
| Experiment failed | Roll back entire environment |
| Need clean state | Restore to baseline snapshot |
Backup Management
Next Steps
- Learn about Cloning
- See Restore Task
- See Backup Task
5 - Clone
Instant Cloning
Piglet Run supports Copy-on-Write (CoW) cloning for rapid database forking.
How It Works
Copy-on-Write means:
- Zero copy at clone time
- Only changed blocks consume storage
- TB-scale databases clone in milliseconds
Use Cases
| Use Case | Benefit |
|---|---|
| Development | Clone prod for testing |
| AI Experiments | Branch for each experiment |
| Feature Branches | Database per branch |
| Training | Each learner gets own copy |
Database Cloning
Using PostgreSQL utilities:
Using pgBackRest for Cloning
Filesystem Cloning with JuiceFS
Next Steps
- See Clone Task
- Learn about Snapshots
6 - Monitoring
Full Observability
Piglet Run includes a complete monitoring stack based on VictoriaMetrics and Grafana.
Components
| Component | Role |
|---|---|
| VictoriaMetrics | Time-series database |
| Grafana | Visualization dashboards |
| node_exporter | System metrics |
| pg_exporter | PostgreSQL metrics |
Dashboards
Access Grafana at http://<ip>/ui
Available dashboards:
- Claude Code: AI agent monitoring
- PostgreSQL: Database performance
- System: Host metrics
- JuiceFS: Filesystem statistics
Metrics
Over 3000+ metrics collected:
- Database queries, connections, locks
- System CPU, memory, disk, network
- Application-specific metrics
Alerts
Configure alerts for:
- High CPU/memory usage
- Database connection limits
- Disk space warnings
- Query performance issues
Next Steps
- See Monitor Task
- Learn about Grafana Reference
7 - Security
Security Model
Piglet Run provides multiple layers of security for your development environment.
Access Control
| Layer | Mechanism |
|---|---|
| Network | Firewall, VPN support |
| Web | Nginx authentication |
| Database | PostgreSQL roles |
| Filesystem | Unix permissions |
Authentication
Default authentication methods:
- VS Code: Password or token
- Jupyter: Token-based
- Grafana: Username/password
- PostgreSQL: Role-based access
Encryption
| Type | Support |
|---|---|
| In Transit | SSL/TLS |
| At Rest | Database encryption |
| Backup | Encrypted backups |
Best Practices
- Change default passwords immediately
- Enable SSL for all services
- Restrict network access
- Regular security updates