The Architecture Behind amarjyoti.dev
I built amarjyoti.dev to serve three audiences from a single static codebase: human visitors reading a portfolio and technical notes, search engines and AI systems parsing structured metadata, and automated quality gates verifying every build before deployment.
Rather than adopting a single-page application framework, Tailwind, or an external CMS, the codebase runs on static Astro, strict TypeScript, and layered plain CSS, separating data, transformations, presentation, styling, and client enhancements cleanly.
Core Architectural Constraints
Every engineering decision in amarjyoti.dev stems from explicit boundaries configured in astro.config.mjs and tsconfig.json:
- Static-first output: Astro compiles every HTML route and machine-readable endpoint into
dist/at build time (output: 'static',trailingSlash: 'never',build.format: 'directory', andcompressHTML: true). - Strict TypeScript contracts: Extending
astro/tsconfigs/strictwith strict indexing and explicit module syntax catches data drift and missing fields at compile time. - Plain CSS with zero runtime styling frameworks: Styles live in layered CSS files (
inlineStylesheets: 'never') backed by custom-property tokens rather than utility classes or CSS-in-JS. - Selective vanilla TypeScript enhancements:
<ClientRouter fallback="none" />with opt-in hover prefetching (prefetchAll: false) coordinates lightweight, event-delegated client modules insrc/scripts/. - Strict Content Security Policy (CSP): Every inline
<style>block emitted indist/must match its SHA-256 hash insidefirebase.jsonstyle-src, checked automatically after every build.
Directory Layout & Module Separation
Keeping data, transformations, presentation, styling, and verification in separate folders prevents copy edits from entangling layout code or SEO generators:
.agents/ Task-routing guide (GUIDE.md), domain guides, and progressive skills (skills/)
.devcontainer/ Reproducible Node 24 + Playwright Chromium headless-shell container config (devcontainer.json)
.github/ CI pipeline workflow (workflows/pipeline.yml) and grouped Dependabot config (dependabot.yml)
src/
assets/ Author portrait (profile-photo.png), subsetted Inter/JetBrains Mono fonts, Markdown articles (articles/)
constants/ Canonical routes, endpoints, DOM selectors, site config, HTTP headers, SEO, theme, UI tokens/labels (ui.ts), and Wikipedia entities (wikipedia-entities.ts)
types/ Public readonly TypeScript contracts (article.ts, portfolio.ts, portfolio/, theme.ts, view.ts, pdfkit.d.ts)
data/ Canonical static profile data (portfolio.ts + portfolio/{profile,skills,career,pages,resume-sections}.ts)
utils/ Pure view-model builders & loaders (portfolio/), article helpers (articles/), IST datetimes (datetime/), SEO (seo/), JSON-LD (json-ld/), LLM context (llms/), RSS (rss/), media & font helpers (media/), endpoint generators (endpoints/), social cards (card/), resume PDF payload (resume/), routing helpers (route-paths.ts), Firebase config parsing (cloudflare-files.ts)
layouts/ Root document shell (BaseLayout.astro)
components/ Domain-grouped Astro components (common, layout, portfolio, resume, projects, articles, contact)
pages/ File-based routes & static endpoints (pages, RSS feeds, llms.txt, llms-full.txt, .well-known/security.txt)
scripts/ Vanilla TypeScript modules (main.ts, dom.ts, lifecycle.ts, theme-toggle.ts, navigation.ts, mobile-nav.ts, clipboard.ts, article-prose.ts, contact-form/{index,draft}.ts, photo-loader.ts, relative-time.ts, clock.ts, analytics/{index,events,interactions,vitals}.ts)
styles/ Layered plain CSS via global.css (tokens.css, base.css, components/*.css, layout/*.css), layered prose.css, and media="print" print.css (print/{resume,article,page}.css)
scripts/ Validation tools (lib/{cli,dist,firebase,html,pdf}.mjs, check-hygiene.mjs + hygiene/{comments,docs,naming}.mjs, check-output/{index,assets,html,json-ld,pdf,sitemap}.mjs, check-csp.mjs)
tests/ Test configs (tests/config/{vitest,playwright}.config.ts), Vitest unit suites (tests/unit/{scripts,utils}/), and Playwright browser E2E suites (tests/e2e/{a11y,articles,contact,csp,layout,navigation,theme}.spec.ts)
Two rules keep imports clean across the repository:
- Public vs. local contracts: Cross-directory types (
ArticleFrontmatter,PortfolioData,PageMetaProps,TimelineEntry,ContactItem,SiteEndpoints,ArticleArchivePage,Theme) live insrc/types/, while module-specific interfaces (LoadedArticle,PageMetadata) stay inside their owning files. - Domain entry points over deep imports: Server utilities (
src/utils/{seo,json-ld,llms,card,articles,resume,portfolio,datetime,rss}/index.ts) and client feature folders (src/scripts/{contact-form,analytics}/index.ts) expose stable entry points while keeping internal helpers inside their respective subdirectories.
Single-Source Data Flow
All structured portfolio and resume data originate in src/data/portfolio.ts, while long-form technical writing lives in src/assets/articles/*.md. From those two inputs, the build pipeline derives every output:
- Source validation:
src/types/portfolio.tsenforces schema structure onportfolio.ts, andsrc/utils/articles/loader.tsvalidates Markdown frontmatter at build time. - Pure transformations: Helpers in
src/utils/portfolio/,src/utils/resume/pdf-data.ts,src/utils/articles/index.ts,src/utils/markdown.ts, andsrc/utils/datetime/build timeline entries, card grids, structured PDF payloads, excerpts, word counts, reading times (~200 wpm viaformatReadTimeFromWords()), ISO-8601timeRequireddurations, and IST (Asia/Kolkata, UTC+05:30) datetimes. - Canonical routing & pagination:
src/constants/routes.tsdefines every route (/,/resume,/projects,/articles,/contact), article reader URL (/articles/<slug>), and paginated archive URL (/articles/<page>). Numeric-only article slugs are rejected so pagination paths never collide. - Page assembly: Route templates in
src/pages/composeBaseLayout.astro,<Toolbar>,<PageSheet>, and domain components insrc/components/using derived view models without hardcoding profile or editorial copy inside UI markup.
Swiss Grid CSS Layers & Pre-Paint Theme
Visual styling follows explicit cascade layers in src/styles/global.css (@layer tokens, base, components, layout):
tokens.css: Light and dark palettes (src/constants/theme.ts), spacing, typography scales, and print tokens (--print-bg,--print-surface).base.css: Element resets, accessible focus rings, typography defaults, and link underlines.components/*.css: Reusable buttons, action rows, contact form controls, topic chips, eyebrow leads, endpoint rows, pagination, timelines, and media frames.layout/*.css: Page and section shells, sticky header chrome (--z-header) and mobile drawer layering (--z-overlay), Swiss grid containers (with CSSsubgridrow alignment), and responsive breakpoints, paired withprefers-reduced-motionsafeguards inglobal.css.prose.css&print.css: Article reader prose styles (prose.css) and unlayered A4 print styles (print.css) loaded viamedia="print"inHead.astroso print layout rules stay out of screen CSS.
Typography relies on locally bundled Inter (--font-sans) and JetBrains Mono (--font-mono) WOFF2 subsets loaded through Astro’s local fontProviders API in astro.config.mjs, avoiding external font requests at runtime.
To apply the persisted or OS-preferred theme before first paint without triggering a CSP inline-script violation, src/pages/theme-init.js.ts prerenders /theme-init.js from src/utils/endpoints/theme-init.ts and loads it synchronously in <head>.
Progressive Client Scripting
Because every page renders as static HTML first, src/scripts/main.ts focuses strictly on progressive enhancement across Astro View Transitions:
- Theme & navigation lifecycle:
theme-toggle.tsupdatesdata-themeand polite live-region announcements,ProfileCard.astrorenders an inline CSS-token SVG with PNG download, andnavigation.ts+mobile-nav.tscoordinate<ClientRouter />active link state, progress feedback (#nav-progress-bar), and accessible mobile menu focus management. - Article prose & clipboard controls:
clipboard.tsandmain.tsdelegatedata-copyanddata-printclicks, whilearticle-prose.tsloads lazily when code blocks, tables, or section headings exist to add copy buttons, keyboard-scrollable table wrappers, and#heading deep-link anchors. - Localized timestamps & live status clock:
relative-time.tsuses client-safe relative-time helpers fromsrc/utils/datetime/to format<time[datetime]>elements,clock.tsruns lazily on/contact, andphoto-loader.tscoordinates portrait loading. - Contact draft persistence & telemetry: On
/contact,main.tsloadscontact-form/index.tswhenform[data-contact-form]exists, preserving drafts insessionStorageacross navigation, whileanalytics/{index,events,interactions,vitals}.tsload on browser idle or first interaction, defergtag.jsinjection, and emit privacy-safeanalytics:actionevents and Web Vitals (LCP,CLS,INP) with query/fragment strings stripped.
Machine-Readable Endpoints
src/constants/routes.ts (ENDPOINT_PATHS) exposes static machine-readable outputs alongside human routes:
| Endpoint | Generator | Purpose |
|---|---|---|
/llms.txt & /llms-full.txt |
src/utils/llms/index.ts |
Concise Markdown index and detailed knowledge base for LLMs |
/rss.xml & /articles/rss.xml |
src/utils/rss/index.ts |
Chronologically sorted RSS 2.0 feeds with xmlns:media article covers |
/sitemap-index.xml |
@astrojs/sitemap + src/utils/endpoints/sitemap.ts |
XML sitemap honoring article updated/datetime frontmatter |
/robots.txt & /.well-known/security.txt |
src/utils/endpoints/robots.ts, src/utils/endpoints/security.ts |
Crawler directives and RFC 9116 security contact metadata |
/card.svg & /card.png |
src/utils/card/index.ts → src/utils/card/{data,render}.ts |
Build-time 1200×630 profile Open Graph card |
/photo.webp |
src/pages/photo.webp.ts → src/utils/media/profile-photo.ts |
Sharp-optimized author portrait |
/favicon.*, /icon-*.png & /site.webmanifest |
src/pages/[icon].ts, src/pages/site.webmanifest.ts → src/utils/favicon.ts, src/utils/endpoints/manifest.ts |
Brand favicons and web app manifest |
Every indexable page also embeds a Schema.org JSON-LD @graph (src/utils/json-ld/index.ts) and speakable metadata (src/utils/seo/index.ts), emitting full Person entities (hasCredential, worksFor, and alumniOf) on / and /resume, ItemList collections on /projects and /articles, wordCount and timeRequired on TechArticles, and lightweight @id stubs on secondary routes.
Build-Time PDF Resume & Security Gates
Running npm run build executes two synchronized steps:
astro buildcompiles static pages and endpoints todist/, including/resume.pdfviasrc/pages/resume.pdf.tsandbuildResumePdfData()insrc/utils/resume/index.ts.src/utils/resume/render.tsrendersdist/resume.pdfdirectly with PDFKit from that typed payload, guaranteeing selectable text, clickable links, embedded fonts, and a deterministic 2-page A4 layout synchronized withsrc/data/portfolio.ts.
On Firebase Hosting (firebase.json), responses carry strict security headers:
- Transport & framing:
Strict-Transport-Security,X-Frame-Options: DENY, andX-Content-Type-Options: nosniff. - Origin isolation & permissions:
Cross-Origin-Opener-Policy: same-origin,Cross-Origin-Resource-Policy: same-origin,Referrer-Policy, andPermissions-Policy. - Strict CSP: No
'unsafe-inline',object-src 'none',frame-src 'none',style-src-attr 'none',frame-ancestors 'none', and SHA-256 hashed<style>blocks verified byscripts/check-csp.mjsagainst every HTML file indist/and tested live in Playwright (tests/e2e/csp.spec.ts).
Automated Verification Pipeline
Quality checks run in GitHub Actions (.github/workflows/pipeline.yml) inside the same Node.js 24 (.node-version) and Playwright Chromium headless-shell baseline defined in .devcontainer/devcontainer.json, alongside weekly grouped updates targeting dev via .github/dependabot.yml. Verification concurrency is scoped per job by PR or ref (cancelling superseded runs except on main), ~/.cache/ms-playwright is cached by exact lockfile hash so cache hits install only OS dependencies and skip browser archive downloads, and verified pushes to dev serialize fast-forward promotion of the exact verified commit SHA to main:
- Fast pre-finish gate (
npm run verify:fast): Executesastro check,npm run check:hygiene(Knip for zero unused files, dependencies, exports, or types, plus zero code comments, zero em dashes, zero named view transitions, zero repo-name prose in articles, valid doc links/paths andSKILL.mdfrontmatter, zero empty dirs, consistent file naming),npm run build,scripts/check-output/index.mjs(endpoints, RSS namespaces,firebase.jsonheaders,404.html,security.txt, JSON-LD@idgraph integrity, sitemap contracts, anchor checks, asset budgets, and decoded 2-page PDF text and URIs viascripts/lib/pdf.mjs), andscripts/check-csp.mjs. - Full CI gate (
npm run verify): Addsformat:check(Prettier),npm test(Vitest unit and client tests intests/unit/),verify:fast, andnpm run test:e2e(Playwright E2E suites intests/e2e/*.spec.ts, including live CSP injection and dual-theme WCAG AA accessibility checks).
This is a living architecture document. Whenever routes, endpoints, build scripts, security headers, or module boundaries change on amarjyoti.dev, this article and its updated timestamp are updated alongside the codebase.