Skip to main content
Case Study

CodeForge

CodeForge is the platform behind this portfolio: an Astro site and a protected admin dashboard backed by a Fastify API, with an evidence-driven AI documentation workflow grounded in each project's public GitHub repository. The system itself is the case study: every claim on this page is backed by code, tests or a production measurement.

Role
Full-Stack Engineer
Timeline
May 2026 – Present
Stack
Astro · Tailwind CSS · Fastify · TypeScript · MongoDB · Vercel · Render

01. The Problem

A personal portfolio has to solve two separate engineering problems: presenting technical work clearly and maintaining the content behind it. Hard-coded project pages make every update a code change and couple content management too tightly to the frontend.

At the same time, a GitHub repository alone rarely gives a technical reviewer enough context to understand a project's architecture, decisions, security controls and testing strategy quickly. And a portfolio that only claims engineering quality, without evidence, is easy to dismiss.

02. Goals

  • Separate content from presentation: projects and experiences are managed from an admin dashboard and stored in a database, not in the frontend source.
  • Provide technical depth: every project page exposes architecture, implementation decisions and engineering context.
  • Automate documentation: generate project documentation from repository evidence instead of rewriting it by hand.
  • Treat production concerns as features: authentication, validation, testing, CI, deployment and observability are part of the scope.
  • Prove it with numbers: quality is measured (coverage gates, E2E results, production Lighthouse) and published, not asserted.

03. Solution Overview

CodeForge uses a split frontend/backend architecture. The Astro frontend, deployed on Vercel, renders the public site and the admin dashboard. A Fastify API on Render owns portfolio data, authentication, business logic, persistence in MongoDB Atlas and the AI-assisted documentation.

ArchitectureRoutes → Controllers → Services → Repositories
SecurityJWT Cookie · CSRF Guard · Hash-based CSP · Rate Limiting
TestingVitest · Astro Container API · Playwright · axe-core
DeliveryGitHub Actions · Vercel ISR · Render · MongoDB Atlas

04. Architecture

The backend follows a Routes → Controllers → Services → Repositories architecture to keep HTTP concerns, business logic and persistence separate. The Fastify application is built separately from the server bootstrap, so the test suite imports the fully configured app and exercises it with inject() without opening a network port.

05. Key Design Decisions

Frontend: Astro without a UI framework runtime

Decision: Render every page with Astro and implement interactivity (admin dashboard, project filter, particle background) as small TypeScript modules bundled by Astro.

Reasoning: The site is content-first, so shipping a component framework would add JavaScript without adding value. Bundled modules are unit-testable and let Astro hash every script, which is what makes a CSP without 'unsafe-inline' possible. An unused React integration was removed for the same reason.

Backend: Controller → Service → Repository

Decision: Keep transport handling, application logic and persistence in separate layers.

Reasoning: Each layer is tested on its own and HTTP handlers never touch MongoDB directly, so the backend stays easy to reason about and extend.

Security: cookies across two sites

Decision: Keep the session JWT in an HttpOnly cookie and add an explicit CSRF guard.

Reasoning: Frontend and API live on different sites, so the cookie must be SameSite=None, which removes SameSite's built-in CSRF protection. The API therefore checks the request origin and requires a custom header on every authenticated mutation, and login itself is origin-checked.

AI Documentation: Evidence over Generation

Decision: Generate documentation from public GitHub repository context rather than relying on unconstrained model output.

Implementation: CodeForge collects repository metadata, the README and package.json, then supplies that context to OpenAI, falling back to Gemini. Generation runs in the background, so a provider failure never blocks saving a project; the Markdown is normalized, persisted and rendered through a safe Markdown renderer. Existing documentation is only replaced on request.

Performance: measure, then cache

Decision: Serve public pages with Vercel ISR (300-second expiration) instead of rendering every request.

Evidence: The change was made after a Lighthouse baseline and measured afterwards: Performance went from 88 to 96 and LCP from 3.0 s to 2.2 s, without turning the site into a static build.

06. Implementation Highlights

