Single-page portfolio for M Afnan Khadim, MERN Stack Web Developer. React 18 + Vite 5, plain JavaScript, no router or state library. A custom dark design system with a light theme toggle, a three.js hero scene, scroll reveals, filterable project grid, Web3Forms contact form and an AI chat assistant.
npm install # install dependencies
npm run dev # start dev server (http://localhost:5173)
npm run build # production build into dist/
npm run preview # serve the production build locally
npm run dev also runs the AI assistant's serverless function (see
vite.config.js), so the chat widget works locally as soon as a .env with
CHAT_API_KEY exists — no Vercel CLI needed. vercel dev also works if you
want the full Vercel environment.
api/chat.js # Vercel function behind the AI assistant
public/ # images, fonts and Font Awesome (icon glyphs only)
src/
main.jsx # entry; imports styles/base.css before App
App.jsx # page composition
components/ # one component per section, plus Tilt, Reveal,
# CountUp, HeroScene (three.js) and ThemeToggle
data/
content.js # nav, services, skills, experience, contact, socials
portfolio.js # projects with GitHub / Play Store / site links
chatbot.js # assistant bio, greeting and prompt (shared with api/)
styles/
base.css # design tokens, reset and shared primitives
<section>.css # one stylesheet per component, imported by it
utils/ # scroll offset, theme switch effect
- Theming: all colours are CSS custom properties in
src/styles/base.css. The light theme is a single:root[data-theme="light"]override of those tokens; the nav toggle setsdata-themeon<html>, saves the choice, and an inline script inindex.htmlapplies it before first paint (first visits follow the OS preference). Section stylesheets use tokens, never raw colours. - Content lives in
src/data/; components only map over it. - Projects link to their GitHub repo, their Google Play listing, or the live site when the repo is private.
- The Web3Forms access key in
src/data/content.jsis public by design (it is a client-side key).
The floating chat bubble (src/components/Chatbot.jsx) posts to /api/chat,
a Vercel serverless function (api/chat.js) that adds the system prompt and
the model API key before calling the provider. The key therefore never reaches the
browser — unlike the Web3Forms key, it must stay secret.
The function's knowledge about Afnan lives in src/data/chatbot.js, and its
project list is generated from src/data/portfolio.js, so the assistant can't
describe a project that is no longer on the site. Edit the bio, greeting or
suggestion chips there.
Configure the provider with environment variables — on Vercel under
Settings → Environment Variables (or vercel env add), and locally in a .env
(see .env.example):
| Variable | Required | Default |
|---|---|---|
CHAT_API_KEY |
yes | — |
CHAT_API_URL |
no | Groq's OpenAI-compatible endpoint |
CHAT_MODEL |
no | openai/gpt-oss-120b |
Any OpenAI-compatible chat-completions API works (Groq, OpenAI, OpenRouter,
Together): set CHAT_API_URL and CHAT_MODEL to match the provider. Without a
key the widget still renders and fails politely, pointing visitors at the
contact form.
Locally the same function is served by a small Vite dev-server plugin in
vite.config.js, which reads .env and mounts the handler at the same
/api/chat path Vercel serves in production.