Architecture of This Website
| Created: | |
| Updated: | |
| Written by: | AI |
AI-assisted content. A human was involved, but the AI did most of the heavy lifting.
Understanding the architecture of a system is crucial for maintenance, scaling, and onboarding new contributors. In this post, I’ll provide a comprehensive overview of how vikan.cloud is architected, from content creation to deployment.
Architecture Overview
vikan.cloud follows a modern serverless architecture with the following key components:
┌─────────────────┐
│ Developer │
│ (Cursor IDE) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ GitHub Repo │
│ (Version │
│ Control) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ GitHub Actions │
│ (CI/CD) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Cloudflare │
│ Workers │
└────────┬────────┘
│
├──────────────┐
▼ ▼
┌──────────────┐ ┌──────────────┐
│ Static │ │ D1 │
│ Assets │ │ Database │
└──────────────┘ └──────────────┘
Component Breakdown
1. Content Layer
Location: src/content/
The content layer uses Astro’s Content Collections feature:
- Blog Posts: Markdown files in
src/content/articles/ - Book Reviews: Markdown files in
src/content/books/ - Schema Validation: Zod schemas ensure content quality
- Type Safety: Full TypeScript support for content
Benefits:
- Version-controlled content
- Type-safe content access
- Easy content management
- No database needed for content
2. Application Layer
Framework: Astro 5.16.2
Astro handles:
- Static Site Generation (SSG): Pre-renders pages at build time
- Server-Side Rendering (SSR): Dynamic pages rendered on-demand
- Component Islands: Minimal JavaScript sent to client
- Content Collections: Type-safe content management
Key Files:
src/pages/: Route definitionssrc/components/: Reusable componentssrc/layouts/: Page layoutssrc/middleware.ts: Security headerssrc/styles/global.css: Global styles and CSS variablestailwind.config.mjs: Tailwind CSS configuration
Styling: Tailwind CSS with custom CSS variables for theming
3. API Layer
Location: src/pages/api/
Serverless API endpoints:
/api/visitor-track: Track anonymized visitor IPs/api/visitor-stats: Retrieve visitor statistics/api/ping: Ping IP addresses with logging/api/ping-stats: Retrieve ping statistics
Characteristics:
- Edge functions (Cloudflare Workers)
- Low latency globally
- Serverless scaling
- D1 database integration
4. Database Layer
Technology: Cloudflare D1 (Serverless SQLite)
Tables:
visitor_counter: Anonymized visitor trackingping: Network connectivity test results (ping logging)
Why D1?:
- Serverless: No database server management
- Edge-ready: Low latency access
- SQLite: Familiar SQL interface
- Free tier: 5GB storage, 5M reads/month
5. Deployment Layer
Platform: Cloudflare Workers
Features:
- Global edge deployment (300+ locations)
- Automatic scaling
- Built-in DDoS protection
- SSL/TLS included
- Serverless architecture
Configuration:
wrangler.json: Cloudflare Workers configastro.config.mjs: Astro adapter configuration
6. CI/CD Pipeline
Platform: GitHub Actions
Workflow (.github/workflows/ci.yml):
- Checkout: Clone repository
- Setup Node.js: Install Node.js 20
- Install Dependencies:
npm ci - Security Scanning:
npm audit: Dependency vulnerabilities- Semgrep: Code security patterns
- ESLint: Code quality and security
- Trivy: Comprehensive vulnerability scanning
- Type Checking:
tsc --noEmit - Content Linting: Validate content files
- Build:
npm run build - SBOM Generation: Software Bill of Materials
- Dry Run: Test Cloudflare deployment
Benefits:
- Automated testing
- Security scanning
- Quality assurance
- Deployment validation
Data Flow
Blog Post Request Flow
User Request
│
▼
Cloudflare Workers (Edge)
│
├─► Static Page? ──► Serve from CDN (Fast!)
│
└─► Dynamic Page? ──► Astro SSR
│
├─► Fetch Content (Content Collections)
├─► Query D1 (if needed)
└─► Render HTML
│
└─► Return to User
API Request Flow
API Request
│
▼
Cloudflare Workers (Edge)
│
▼
Astro API Route
│
├─► Validate Request
├─► Query/Update D1 Database
└─► Return JSON Response
Security Architecture
Security Headers
Implemented in src/middleware.ts:
- Content-Security-Policy (CSP): Prevents XSS attacks
- HTTP Strict Transport Security (HSTS): Enforces HTTPS
- X-Frame-Options: Prevents clickjacking
- X-Content-Type-Options: Prevents MIME sniffing
- Referrer-Policy: Controls referrer information
Security Scanning
Automated in CI/CD:
- npm audit: Dependency vulnerabilities
- Semgrep: Code security patterns
- ESLint security plugin: Security linting
- Trivy: Comprehensive scanning
Privacy
- IP Anonymization: Visitor IPs truncated (last octet removed)
- No Tracking Scripts: No third-party analytics
- Minimal Data Collection: Only necessary data stored
Performance Optimizations
Static Generation
- Most pages pre-rendered at build time
- Zero JavaScript for static pages
- Fast initial page loads
Edge Deployment
- Content served from nearest edge location
- Sub-50ms response times globally
- Automatic caching
Asset Optimization
- Font preloading
- Optimized images
- Minimal CSS/JS
- Tailwind CSS: Utility-first CSS with purging for minimal bundle size
Development Workflow
Local Development
- Clone Repository:
git clone - Install Dependencies:
npm install - Start Dev Server:
npm run dev - Make Changes: Edit files in Cursor IDE
- Preview: Hot reload in browser
Deployment Workflow
- Create Branch:
git checkout -b feature/... - Make Changes: Edit code
- Commit:
git commit -m "..." - Push:
git push origin feature/... - Create PR: GitHub Pull Request
- CI Runs: Automated tests and checks
- Merge: After approval
- Deploy: Manual deployment to Cloudflare
Scalability Considerations
Current Architecture
- Content: Unlimited (static files)
- API Requests: Serverless auto-scaling
- Database: 5GB storage, 5M reads/month (free tier)
- Bandwidth: Unlimited on Cloudflare Workers
Future Scaling
If needed:
- Upgrade D1 database tier
- Add Cloudflare R2 for large assets
- Implement caching strategies
- Add CDN for static assets
Monitoring and Observability
Current Monitoring
- Cloudflare Analytics: Basic traffic metrics
- D1 Database: Query performance
- GitHub Actions: CI/CD status
Future Enhancements
- Application performance monitoring
- Error tracking
- User analytics (privacy-preserving)
- Performance metrics
Conclusion
vikan.cloud’s architecture prioritizes:
- Performance: Static generation + edge deployment
- Security: Multiple layers of security
- Developer Experience: Modern tooling and type safety
- Cost Efficiency: Serverless architecture
- Maintainability: Clear structure and documentation
This architecture provides a solid foundation for a personal blog while remaining simple enough to maintain and extend.
Updates & Resources
Recent Updates (December 2025)
Tailwind CSS Integration: The project migrated to Tailwind CSS for styling with a utility-first approach, reduced custom CSS (over 400 lines removed), better maintainability, and seamless theme integration.
Database Improvements: Fixed database storage implementation for ping logging, improved error logging for database operations, and verified visitor tracking.