2.9 KiB
2.9 KiB
Repository Guidelines
Project Structure & Module Organization
- Frontend (Next.js + TypeScript):
src/app/**(pages:page.tsx,layout.tsx, styles:globals.css). API route for CopilotKit:src/app/api/copilotkit/route.ts. - Agent (ADK/Python):
agent/agent.py, virtual env inagent/.venv, deps inagent/requirements.txt. - Public assets:
public/. Config:next.config.ts,tsconfig.json,eslint.config.mjs. - Scripts:
scripts/run-agent.sh,scripts/setup-agent.sh.
Build, Test, and Development
npm run dev— runs UI (next dev --turbopack) and the Python agent concurrently.npm run dev:ui— frontend only; useful for UI iteration.npm run dev:agent— agent only; activates.venvand runsagent.py.npm run build— production build for the Next.js app.npm start— serve the built app.npm run lint— lint the frontend with Next/ESLint.- First-time setup installs the agent via
postinstall(creates.venvand installs Python deps).
Coding Style & Naming Conventions
- TypeScript/React: 2-space indent, PascalCase components, camelCase variables, file-based routing under
src/app/**. - Python agent: follow PEP 8; keep modules small and composable.
- Linting: Next.js ESLint config (
npm run lint). Prefer explicit types in exported APIs. - Components: colocate with usage; export from an
index.tswhen creating reusable modules.
Testing Guidelines
- Currently no test harness. When adding tests:
- Frontend: Jest/Vitest in
src/__tests__/with*.test.ts(x). - Agent:
pytestinagent/tests/withtest_*.py. - Aim for high coverage on data shaping (dashboard spec generation, adapters).
- Frontend: Jest/Vitest in
Commit & Pull Request Guidelines
- Conventional Commits:
type(scope): message.- Types:
feat,fix,docs,refactor,test,chore,ci. - Example:
feat(charts): support pie charts.
- Types:
- PRs: clear description, linked issue, before/after screenshots or JSON spec samples, and testing notes.
- Keep PRs focused; call out env/config changes explicitly.
Environment, Security & Config
- Place secrets in
.env.local(frontend) andagent/.env(agent). Never commit secrets. - Example keys (adjust to your provider):
- Frontend:
NEXT_PUBLIC_CPK_ENDPOINT=/api/copilotkit. - Agent:
GOOGLE_API_KEY=...(Gemini), orOPENAI_API_KEY=...if applicable.
- Frontend:
- Validate/sanitize prompts; avoid logging PII. Prefer
INFOlogs with redaction.
Charts & CopilotKit Tips
- Dashboard spec (example):
{ "type": "line", "title": "Revenue", "x": "date", "y": "revenue" }. - Supported types to target in UI:
line,bar,pie - Naming: use singular
x/yfor series - Recharts via CPK: map spec→props; e.g.,
LineChartwithdataKey={spec.y}andXAxis dataKey={spec.x};
Architecture Overview
- Next.js app hosts CopilotKit UI and API route; Python agent performs ADK/Gemini orchestration.
npm run devruns both together.