Skip to content

Commit ae158b4

Browse files
committed
docs: update resume.tex and README.md with Go Serverless Visitor Tracker
1 parent 3261170 commit ae158b4

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ Originally designed as a zero-ingress VM-based setup (using Cloudflare tunnels a
1616
## 🏗️ Architecture Design
1717

1818
```
19-
[USER] ─── (HTTPS) ───► [CLOUD RUN INGRESS] ───► [UNPRIVILEGED NGINX CONTAINER]
19+
[USER] ─── (HTTPS) ───► [PORTFOLIO FRONTEND] ───► [UNPRIVILEGED NGINX]
2020
(index.html & resume.pdf)
21-
22-
│ (Deploy)
21+
22+
(Fetch API / CORS)
23+
24+
[FIRESTORE DB] ◄─── (atomic sdk) ───► [PORTFOLIO TRACKER API (Go)]
25+
(us-central1, 128Mi, CPU Idle)
26+
27+
│ (Deploy)
2328
[GITHUB ACTIONS] ─── (OIDC/WIF) ───► [GCP ARTIFACT REGISTRY] ──────┘
2429
```
2530

@@ -31,37 +36,46 @@ Originally designed as a zero-ingress VM-based setup (using Cloudflare tunnels a
3136
We eliminated all long-lived Google Cloud Service Account JSON keys from GitHub Secrets. The deployment pipeline authenticates securely using short-lived OpenID Connect (OIDC) tokens through GCP Workload Identity Federation, drastically reducing the security risk profile.
3237

3338
### 2. Fully Managed Serverless Hosting
34-
Migrated from a self-managed `e2-micro` VM to **Google Cloud Run**. The application scales down to zero instances when idle, removing host OS maintenance, security patching overhead, and daemon service monitoring.
39+
Migrated from a self-managed `e2-micro` VM to **Google Cloud Run**. Both the static web app and the visitor tracker microservice are hosted on Cloud Run. The services scale down to zero instances when idle, removing host OS maintenance and daemon service monitoring.
3540

36-
### 3. State-Locked Declarative IaC
37-
The infrastructure (Cloud Run service and public IAM bindings) is defined declaratively using **Terraform** with state locked in a **GCS Remote Backend**. The pipeline automatically applies modifications on push to the `main` branch.
41+
### 3. Serverless Go & Firestore Visitor Analytics
42+
Implemented a custom visitor and active session tracker API in **Go (Golang)**. It connects to **Google Cloud Firestore (Native Mode)** to record live session metadata and atomically increment unique site views.
43+
- **Resource Footprint Optimization:** The Go microservice runs within a resource-restricted container limited to `128Mi` memory, utilizing `cpu_idle = true` to throttle CPU during inactivity, reducing idle container costs to zero.
44+
- **Session Lifecycle & Bloat Prevention:** The API writes ephemeral active session documents and executes auto-eviction queries to delete sessions older than 5 minutes, preventing Firestore database bloat.
45+
- **Cache Control & CORS:** Sends strict no-cache headers to ensure metrics remain fresh, and includes proper CORS configuration for seamless client integration.
3846

39-
### 4. LaTeX Resume Automation with Caching
47+
### 4. State-Locked Declarative IaC
48+
The infrastructure (Cloud Run services and public IAM invoker bindings) is defined declaratively using **Terraform** with state locked in a **GCS Remote Backend**. The pipeline automatically applies modifications on push to the `main` branch.
49+
50+
### 5. LaTeX Resume Automation with Caching
4051
The pipeline compiles `resume.tex` to `resume.pdf` during the workflow run. To optimize deployment speed, `actions/cache` is used to cache `resume.pdf` based on the hash of `resume.tex`.
41-
* **Deployment Optimization:** If `resume.tex` has not changed, the LaTeX setup and compilation step are skipped completely, saving ~1.5 minutes per run.
52+
- **Deployment Optimization:** If `resume.tex` has not changed, the LaTeX setup and compilation step are skipped completely, saving ~1.5 minutes per run.
4253

43-
### 5. Runtime Hardening
44-
The portfolio is served using `nginxinc/nginx-unprivileged:1.27.0-alpine-slim` running on non-root UID 101, safeguarding the environment against container-escape vulnerabilities.
54+
### 6. Runtime Hardening
55+
The portfolio frontend is served using `nginxinc/nginx-unprivileged:1.27.0-alpine-slim` running on non-root UID 101, safeguarding the environment against container-escape vulnerabilities.
4556

4657
---
4758

4859
## 📂 Repository Structure
4960

50-
* `main.tf` : Terraform configuration for the Cloud Run v2 service and public access bindings (`roles/run.invoker` for `allUsers`).
61+
* `main.tf` : Terraform configuration for both the frontend and tracker API Cloud Run services, including public access bindings (`roles/run.invoker` for `allUsers`).
5162
* `variables.tf` : Declarative input variables for container tags.
5263
* `Dockerfile` : Configured to optionally copy `resume.pdf` using wildcards to protect local/dev builds if the PDF hasn't been compiled locally.
53-
* `index.html` : The main web page detailing the 4-phase architectural evolution.
64+
* `index.html` : The main web page detailing the 4-phase architectural evolution and displaying live session stats in the footer.
5465
* `resume.tex` : The LaTeX source file for the professional resume.
55-
* `.github/workflows/deploy.yml` : Secure CI/CD workflow utilizing OIDC auth, LaTeX caching, Docker builds, and Terraform apply.
66+
* `tracker-api/` : Go API microservice codebase.
67+
- `main.go` : The Go listener with Firestore SDK integrations, CORS, and cleanup routines.
68+
- `Dockerfile` : Multi-stage build (`golang:alpine` to `alpine:latest`) to produce a highly-minimized execution image.
69+
* `.github/workflows/deploy.yml` : Secure CI/CD workflow utilizing OIDC auth, LaTeX caching, Docker builds for both containers, and Terraform apply.
5670

5771
---
5872

5973
## ⚙️ Automated Deployment Flow
6074

6175
1. **Change Detection & Cache Check:** GitHub Actions checks if `resume.tex` has changed. If unchanged, it restores `resume.pdf` from the cache.
6276
2. **LaTeX Compilation (Conditional):** If the cache is missed, it compiles `resume.tex` into `resume.pdf`.
63-
3. **Hardened Containerization:** The runner builds the unprivileged Nginx image, copying both `index.html` and `resume.pdf` (if present) into the image, and pushes it to GCP Artifact Registry using OIDC authentication.
64-
4. **Declarative Deploy:** Runs `terraform init` and `terraform apply` using the new image tag, deploying the service and ensuring public web ingress access.
77+
3. **Hardened Containerization:** The runner builds the unprivileged Nginx frontend image and the compiled Go tracker API image, pushing both to GCP Artifact Registry using OIDC authentication.
78+
4. **Declarative Deploy:** Runs `terraform init` and `terraform apply` using the new image tags, deploying/updating both Cloud Run services and ensuring public web ingress access.
6579

6680
---
6781

resume.tex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ \section{Technical Projects}
9494
\item Hardened application deployments by using rootless, unprivileged Docker containers and enforcing E2E strict HTTPS, DNSSEC, and HSTS policies at the Cloudflare Edge to minimize the system attack surface.
9595
\end{itemize}
9696

97+
\textbf{Serverless Visitor Tracker \& Session Analytics API} \hfill \href{https://sreeramkr.com}{sreeramkr.com}
98+
\begin{itemize}[itemsep=3pt]
99+
\item Developed a lightweight, low-latency API in \textbf{Go (Golang)} to track live website sessions and unique page views, running on an optimized \textbf{Google Cloud Run} container.
100+
\item Integrated \textbf{Google Cloud Firestore (Native Mode)} for transactional state storage, implementing atomic increment operations and concurrent query aggregations.
101+
\item Designed automated database bloat prevention to clean up expired sessions and enforced strict HTTP Cache-Control headers to deliver real-time metrics dynamically.
102+
\end{itemize}
103+
97104
% --- EDUCATION ---
98105
\section{Education}
99106

0 commit comments

Comments
 (0)