KECERDASAN-BUATAN/AGENTS.md

3.2 KiB

AGENTS.md

Project

Single-page dengue (DBD) pre-diagnosis app: FastAPI + MySQL backend + one static HTML/JS frontend. All user-facing copy is Indonesian; keep it that way. The fuzzy engine is Mamdani (min-max inference, centroid defuzzification) for DF / DHF / DSS.

Layout

  • main.py — the whole backend: SQLAlchemy models, DB seeding, fuzzy engine, FastAPI routes, uvicorn entrypoint.
  • index.html — the whole frontend (inline CSS/JS; Tailwind + Font Awesome loaded from CDNs). No build step.
  • usecase.html — standalone static documentation page with the corrected use case diagram (inline CSS/SVG/JS, no CDN). Open via file://; unrelated to the running app.
  • .agents/skills/design-taste-frontend/ + skills-lock.json — vendored third-party taste-skill (design workflow/tooling). Not app code; do not edit the kit's assets/ or scripts/.

Setup and run

  • No requirements.txt, no tests, no lint/format config, no git. Install deps manually: pip install fastapi uvicorn numpy sqlalchemy pymysql.
  • MySQL must be reachable before startup. Hardcoded URL at main.py:17: mysql+pymysql://root:@localhost:3306/db_fuzzy_dbd (root, empty password). There is no offline/mock mode.
  • Importing main.py has side effects: Base.metadata.create_all() (main.py:85) and seed_initial_data() (main.py:132) run at import, so the app fails immediately if MySQL is down.
  • Run: python main.py → http://127.0.0.1:8000 (uvicorn, reload=True). UI is served at /.
  • Syntax-check without touching MySQL: python -m py_compile main.py.

HTTP API

GET / (serves index.html), GET /api/penyakit, POST /api/diagnosa, GET /api/riwayat, DELETE /api/riwayat/{id}.

Things easy to get wrong

  • Symptom codes are duplicated and must match exactly. daftarGejala (index.html:262) vs. the keys read by evaluasi_aturan (main.py:199). Mismatch → KeyError on POST /api/diagnosa. Valid codes: G01 G02 G04 G05 G06 G07 G10 G12 G16 G17 G18 (gaps are intentional).
  • Diagnosis text is not read from the DB. POST /api/diagnosa returns the hardcoded info_map (main.py:257); /api/penyakit and seeding use tb_penyakit. Editing one does not change the other — keep both in sync.
  • Classification thresholds on centroid score (main.py:249): <42 → DF, <72 → DHF, otherwise DSS.
  • Membership-function breakpoints (mu_rendah/mu_sedang/mu_tinggi, main.py:142) differ from the UI labels (Rendah ≤3, Sedang ≤6). Change them together if you touch the scale.
  • TbUser and tb_diagnosa.user_id exist but are unused — no auth or user endpoints; user_id is always null.
  • Persistence uses create_all + runtime seeding, not migrations. Changing model columns will not alter existing tables; treat the DB as manual.
  • Frontend is CDN-dependent (needs internet for styling/icons) and has no bundler.
  • index.html:242 has a duplicate id attribute on the tab-penyakit section. Harmless today; don't add another.

Verification

No test suite exists. After changes: python -m py_compile main.py, then start the server and smoke-test e.g. Invoke-RestMethod http://127.0.0.1:8000/api/penyakit. Frontend changes must be checked manually in a browser at the running server.