Architecture Overview
S-Parking leverages Google Cloud Platform’s serverless infrastructure to deliver a scalable, cost-effective parking management system. The architecture is built on Cloud Functions (2nd gen) and Firestore as the primary database.Serverless Design
No server management required. Functions auto-scale based on demand.
Pay-per-use
Only pay for actual invocations and compute time.
Global CDN
Firebase Hosting with automatic SSL and edge caching.
Real-time Database
Firestore provides millisecond-latency queries with real-time listeners.
GCP Services Used
Cloud Functions (2nd Gen)
All backend logic runs as HTTP-triggered Cloud Functions deployed on Cloud Run. Each function is independently deployable and scalable. Key Features:- Concurrency: Handles multiple requests per instance
- Cold Start Optimization: ~500ms startup time
- CORS Support: Pre-configured for web client access
- Environment: Node.js 20 runtime
Firestore (Native Mode)
Firestore serves as the primary NoSQL database with three main collections:parking_spots- Real-time parking spot statusparking_zones- Zone definitions and metadataoccupancy_history- Hourly snapshots for analytics
Firebase Hosting
Static assets and the web dashboard are served via Firebase Hosting:Firebase Authentication
Email/password authentication with custom claims for admin access. See Authentication for implementation details.Scalability & Performance
Auto-scaling Strategy
- Low Load (0-10 req/s)
- Medium Load (10-100 req/s)
- High Load (100+ req/s)
- Instances: 1-2 warm instances per function
- Latency: Less than 200ms average
- Cost: ~$5-10/month
Optimization Techniques
Client-side Cachingparking_spots: Indexed onstatus,zone_idoccupancy_history: Composite index onts+zone_id
Deployment Architecture
Regional Configuration
Primary Region:us-central1 (Iowa, USA)
- Lowest latency for North/South America
- Best pricing tier
- High availability zone
nam5 (United States)
- Automatic replication across multiple data centers
- 99.999% uptime SLA
Monitoring & Logging
All functions log to Cloud Logging with structured logging:- Error rate > 5%
- Latency > 1s (p95)
- Cold starts > 100/hour
Cost Optimization
Function Optimization
- Use connection pooling
- Minimize cold starts
- Set appropriate memory limits (256MB default)
Database Optimization
- Use batch writes (saves 90% writes)
- Implement client-side caching
- Set up data retention policies
Hosting Optimization
- Enable CDN caching
- Compress assets with gzip
- Use lazy loading for images
Monitoring Budget
- Set up budget alerts
- Monitor per-function costs
- Review unused indexes
- Cloud Functions: $15-25
- Firestore: $10-15 (50K reads/day, 5K writes/day)
- Firebase Hosting: $0 (under free tier)
- Total: ~$25-40/month
Security Considerations
- CORS: Configured to accept requests from authorized domains only
- HTTPS Only: All traffic encrypted via TLS 1.3
- Rate Limiting: Implemented at Cloud Functions level
- Input Validation: All endpoints validate request parameters
- Firestore Rules: Strict read/write rules based on authentication