Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Next.js 14+ dashboard application that monitors and tracks Google Cloud AI (Gemini API) and Supabase usage with budget alerts and cost projections. The app uses TypeScript, Tailwind CSS v4, shadcn/ui components with the doom-64 theme, and Recharts for visualizations.
# Install dependencies npm install # Development server (http://localhost:3000) npm run dev # Production build npm run build # Run production server npm start # Lint code npm run lint
The application follows a server-side API proxy pattern to protect sensitive credentials:
components/google-cloud-dashboard.tsx, components/supabase-dashboard.tsx) fetch data via browser fetch()app/api/*/usage/route.ts) act as secure proxieslib/google-cloud.ts, lib/supabase.ts) contain actual API logic with credentialstypes/index.ts) ensure type safety across all layersCritical: Never expose API keys or service credentials in client-side code. All authentication happens server-side in the
/lib directory.
@google-cloud/monitoring SDK with service account credentials stored as JSON in environment variablesaiplatform.googleapis.com/prediction/online/response_count metricALIGN_RATE alignerAVG_TOKENS_PER_REQUEST constant (lib/google-cloud.ts:67)FREE_TIER_LIMITS object (lib/supabase.ts:42-48)MONTHLY_BUDGET_USD environment variableRequired variables (never commit to version control):
# Google Cloud GOOGLE_CLOUD_PROJECT_ID=your-project-id GOOGLE_APPLICATION_CREDENTIALS_JSON={"type":"service_account",...} # Minified JSON GOOGLE_CLOUD_REGION=us-central1 # Supabase NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key SUPABASE_SERVICE_ROLE_KEY=your-service-role-key # Server-side only! # Budget MONTHLY_BUDGET_USD=100
See
env.example.txt for template.
GeminiUsageMetrics type in types/index.tsgetGeminiUsageMetrics() in lib/google-cloud.ts to fetch/calculate the metricMONTHLY_BUDGET_USD in .env.local (restart server)FREE_TIER_LIMITS in lib/supabase.ts:42-48npx shadcn@latest add [component-name]
npx shadcn@latest add https://tweakcn.com/r/themes/[theme-name].json
Current theme: doom-64 (retro gaming aesthetic with dark mode)
aiplatform.googleapis.com/prediction/online/response_count) may need adjustment based on specific services usedSUPABASE_SERVICE_ROLE_KEY bypasses Row Level Security - never expose client-sideGOOGLE_APPLICATION_CREDENTIALS_JSON must be minified (no line breaks)app/globals.css using @theme directive@tailwindcss/postcssDate Added: November 2024
Issue: Recharts v3.5.0 has compatibility issues with React 19 and Next.js 15 SSR
What We Encountered:
dynamic() functionWorkarounds Implemented: All chart components in
components/charts/ use client-side only rendering:
line-chart-wrapper.tsx): Uses useEffect + dynamic import() to load Recharts only on clientbar-chart-wrapper.tsx, supabase-bar-chart-wrapper.tsx): Same pattern - client-side loading with loading statesWhy This Works:
Files Using This Pattern:
components/charts/line-chart-wrapper.tsxcomponents/charts/bar-chart-wrapper.tsxcomponents/charts/supabase-bar-chart-wrapper.tsxFuture Considerations:
If You See Chart Errors:
.next directory: rm -rf .nextnpm run builduseEffect + dynamic import pattern'use client' directive is at the top of chart wrapper filesBefore committing or deploying:
npm run build to ensure TypeScript compilation succeedsnpm run lint to check for ESLint errorsMONTHLY_BUDGET_USD temporarilyGOOGLE_APPLICATION_CREDENTIALS_JSON is valid JSONGOOGLE_CLOUD_PROJECT_ID matches service account projectSUPABASE_SERVICE_ROLE_KEY is correct (not anon key).next directory: rm -rf .nextrm -rf node_modules && npm installnpx tsc --noEmit