Skip to content

Commit 0cc7d51

Browse files
Phase 3: Professional UI, Kubernetes, observability, notifications, CI/CD
Co-authored-by: CodersAcademy006 <104912634+CodersAcademy006@users.noreply.github.com>
1 parent 3688b91 commit 0cc7d51

26 files changed

+6803
-562
lines changed

.github/workflows/ci-cd.yml

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# IntelliWeather CI/CD Pipeline
2+
# Runs tests, builds Docker image, and optionally deploys to Kubernetes
3+
4+
name: CI/CD Pipeline
5+
6+
on:
7+
push:
8+
branches: [main, develop]
9+
tags: ['v*']
10+
pull_request:
11+
branches: [main]
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
# ==================== LINT & TEST ====================
19+
test:
20+
name: Test
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.12'
31+
cache: 'pip'
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install -r requirements.txt
37+
pip install pytest pytest-cov pytest-asyncio flake8 black mypy
38+
39+
- name: Lint with flake8
40+
run: |
41+
# Stop the build if there are Python syntax errors or undefined names
42+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
43+
# Exit-zero treats all errors as warnings
44+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
45+
continue-on-error: true
46+
47+
- name: Check formatting with black
48+
run: black --check --diff . || true
49+
continue-on-error: true
50+
51+
- name: Type check with mypy
52+
run: mypy --ignore-missing-imports . || true
53+
continue-on-error: true
54+
55+
- name: Run tests
56+
run: |
57+
pytest tests/ -v --cov=. --cov-report=xml --cov-report=term-missing
58+
env:
59+
DEBUG: "true"
60+
61+
- name: Upload coverage reports
62+
uses: codecov/codecov-action@v3
63+
with:
64+
files: ./coverage.xml
65+
fail_ci_if_error: false
66+
67+
# ==================== BUILD DOCKER IMAGE ====================
68+
build:
69+
name: Build
70+
runs-on: ubuntu-latest
71+
needs: test
72+
permissions:
73+
contents: read
74+
packages: write
75+
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
80+
- name: Set up Docker Buildx
81+
uses: docker/setup-buildx-action@v3
82+
83+
- name: Log in to Container Registry
84+
if: github.event_name != 'pull_request'
85+
uses: docker/login-action@v3
86+
with:
87+
registry: ${{ env.REGISTRY }}
88+
username: ${{ github.actor }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Extract metadata
92+
id: meta
93+
uses: docker/metadata-action@v5
94+
with:
95+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
96+
tags: |
97+
type=ref,event=branch
98+
type=ref,event=pr
99+
type=semver,pattern={{version}}
100+
type=semver,pattern={{major}}.{{minor}}
101+
type=sha,prefix=
102+
103+
- name: Build and push Docker image
104+
uses: docker/build-push-action@v5
105+
with:
106+
context: .
107+
push: ${{ github.event_name != 'pull_request' }}
108+
tags: ${{ steps.meta.outputs.tags }}
109+
labels: ${{ steps.meta.outputs.labels }}
110+
cache-from: type=gha
111+
cache-to: type=gha,mode=max
112+
platforms: linux/amd64,linux/arm64
113+
114+
# ==================== SECURITY SCAN ====================
115+
security:
116+
name: Security Scan
117+
runs-on: ubuntu-latest
118+
needs: build
119+
if: github.event_name != 'pull_request'
120+
121+
steps:
122+
- name: Checkout code
123+
uses: actions/checkout@v4
124+
125+
- name: Run Trivy vulnerability scanner
126+
uses: aquasecurity/trivy-action@master
127+
with:
128+
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
129+
format: 'sarif'
130+
output: 'trivy-results.sarif'
131+
continue-on-error: true
132+
133+
- name: Upload Trivy scan results
134+
uses: github/codeql-action/upload-sarif@v2
135+
with:
136+
sarif_file: 'trivy-results.sarif'
137+
continue-on-error: true
138+
139+
# ==================== DEPLOY TO STAGING ====================
140+
deploy-staging:
141+
name: Deploy to Staging
142+
runs-on: ubuntu-latest
143+
needs: [build, security]
144+
if: github.ref == 'refs/heads/develop'
145+
environment: staging
146+
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v4
150+
151+
- name: Set up kubectl
152+
uses: azure/setup-kubectl@v3
153+
154+
- name: Configure kubectl
155+
run: |
156+
mkdir -p ~/.kube
157+
echo "${{ secrets.KUBE_CONFIG_STAGING }}" | base64 -d > ~/.kube/config
158+
if: ${{ secrets.KUBE_CONFIG_STAGING != '' }}
159+
160+
- name: Deploy to staging
161+
run: |
162+
if [ -f ~/.kube/config ]; then
163+
kubectl set image deployment/intelliweather \
164+
intelliweather=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
165+
--namespace=staging || echo "Kubectl deployment skipped (no cluster configured)"
166+
else
167+
echo "Staging deployment skipped (no KUBE_CONFIG_STAGING secret)"
168+
fi
169+
170+
# ==================== DEPLOY TO PRODUCTION ====================
171+
deploy-production:
172+
name: Deploy to Production
173+
runs-on: ubuntu-latest
174+
needs: [build, security]
175+
if: startsWith(github.ref, 'refs/tags/v')
176+
environment: production
177+
178+
steps:
179+
- name: Checkout code
180+
uses: actions/checkout@v4
181+
182+
- name: Set up kubectl
183+
uses: azure/setup-kubectl@v3
184+
185+
- name: Configure kubectl
186+
run: |
187+
mkdir -p ~/.kube
188+
echo "${{ secrets.KUBE_CONFIG_PRODUCTION }}" | base64 -d > ~/.kube/config
189+
if: ${{ secrets.KUBE_CONFIG_PRODUCTION != '' }}
190+
191+
- name: Deploy to production
192+
run: |
193+
if [ -f ~/.kube/config ]; then
194+
# Extract version from tag
195+
VERSION=${GITHUB_REF#refs/tags/}
196+
197+
# Deploy using Helm
198+
helm upgrade --install intelliweather ./helm/intelliweather \
199+
--namespace=production \
200+
--set image.tag=$VERSION \
201+
--wait --timeout=5m || echo "Helm deployment skipped"
202+
else
203+
echo "Production deployment skipped (no KUBE_CONFIG_PRODUCTION secret)"
204+
fi
205+
206+
# ==================== NOTIFY ====================
207+
notify:
208+
name: Notify
209+
runs-on: ubuntu-latest
210+
needs: [test, build]
211+
if: always()
212+
213+
steps:
214+
- name: Notify on success
215+
if: needs.test.result == 'success' && needs.build.result == 'success'
216+
run: |
217+
echo "✅ Pipeline succeeded!"
218+
echo "Tests: ${{ needs.test.result }}"
219+
echo "Build: ${{ needs.build.result }}"
220+
221+
- name: Notify on failure
222+
if: needs.test.result == 'failure' || needs.build.result == 'failure'
223+
run: |
224+
echo "❌ Pipeline failed!"
225+
echo "Tests: ${{ needs.test.result }}"
226+
echo "Build: ${{ needs.build.result }}"

CHANGELOG.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,93 @@ All notable changes to IntelliWeather API will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.0] - 2024-01-16
9+
10+
### Added - Phase 3 Features
11+
12+
#### Professional UI Redesign
13+
- **New Header**: Fixed navigation bar with logo, nav links, theme toggle, and auth buttons
14+
- **New Footer**: Full footer with branding, social links, product/resource/company columns
15+
- **Dark/Light Mode**: System-aware theme with smooth transitions and localStorage persistence
16+
- **Advanced Animations**: Hardware-accelerated animations using CSS transforms and opacity
17+
- **Motion Controller**: JavaScript animation sequencing system with cancellation support
18+
- **Skeleton Loaders**: Shimmer loading states during data fetches
19+
- **Reduced Motion Support**: Respects `prefers-reduced-motion` system preference
20+
21+
#### Animation System
22+
- `static/css/animations.css` - Comprehensive animation library
23+
- `static/css/theme.css` - Theme system with CSS custom properties
24+
- `static/js/motion.js` - MotionController for coordinated animations
25+
- `static/js/theme.js` - ThemeManager for dark/light mode
26+
- `static/js/search.js` - Enhanced search with autosuggest and keyboard navigation
27+
- Design tokens for consistent timing (durations, easings, staggers)
28+
29+
#### Kubernetes Deployment
30+
- `k8s/deployment.yaml` - Deployment, Service, Ingress, HPA, PVC, PDB manifests
31+
- `k8s/secrets-template.yaml` - Secrets template (never commit actual secrets!)
32+
- `k8s/local/local-setup.sh` - Script for local kind/minikube development
33+
- Resource limits and requests for production stability
34+
- Health probes (liveness, readiness)
35+
- HorizontalPodAutoscaler for auto-scaling
36+
37+
#### Helm Chart
38+
- `helm/intelliweather/Chart.yaml` - Chart metadata
39+
- `helm/intelliweather/values.yaml` - Configurable values
40+
- Redis and PostgreSQL as optional dependencies
41+
- Support for custom annotations, resources, and environment variables
42+
43+
#### Observability Stack
44+
- `monitoring/prometheus.yml` - Prometheus scrape configuration
45+
- `monitoring/alert_rules.yml` - Alertmanager rules (high error rate, latency, cache ratio)
46+
- `monitoring/grafana-dashboard.json` - Pre-built Grafana dashboard
47+
- Prometheus metrics exposed at `/metrics/prometheus`
48+
- Metrics: request rate, latency histogram, cache hit ratio, active sessions
49+
50+
#### Notifications Module
51+
- `notifications/__init__.py` - Pluggable notification system
52+
- **EmailBackend**: SMTP and SendGrid support
53+
- **SMSBackend**: Twilio integration with mock fallback
54+
- **WebPushBackend**: Web push notifications (stub)
55+
- **InAppBackend**: In-app notifications stored in memory/DB
56+
- Exponential backoff retry for failed deliveries
57+
- Notification templates for weather alerts, account events
58+
59+
#### CI/CD Pipeline
60+
- `.github/workflows/ci-cd.yml` - GitHub Actions workflow
61+
- Jobs: lint, test, build Docker image, security scan, deploy
62+
- Multi-platform builds (amd64, arm64)
63+
- Conditional deployment to staging/production
64+
- Code coverage upload to Codecov
65+
66+
#### Documentation
67+
- `docs/DEPLOYMENT.md` - Comprehensive deployment guide
68+
- `docs/CDN.md` - Cloudflare and Fastly integration guides
69+
- Edge caching examples with Workers/Compute@Edge
70+
- Cache header configuration
71+
72+
### Changed
73+
- Version bump to 3.0.0
74+
- Updated `config.py` with Phase 3 feature flags
75+
- Enhanced `requirements.txt` with observability dependencies
76+
- Professional UI design comparable to AccuWeather
77+
78+
### Configuration
79+
New environment variables:
80+
- `FEATURE_NOTIFICATIONS` - Enable notifications (default: true)
81+
- `SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD` - SMTP settings
82+
- `SENDGRID_API_KEY` - SendGrid API key
83+
- `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN`, `TWILIO_PHONE_NUMBER` - Twilio SMS
84+
- `VAPID_PRIVATE_KEY`, `VAPID_PUBLIC_KEY` - Web push keys
85+
- `FEATURE_BACKGROUND_JOBS` - Enable job queue (default: true)
86+
- `JOB_QUEUE_BACKEND` - Queue backend (memory/redis/rq/celery)
87+
- `POSTGRES_URL` - PostgreSQL connection URL
88+
- `PROMETHEUS_ENABLED` - Enable Prometheus metrics
89+
- `FEATURE_ANALYTICS`, `FEATURE_REFERRALS`, `FEATURE_SHAREABLE_LINKS` - Growth features
90+
- `FREE_TIER_REQUESTS_PER_DAY`, `PRO_TIER_REQUESTS_PER_DAY` - Access tiers
91+
- `FEATURE_ANIMATIONS`, `REDUCED_MOTION_DEFAULT` - Animation settings
92+
93+
---
94+
895
## [2.0.0] - 2024-01-15
996

1097
### Added - Phase 2 Features

0 commit comments

Comments
 (0)