The implementation focuses on maintainability and explicit engineering boundaries rather than treating the portfolio as a purely visual frontend.

  • Fastify API: typed REST endpoints with JSON request schemas, one error format and centralized error handling.
  • Persistence: MongoDB with Mongoose models behind repositories; experience logos are stored in the database and served by the API, so there is no separate file storage.
  • Admin dashboard: overview, project and experience management with logo upload, an API playground and a system page with liveness, readiness and request metrics.
  • AI workflow: background, repository-aware documentation generation, triggered on creation or on demand.
  • Observability: structured request logs with request ids, an audit log for every content change, and /live, /ready and /metrics endpoints.
  • Deployment: Vercel for the frontend, Render for the API and MongoDB Atlas for data, with the same Node.js version pinned locally, in CI and in production.

07. Testing & Engineering Quality

Every push and pull request runs the same quality gates in GitHub Actions. A build fails when coverage drops below its threshold, when an accessibility scan finds a violation, or when a high-severity dependency advisory appears.

✓ESLint and TypeScript (tsc, astro check)
✓Backend Vitest against a real MongoDB
✓Frontend unit and rendering tests (90% coverage gate)
✓Playwright E2E with six parallel workers
✓axe-core scans of public and admin pages
✓npm audit, CodeQL and Dependency Review

Frontend tests render the real .astro pages with the Astro Container API, and the admin tests mount that markup before running the client code, so templates and scripts cannot silently drift apart. Test counts and coverage are not copied into prose: CI regenerates them on every run in a single metrics file.

08. Security Model

Authentication

JWT (HS256, issuer and audience checked, 24 h expiry) in an HttpOnly, Secure cookie, revoked server-side at logout; bcrypt-hashed admin password.

CSRF Protection

Every authenticated mutation must come from an allowed origin and carry an X-Requested-With header that cross-site pages cannot send.

HTTP Protection

Helmet, HSTS, frame-ancestors 'none', referrer policy and a hash-based CSP without 'unsafe-inline' on both the site and the API.

Abuse Prevention

Global per-client rate limiting plus a stricter limit of five login attempts per minute.

Input Safety

Fastify JSON schemas reject unknown fields, oversized values and malformed ids before any business logic runs.

Output Safety

API data reaches the DOM only through textContent and attributes; project Markdown is escaped and its links are allow-listed.

09. Results

The result is a portfolio platform that demonstrates full-stack engineering through the system itself rather than through screenshots. Production Lighthouse audit of the homepage on 20 October 2026: scores out of 100, median of three runs on desktop and three on mobile.

Performance
Desktop
99
Mobile
92
Accessibility
Desktop
100
Mobile
100
Best Practices
Desktop
100
Mobile
100
SEO
Desktop
100
Mobile
100

Layout shift is zero on both form factors and LCP stays under the 2.5-second target. The platform that delivers those numbers is built from:

FrontendAstro + Tailwind CSS + TypeScript modules
BackendFastify + TypeScript on Node.js 24
PersistenceMongoDB Atlas + Mongoose
AI DocumentationGitHub Context + OpenAI / Gemini

More importantly, CodeForge became an engineering evidence platform: portfolio content is stored as application data, the administrative workflow is protected against both authentication and CSRF attacks, every layer is tested, CI blocks regressions, and technical documentation is generated from repository evidence.

10. What I Learned

  • Architecture matters at project scale: separating transport, business logic and persistence makes the system substantially easier to test and evolve.
  • Deployment shapes the threat model: splitting frontend and API across two sites forced SameSite=None cookies, and with them an explicit CSRF defence. Security has to follow the real topology.
  • Measure before optimizing: ISR was justified by a baseline, and a single slow TTFB sample turned out to be noise once the audit was repeated. One measurement is not evidence.
  • AI output needs evidence: repository-grounded generation is more useful for technical documentation than unconstrained generation because it reduces unsupported claims.
  • Engineering quality is broader than features: testing, CI, deployment, observability and documentation are part of the product.

11. Future Improvements

The engineering roadmap is complete; what remains is evidence that needs real users and deliberate trade-offs. Next steps are recording field INP from real-user monitoring and deeper repository analysis for richer AI documentation.