|
1 | 1 | # Repository Guidelines |
2 | 2 |
|
3 | 3 | ## Project Structure & Module Organization |
4 | | -- `backend/`: FastAPI service and data-to-spec pipeline (`main.py`, `analyzer.py`, `spec_generator.py`, `llm.py`). |
5 | | -- `frontend/`: React + TypeScript + Vite UI (`src/components`, `src/lib/catalog.ts`, `src/App.tsx`). |
6 | | -- `sample_data/`: local datasets for manual validation (CSV/TSV/JSON/XLSX). |
7 | | -- Root docs: `json-render-docs.md`, `quickstart.md`. |
8 | | - |
9 | | -Keep backend logic data-focused (analysis/spec generation) and frontend logic presentation-focused (renderer and components). |
| 4 | +- `backend/`: FastAPI service and analysis pipeline (`main.py`, `analyzer.py`, `llm.py`, `db.py`, `nl2sql.py`). |
| 5 | +- `frontend/`: React 19 + TypeScript app (Vite). UI components live in `frontend/src/components/`, JSON catalog/registry in `frontend/src/lib/` and `frontend/src/components/registry.tsx`. |
| 6 | +- `sample_data/`: local datasets for smoke testing uploads. |
| 7 | +- `resource/`: demo media assets. |
| 8 | +- `.github/workflows/pylint.yml`: Python lint CI job. |
10 | 9 |
|
11 | 10 | ## Build, Test, and Development Commands |
12 | | -- Backend setup/run: |
13 | | -```powershell |
14 | | -cd backend |
15 | | -python -m venv .venv |
16 | | -.\.venv\Scripts\Activate.ps1 |
17 | | -pip install -r requirements.txt |
18 | | -uvicorn main:app --reload --port 8000 |
19 | | -``` |
20 | | -- Frontend setup/run: |
21 | | -```powershell |
22 | | -cd frontend |
23 | | -npm install |
24 | | -npm run dev |
25 | | -``` |
| 11 | +- Backend setup: |
| 12 | + - `cd backend && pip install -r requirements.txt` |
| 13 | + - `uvicorn main:app --reload --port 8000` (runs API at `http://localhost:8000`) |
| 14 | +- Frontend setup: |
| 15 | + - `cd frontend && npm install` |
| 16 | + - `npm run dev` (local app at `http://localhost:5173`) |
26 | 17 | - Frontend quality/build: |
27 | | -```powershell |
28 | | -npm run lint # ESLint on TS/TSX |
29 | | -npm run build # Type-check + production build |
30 | | -npm run preview # Preview built app |
31 | | -``` |
| 18 | + - `npm run lint` (ESLint for `ts/tsx`) |
| 19 | + - `npm run build` (TypeScript compile + Vite production build) |
| 20 | + - `npm run preview` (serve built app) |
32 | 21 |
|
33 | 22 | ## Coding Style & Naming Conventions |
34 | | -- Python: follow PEP 8, 4-space indentation, `snake_case` for functions/variables, small focused helpers. |
35 | | -- TypeScript/React: 2-space indentation, `PascalCase` for components (`StatCard.tsx`), `camelCase` for functions/props. |
36 | | -- Keep component schemas and registry aligned with `frontend/src/lib/catalog.ts` and `frontend/src/components/registry.tsx`. |
37 | | -- Run `npm run lint` before opening a PR. |
| 23 | +- Python: 4-space indentation, `snake_case` for functions/variables, small focused functions. |
| 24 | +- TypeScript/React: `PascalCase` for components (`StatCard.tsx`), `camelCase` for helpers/hooks. |
| 25 | +- Keep component contracts aligned with the JSON render catalog (`BarChart`, `LineChart`, `PieChart`, etc.). |
| 26 | +- Run `npm run lint` before opening a PR; keep imports and unused variables clean. |
38 | 27 |
|
39 | 28 | ## Testing Guidelines |
40 | | -- No automated test suite is currently committed. |
41 | | -- Minimum expectation: manual smoke test with both servers running and at least one file from `sample_data/` uploaded. |
42 | | -- New tests are encouraged: |
43 | | - - Backend: `backend/tests/test_*.py` with `pytest`. |
44 | | - - Frontend: `*.test.tsx` near components or under `frontend/src/__tests__/`. |
| 29 | +- There is no committed unit-test suite yet for backend or frontend. |
| 30 | +- Minimum check before PR: |
| 31 | + - `npm run lint` |
| 32 | + - `npm run build` |
| 33 | + - Manual smoke test: upload at least one file from `sample_data/` and verify dashboard rendering. |
| 34 | +- For backend logic changes, add targeted tests when introducing non-trivial parsing/query behavior. |
45 | 35 |
|
46 | 36 | ## Commit & Pull Request Guidelines |
47 | | -- Existing history uses short, release-style messages (example: `version 1.0.4 supportAllKindOfData`). |
48 | | -- Prefer concise commits with clear scope, e.g. `frontend: improve chart legend layout`. |
| 37 | +- Current history is release-oriented (`version <semver> <note>`, e.g., `version 2.1.0 support personal database analyze`). |
| 38 | +- Prefer concise, imperative commit subjects; include scope when useful (e.g., `backend: tighten SQL guard`). |
49 | 39 | - PRs should include: |
50 | | - - What changed and why. |
51 | | - - Manual verification steps. |
52 | | - - Screenshots/GIFs for UI changes. |
53 | | - - Any config/env updates. |
| 40 | + - What changed and why |
| 41 | + - Manual verification steps |
| 42 | + - UI screenshots/GIFs for frontend changes |
| 43 | + - Linked issue/task reference |
54 | 44 |
|
55 | 45 | ## Security & Configuration Tips |
56 | | -- Configure secrets in `backend/.env` (`LLM_API_KEY`, `LLM_BASE_URL`, optional `LLM_MODEL`). |
57 | | -- Never commit API keys or sensitive datasets. |
| 46 | +- Use `backend/.env` for `LLM_API_KEY`, `LLM_BASE_URL`, `LLM_MODEL`, and DB credentials (`DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`, `DB_NAME`). |
| 47 | +- Never commit secrets. Keep generated metadata (`backend/db_meta.json`) out of version control. |
0 commit comments