Start from the user and the product signal
A production feature begins with a reason to exist and a way to understand whether it is useful. Analytics introduces that measurement layer: identify meaningful activity and use it to inform product decisions, rather than treating collected numbers as a goal by themselves.
Integrate services as part of a coherent experience
AI APIs and Stripe represent different kinds of external capability: one can provide model-powered behavior, while the other supports payment flows. In either case, an integration needs a clear place in the product, predictable user-facing behavior and careful handling of its configuration.
Understand what keeps the application running
A feature does not end when it works on a developer’s machine. VPS concepts introduce the server environment that can host a live application and the operational context around it. This stage connects product intent, third-party services and deployment thinking in production-oriented work.
From concept to working code
These short excerpts show how the ideas in each stage appear in real projects. They are starting points to read, question, adapt and test—not code to paste without understanding.
Keep external service credentials on the server
The route validates the request before calling an AI service. The API key comes from a server environment variable, upstream errors are converted into a controlled response, and the secret is never sent to browser code.
export async function POST(request) {
const { prompt } = await request.json();
if (typeof prompt !== "string" || !prompt.trim()) {
return Response.json({ error: "Prompt is required." }, { status: 400 });
}
const upstream = await fetch(process.env.AI_API_URL, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ prompt: prompt.trim() }),
});
if (!upstream.ok) {
return Response.json({ error: "The service is unavailable." }, { status: 502 });
}
return Response.json(await upstream.json());
}Make the runtime reproducible
The Dockerfile installs locked dependencies, builds in a separate stage and runs with production mode under a non-root user. In a real release, add a health check, pin the base image and inject secrets through deployment configuration.
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:22-alpine AS runtime
ENV NODE_ENV=production
WORKDIR /app
COPY --from=build /app .
EXPOSE 3000
USER node
CMD ["npm", "start"]Read it, then make it yoursChange one requirement, predict what should happen, then run the code and check your prediction. In review, be ready to explain the trade-off you chose and one improvement you would make next.