YPYM Company - Complete Architecture Documentation
🏗️ System Architecture Overview
This document provides a comprehensive guide to the YPYM Company platform architecture, covering the frontend layer, backend services, and web infrastructure.Folder Structure Project
C:\Users\rochm\Documents\ypym-sandbox\ypym-company>Architecture Diagram
🎨 Frontend Architecture
Technology Stack
| Component | Technology | Version | Purpose |
|---|---|---|---|
| Framework | Astro | 4.15.0 | Static site generation & fast page loads |
| Styling | Tailwind CSS | 3.4.0 | Utility-first CSS framework |
| Language | TypeScript | 5.5.0 | Type-safe JavaScript development |
| Build Tool | TypeScript Checker | @astrojs/check 0.9.0 | Pre-build type validation |
| Sitemap | @astrojs/sitemap | 3.7.0 | SEO-friendly sitemap generation |
| Node.js | Any LTS version | Recommended 18+ | Runtime environment |
Directory Structure
Build Process
Key Frontend Features
1. Image Optimization Engine
- Service: Astro Sharp Integration
- Formats: WebP, PNG, JPEG
- Remote Domains:
ghost.ypym.app(Production Ghost CMS)localhost:2368(Development Ghost CMS)images.unsplash.com(Stock images)
- Optimization: Automatic srcset generation, lazy loading
- Input Limit: 192 MP (no pixel limit)
2. TypeScript Configuration
3. Tailwind CSS Design System
- Color Palette: Anthropic-inspired (sand, beige, accents)
- Sand Colors: 50-900 scale
- Accent Colors: Orange (#d97757), Black, White
- Responsive: Mobile-first design
- Customizations: Extended theme variables
4. Site Configuration
Development Commands
👻 Backend Architecture
Ghost CMS Overview
Ghost is a modern, open-source headless CMS designed for content management with API-first architecture.| Feature | Details |
|---|---|
| Version | 5-alpine (lightweight Docker image) |
| Port | 2368 |
| Container Name | tessera-ghost |
| Mode | Headless (API-only, no default frontend) |
| Database | MySQL 8.0 |
| Environment | Docker container (production-ready) |
Ghost Architecture Diagram
Ghost API Endpoints
Content API (Public)
Used by Astro frontend for reading published content:Admin API (Authenticated)
Available athttp://localhost:2368/ghost/api/admin/ for authenticated requests.
Ghost Environment Configuration
Ghost Docker Configuration
Ghost Frontend Integration
File: frontend/src/lib/ghost.tsContent Types Supported
- Posts - Blog articles with tags and authors
- Pages - Static pages (About, Services, etc.)
- Authors - Team member profiles
- Tags - Content categorization
- Settings - Site-wide configuration
🗄️ Database Layer - MySQL
MySQL Configuration
| Setting | Value | Purpose |
|---|---|---|
| Version | 8.0 | Latest stable release |
| Port | 3306 | Standard MySQL port |
| Container | tessera-mysql | Docker container identifier |
| Auth Plugin | mysql_native_password | Password authentication |
Database Schema
MySQL Health Check
Data Persistence
Backup & Recovery
Strategy: Volume-based backups using Docker volumes🐳 Docker & Web Services
Docker Orchestration
File: docker/docker-compose.yml Docker Compose manages two primary services interconnected through a custom bridge network.Service Architecture
Service Dependencies
Ghost depends on MySQL being healthy before starting:- MySQL container starts first
- Successfully initializes from
init.sql - Passes 5 consecutive health checks
- Only then Ghost container starts
Network Configuration
Environment Variables & Secrets
Critical: Store in.env file (not in version control)
MYSQL_ROOT_PASSWORD=rootpasswordMYSQL_PASSWORD=ghostpassword
Starting Services
Container Health Status
🔄 Data Flow & Integration
Request Flow: User Accessing Website
Content Update Workflow
API Integration Layer
File: frontend/src/lib/ghost.ts🚀 Deployment Architecture
Development Environment
Production Environment
Build & Deployment Pipeline
Production Checklist
- Set proper Ghost URL:
https://ghost.ypym.app - Configure MySQL backups & replication
- Enable HTTPS/TLS certificates
- Set environment variables in
.env - Configure content image CDN
- Set up monitoring & alerting
- Configure Ghost backup plugins
- Test disaster recovery procedures
📊 Performance Metrics
Frontend Performance
| Metric | Target | Current |
|---|---|---|
| Lighthouse Score | 100 | ~98-100 |
| Page Load | < 1s | ~0.3-0.7s |
| First Contentful Paint | < 2.5s | ~0.5s |
| Largest Contentful Paint | < 4s | ~1.2s |
| Cumulative Layout Shift | < 0.1 | ~0.01 |
Optimization Features
- Static Generation: Pre-rendered HTML (zero runtime overhead)
- Image Optimization: Automatic WebP generation, lazy loading
- Code Splitting: Per-route JavaScript bundles
- CSS Purging: Only ship used styles (~15KB gzipped)
- Minification: Automatic HTML, CSS, JS minification
🔐 Security Considerations
Frontend Security
- No backend exposure: Static files only
- CSP Headers: Configure in hosting provider
- CORS: Not applicable (static site)
- Image domains whitelisted: Only approved sources
Backend Security
- Ghost Role-Based Access: Owner → Admin → Editor → Author
- API Key Separation: Content API key ≠ Admin API key
- Database Credentials: Stored in environment variables (
.env) - Network Isolation: MySQL only accessible via Ghost (Docker network)
Secrets Management
🛠️ Troubleshooting Guide
Common Issues
Ghost Cannot Connect to MySQL
Build Fails with Image Optimization
Content Not Appearing on Frontend
📚 Additional Resources
- Astro Documentation: https://docs.astro.build
- Ghost Content API: https://ghost.org/docs/api/content/
- Tailwind CSS: https://tailwindcss.com/docs
- Docker Documentation: https://docs.docker.com
- MySQL 8.0: https://dev.mysql.com/doc/refman/8.0/en/
📝 Summary
The YPYM Company platform is built on a modern, scalable architecture:- Frontend: Static-first Astro SSG with optimized images and component library
- Backend: Headless Ghost CMS for content management without vendor lock-in
- Database: MySQL 8.0 for robust relational data storage
- Infrastructure: Docker orchestration for reproducible deployments
- Performance: Sub-1 second page loads with 100 Lighthouse scores

