Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b1ab9b9
feat(users): add porn_free_goal field and onboarding AI analysis inte…
salmanabdurrahman May 13, 2026
8fa85ee
feat(db): add manual auth columns and baseline seeder
salmanabdurrahman May 13, 2026
72c7fdc
fix(test): adjust users service initialization in e2e runtime
salmanabdurrahman May 13, 2026
4f95a80
feat(ai): add relapse‑solution endpoint and integrate AI relapse plan
salmanabdurrahman May 13, 2026
8651cb9
feat(routine): add explicit relapse endpoint and validation
salmanabdurrahman May 14, 2026
8bd04a5
feat(ai): normalize chat role to assistant and validate onboarding level
salmanabdurrahman May 14, 2026
ba48a62
deps(deps): add postgres driver dependency
salmanabdurrahman May 14, 2026
1161a4b
seed: expand baseline data for education contents, community posts/co…
ZaygaErnesto May 14, 2026
93ae8bb
seed: expand baseline data for seeders (#2)
salmanabdurrahman May 14, 2026
3d43b0f
feat(routine): handle same‑day relapse logic
salmanabdurrahman May 14, 2026
0ad3a95
feat(model): add education content type field and normalize labels
salmanabdurrahman May 14, 2026
dbc6e26
feat(db): extend seed data with google ids, relapse triggers and auth…
salmanabdurrahman May 14, 2026
34adcd8
feat(routine): add relapse statistics endpoint with utc hour analysis
salmanabdurrahman May 14, 2026
376f6a8
feat(api): add porn_free_goal field to user profile responses
salmanabdurrahman May 14, 2026
d990655
feat(api): add relapse calendar and enhanced relapse statistics
salmanabdurrahman May 14, 2026
2501877
feat(api): add porn_free_goal setting
salmanabdurrahman May 14, 2026
8af395e
docs(docs): update api reference with platform routes and review date
salmanabdurrahman May 14, 2026
1f4db88
feat(api): add relapse trigger distribution and rename solution fields
salmanabdurrahman May 15, 2026
d1817f2
feat(ai): add distinct persona signatures and style guidelines
salmanabdurrahman May 15, 2026
57b48ad
docs(ui): simplify relapse analysis message
salmanabdurrahman May 15, 2026
3f75b6e
feat(content): add daily physical challenges and challenge details
salmanabdurrahman May 15, 2026
89eb5c3
feat(ai): sanitize coach replies and strip internal persona markers
salmanabdurrahman May 15, 2026
57b60f5
fix(db): cast seed.id to uuid in baseline seed
salmanabdurrahman May 15, 2026
ba205ff
docs(docs): update documentation and seed data conventions
salmanabdurrahman May 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,504 changes: 1,160 additions & 344 deletions api/openapi/openapi.yaml

Large diffs are not rendered by default.

107 changes: 63 additions & 44 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ reviewers:
doc_status: draft
source_repo: recova-backend-v2
source_path: docs/api-reference.md
last_reviewed: 2026-05-09
last_reviewed: 2026-05-15
---

# Recova Backend API Reference
Expand Down Expand Up @@ -48,62 +48,81 @@ API saat ini dikonsumsi oleh aplikasi mobile Flutter, sehingga kontrak endpoint

## Endpoint Inventory

| Domain | Method | Path | Summary | Auth requirement | Contract status |
| --------- | -------- | ------------------------------ | --------------------------------------------- | ----------------- | --------------- |
| auth | `POST` | `/auth/google` | login/registrasi via Google token | public | implemented |
| auth | `POST` | `/auth/onboarding` | simpan onboarding awal pengguna | bearer | implemented |
| auth | `POST` | `/auth/refresh` | rotasi refresh token dan perbarui sesi akses | cookie | implemented |
| auth | `POST` | `/auth/logout` | akhiri sesi aktif pengguna | bearer | implemented |
| users | `GET` | `/users/me` | ambil profil pengguna | bearer | implemented |
| users | `PUT` | `/users/settings` | update pengaturan profil | bearer | implemented |
| users | `DELETE` | `/users/me/reset-data` | reset data pengguna untuk development/testing | bearer + dev-only | implemented |
| ai | `POST` | `/ai/ask-coach` | kirim pesan ke AI Coach | bearer | implemented |
| ai | `GET` | `/ai/chat-history` | ambil riwayat chat AI Coach | bearer | implemented |
| ai | `GET` | `/ai/summary` | ambil ringkasan check-in | bearer | implemented |
| ai | `POST` | `/ai/onboarding-analysis` | analisis data onboarding | bearer | implemented |
| ai | `GET` | `/ai/persona-preferences` | ambil preferensi persona AI | bearer | implemented |
| ai | `PUT` | `/ai/persona-preferences` | perbarui preferensi persona AI | bearer | implemented |
| routine | `POST` | `/routine/checkin` | check-in harian | bearer | implemented |
| routine | `GET` | `/routine/statistics` | ambil statistik pengguna | bearer | implemented |
| routine | `GET` | `/routine/relapses` | ambil riwayat relapse | bearer | implemented |
| journals | `GET` | `/journals` | ambil daftar jurnal pribadi | bearer | implemented |
| journals | `POST` | `/journals` | buat entri jurnal | bearer | implemented |
| community | `GET` | `/community` | ambil daftar postingan komunitas | bearer | implemented |
| community | `POST` | `/community` | buat postingan komunitas | bearer | implemented |
| community | `POST` | `/community/:post_id/comments` | tambah komentar pada postingan | bearer | implemented |
| community | `POST` | `/community/:post_id/like` | toggle suka postingan | bearer | implemented |
| education | `GET` | `/education` | ambil daftar konten edukasi | bearer | implemented |
| content | `GET` | `/content/daily` | ambil konten harian | bearer | implemented |
| Domain | Method | Path | Summary | Auth requirement | Contract status |
| ------------ | -------- | ---------------------------------------------------- | ---------------------------------------------------------- | ----------------- | --------------- |
| platform | `GET` | `/health/live` | cek status liveness service | public/internal | implemented |
| platform | `GET` | `/health/ready` | cek status readiness dependency | public/internal | implemented |
| platform | `GET` | `/metrics` | expose metrik prometheus | public/internal | implemented |
| platform | `GET` | `/openapi.yaml` | ambil OpenAPI YAML runtime | public | implemented |
| platform | `GET` | `/docs/api` | tampilkan API reference interaktif | public | implemented |
| auth | `POST` | `/auth/google` | login/registrasi via Google token | public | implemented |
| auth | `POST` | `/auth/register` | registrasi akun manual | public | implemented |
| auth | `POST` | `/auth/login` | login akun manual | public | implemented |
| auth | `POST` | `/auth/onboarding` | simpan onboarding awal + analisis AI response | bearer | implemented |
| auth | `POST` | `/auth/refresh` | rotasi refresh token dan perbarui sesi akses | cookie | implemented |
| auth | `POST` | `/auth/logout` | akhiri sesi aktif pengguna | bearer | implemented |
| users | `GET` | `/users/me` | ambil profil pengguna | bearer | implemented |
| users | `PUT` | `/users/settings` | update pengaturan profil | bearer | implemented |
| users | `DELETE` | `/users/me/reset-data` | reset data pengguna untuk development/testing | bearer + dev-only | implemented |
| ai | `POST` | `/ai/ask-coach` | kirim pesan ke AI Coach | bearer | implemented |
| ai | `POST` | `/ai/relapse-solution` | analisis trigger relapse + solusi terbaik | bearer | implemented |
| ai | `GET` | `/ai/chat-history` | ambil riwayat chat AI Coach | bearer | implemented |
| ai | `GET` | `/ai/summary` | ambil ringkasan check-in | bearer | implemented |
| ai | `POST` | `/ai/onboarding-analysis` | analisis data onboarding | bearer | implemented |
| ai | `GET` | `/ai/persona-preferences` | ambil preferensi persona AI | bearer | implemented |
| ai | `PUT` | `/ai/persona-preferences` | perbarui preferensi persona AI | bearer | implemented |
| routine | `POST` | `/routine/checkin` | check-in harian | bearer | implemented |
| routine | `POST` | `/routine/relapses` | catat relapse harian | bearer | implemented |
| routine | `GET` | `/routine/statistics` | ambil statistik pengguna | bearer | implemented |
| routine | `GET` | `/routine/statistics/activity-summary` | ambil ringkasan aktivitas periodik | bearer | implemented |
| routine | `GET` | `/routine/relapses` | ambil riwayat relapse | bearer | implemented |
| routine | `GET` | `/routine/relapses/statistics` | ambil statistik relapse lengkap | bearer | implemented |
| achievements | `GET` | `/achievements/catalog` | ambil katalog achievement aktif | bearer | implemented |
| achievements | `GET` | `/achievements/progress` | ambil progres achievement user | bearer | implemented |
| achievements | `GET` | `/achievements/unlocked` | ambil daftar achievement yang sudah terbuka | bearer | implemented |
| journals | `GET` | `/journals` | ambil daftar jurnal pribadi | bearer | implemented |
| journals | `POST` | `/journals` | buat entri jurnal | bearer | implemented |
| community | `GET` | `/community` | ambil daftar postingan komunitas | bearer | implemented |
| community | `POST` | `/community` | buat postingan komunitas | bearer | implemented |
| community | `GET` | `/community/{post_id}/comments` | ambil thread komentar | bearer | implemented |
| community | `POST` | `/community/{post_id}/comments` | tambah komentar pada postingan | bearer | implemented |
| community | `POST` | `/community/{post_id}/comments/{comment_id}/replies` | tambah balasan komentar | bearer | implemented |
| community | `POST` | `/community/{post_id}/like` | toggle suka postingan | bearer | implemented |
| education | `GET` | `/education` | ambil daftar konten edukasi | bearer | implemented |
| content | `GET` | `/content/daily` | ambil konten harian (motivasi, challenge, challenge fisik) | bearer | implemented |

## Contract Fields Coverage

| Contract field | Status | Notes |
| ----------------------- | ------- | --------------------------------------- |
| Method | covered | tersedia di sumber |
| Path | covered | tersedia di sumber |
| Summary | covered | tersedia di sumber |
| Auth requirement | gap | belum ada source eksplisit per endpoint |
| Request body schema | gap | belum ada source schema |
| Query schema | gap | belum ada source schema |
| Success response schema | gap | belum ada source schema |
| Error response schema | gap | belum ada source schema |
| Contract field | Status | Notes |
| ----------------------- | ------- | --------------------------------------------------------------------------- |
| Method | covered | tersedia di sumber |
| Path | covered | tersedia di sumber |
| Summary | covered | tersedia di sumber |
| Auth requirement | covered | terspesifikasi di `docs/generated/openapi.yaml` |
| Request body schema | covered | terspesifikasi per endpoint di OpenAPI |
| Query schema | covered | terspesifikasi per endpoint di OpenAPI |
| Success response schema | covered | tervalidasi contract test + OpenAPI |
| Error response schema | covered | tervalidasi contract test + OpenAPI |
| Platform routes | covered | `/health/*`, `/metrics`, `/openapi.yaml`, `/docs/api` sudah diinventarisasi |

## Gap Register
## Education Response Notes

- response `GET /api/v1/education` mengandung field `type` pada setiap item konten,
- nilai `type` dibatasi ke `artikel` atau `video`,
- label kategori user-facing pada payload menggunakan format natural (spasi), bukan snake_case.

Detail berikut masih perlu source tambahan:
## Gap Register

- daftar status code per endpoint,
- struktur request body/query per endpoint,
- struktur response sukses per endpoint,
- struktur error per endpoint,
- auth/authorization rule per endpoint.
Tidak ada gap terbuka untuk kontrak endpoint utama per audit 2026-05-15.
Detail query/response dan status code kanonik berada di `docs/generated/openapi.yaml` dan tervalidasi oleh `test/contract/openapi_contract_test.go`.

## Related Documents

- [API Compatibility Matrix](/Users/macbookpro/Development/recova-backend-v2/docs/api-compatibility-matrix.md)
- [API Versioning Standard](/Users/macbookpro/Development/recova-backend-v2/docs/standards/api-versioning.md)
- [API Response Standard](/Users/macbookpro/Development/recova-backend-v2/docs/api-response-standard.md)
- [API Docs Generation](/Users/macbookpro/Development/recova-backend-v2/docs/operations/api-docs-generation.md)
- [Flow and Endpoint Audit (2026-05-14)](/Users/macbookpro/Development/recova-backend-v2/docs/operations/flow-and-endpoint-audit-2026-05-14.md)

Comment on lines 121 to 126
## Source Reference

Expand Down
42 changes: 23 additions & 19 deletions docs/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ reviewers:
doc_status: draft
source_repo: recova-backend-v2
source_path: docs/database.md
last_reviewed: 2026-05-09
last_reviewed: 2026-05-15
---

# Recova Backend Database
Expand All @@ -31,6 +31,7 @@ Entitas domain yang sudah teridentifikasi:
- ai coach chats
- daily motivations
- daily challenges
- daily physical challenges

## Ownership Boundary

Expand Down Expand Up @@ -59,7 +60,7 @@ CommunityPost
-> Comment (1:N)
-> Like (1:N)

Content (Education / Daily Motivation / Daily Challenge)
Content (Education / Daily Motivation / Daily Challenge / Daily Physical Challenge)
-> disajikan ke User melalui API read flows
```

Expand All @@ -71,31 +72,34 @@ Skema baseline SQL saat ini berada di migration:
- `migrations/20260508103000_create_auth_refresh_tokens.up.sql`
- `migrations/20260509100000_add_checkins_statistics_index.up.sql`
- `migrations/20260509113000_add_community_threaded_comments.up.sql`
- `migrations/20260512110000_add_manual_auth_columns.up.sql`
- `migrations/20260513101500_add_porn_free_goal_to_users.up.sql`

Tabel inti:

| Table | Purpose |
| ---------------------- | --------------------------------- |
| `users` | identitas akun pengguna |
| `profiles` | data onboarding/profile pengguna |
| `streaks` | histori streak pengguna |
| `check_ins` | catatan check-in harian |
| `journals` | jurnal pengguna |
| `community_posts` | posting komunitas |
| `community_comments` | komentar komunitas |
| `community_post_likes` | relasi like per pengguna-per-post |
| `education_contents` | konten edukasi aplikasi |
| `daily_motivations` | konten motivasi harian |
| `daily_challenges` | konten tantangan harian |
| `ai_chats` | histori chat AI per pengguna |
| `auth_refresh_tokens` | state refresh token ter-rotasi |
| Table | Purpose |
| --------------------------- | --------------------------------- |
| `users` | identitas akun pengguna |
| `profiles` | data onboarding/profile pengguna |
| `streaks` | histori streak pengguna |
| `check_ins` | catatan check-in harian |
| `journals` | jurnal pengguna |
| `community_posts` | posting komunitas |
| `community_comments` | komentar komunitas |
| `community_post_likes` | relasi like per pengguna-per-post |
| `education_contents` | konten edukasi aplikasi |
| `daily_motivations` | konten motivasi harian |
| `daily_challenges` | konten tantangan harian |
| `daily_physical_challenges` | konten tantangan fisik harian |
| `ai_chats` | histori chat AI per pengguna |
| `auth_refresh_tokens` | state refresh token ter-rotasi |

Constraint/index baseline:

- unique: `users.google_id`, `users.email`, `profiles.user_id`,
- unique: `users.google_id` (nullable), `users.email`, `users.username` (nullable), `profiles.user_id`,
- unique: `check_ins(user_id, check_in_date)`,
- unique: `journals.check_in_id`,
- unique: `daily_motivations.content`, `daily_challenges.content`,
- unique: `daily_motivations.content`, `daily_challenges.content`, `daily_physical_challenges(title, description)`,
- unique: `auth_refresh_tokens.token_hash`,
- FK seluruh child entity ke `users.id`,
- index agregasi utama: `ai_chats(user_id, created_at)`,
Expand Down
Loading
Loading