Platform: Next.js 14 (App Router) + Tailwind CSS v4 + TypeScript (Strict) Arsitektur: Feature-Sliced Design (FSD) — modular, scalable, future-proof Target: General-purpose web application foundation yang siap dikembangkan ke domain apapun
Repositori ini adalah starter foundation project — bukan template kosong, bukan production app, tapi sweet spot di tengah. Struktur sudah matang, boundary jelas, dokumentasi tersedia, dan siap untuk developer maupun AI coding agent.
| Teknologi | Fungsi | Alasan |
|---|---|---|
| Next.js 14 (App Router) | Routing, SSR, RSC, API Routes | Standard industri React framework |
| TypeScript (Strict) | Type safety | Zero tolerance untuk any |
| Tailwind CSS v4 | Styling | Utility-first, performant |
| Shadcn UI / Radix | Component primitives | Accessible, customizable, headless |
| TanStack React Query | Server state | Caching, deduplication, optimistic updates |
| Zustand | Client state | Ringan, no boilerplate |
| Zod | Validation | Type-safe runtime validation |
| next-intl | i18n | Standard untuk Next.js internasionalisasi |
| Vitest + Testing Library | Unit/integration test | Fast, modern, React-friendly |
| Playwright | E2E test | Reliable browser automation |
| Motion | Animasi | Declarative, performant |
Setiap fitur adalah module mandiri di src/features/. Module punya dependency sendiri (api, hooks, types, components) dan tidak boleh saling import secara langsung.
- Tulis type/interface sebelum implementasi
- Semua data yang masuk/keluar harus punya type
- Inferensi type lebih baik daripada explicit type di semua tempat
- UI layer: Hanya rendering, tidak ada business logic
- Logic layer: Hooks, services, utils — tidak ada JSX
- State layer: Zustand stores, React Query — tidak ada UI
- API layer: fetch, axios — tidak ada business logic
Setiap folder publik memiliki index.ts sebagai barrel export. Internal module tidak boleh di-import langsung dari file深处.
Import graph harus tetap DAG (Directed Acyclic Graph). Tidak boleh ada:
- Component import dari feature lain secara langsung
- Store import dari component
- Lib import dari utils (atau sebaliknya)
strict: truedi tsconfig- Dilarang menggunakan
as any,@ts-ignore,@ts-expect-errortanpa alasan tertulis - Gunakan
satisfiesoperator untuk validasi object literal - Utility types lebih baik daripada manual union types
| Entitas | Format | Contoh |
|---|---|---|
| Component file | kebab-case.tsx |
button.tsx, user-card.tsx |
| Component widgets | pascal-case.tsx |
Button.tsx, UserCard.tsx |
| Props type | XxxProps |
ButtonProps, UserCardProps |
| Type/Interface | XxxType / PascalCase |
UserType, ApiResponse |
| Hook | use-kebab-case.ts |
use-debounce.ts |
| Utility | kebab-case.ts |
format-date.ts |
| Store | kebab-case.ts |
auth-store.ts |
| API function | kebab-case.ts |
get-users.ts |
| Constants | UPPER_CASE |
MAX_RETRY_COUNT |
- Gunakan
@/alias, jangan relative path (../../) - Urutan import: (1) built-in, (2) eksternal, (3) internal, (4) relative
- Pisahkan import type dengan
import type { ... } - Barrel export hanya dari
index.ts, jangan dari file lain
- Tailwind CSS utility classes
- Hindari inline styles, CSS Modules, styled-components
- Gunakan
cn()utility dari@/utils/cnuntuk conditional classes - Komponen Shadcn UI bisa di-customize via
classNameprop
- Spesifik: Sebutkan file path, function name, dan expected behavior
- Contexual: Berikan referensi pattern yang sudah ada
- Boundary: Jelaskan scope — apa yang BOLEH dan TIDAK BOLEH diubah
- Verification: Sebutkan cara memverifikasi hasil (test command, typecheck, dll)
Task: [deskripsi singkat]
File: [path file yang diubah]
Pattern: [referensi pattern yang sudah ada]
Scope: [batasan perubahan]
Verify: [command untuk verifikasi]
- Setiap perubahan wajib di-review
- Ceklist review: type error?, logic error?, edge case terhandle?, test passing?
- Jangan deploy tanpa review
- Boleh: refactor, rename, extract function, add types, write tests
- Tidak boleh: ganti arsitektur tanpa approval, hapus folder existing, ubah konfigurasi inti
| Folder | Pemilik | Fungsi |
|---|---|---|
src/app/ |
Routing & Layout | Entry point, global layout, providers |
src/components/ui/ |
UI Kit | Atomic components (button, input, badge) |
src/components/layouts/ |
Layout | Header, footer, sidebar, container |
src/components/widgets/ |
Widgets | Composite components (card, modal, table) |
src/components/providers/ |
Providers | Theme, query, auth wrappers |
src/features/ |
Feature Module | Self-contained feature module |
src/config/ |
Configuration | env, site config, paths |
src/lib/ |
Integrations | API client, third-party wrappers |
src/hooks/ |
Shared Hooks | Generic reusable hooks |
src/utils/ |
Utilities | Pure functions, helpers |
src/types/ |
Global Types | Shared type definitions |
src/data/ |
Static Data | Constants, enums, mock data |
src/testing/ |
Test Setup | Test utilities, mocks, setup |
src/styles/ |
Styles | Global CSS, CSS variables |
src/i18n/ |
Internationalization | i18n config, routing, request |
.docs/ |
Engineering Docs | Architecture, decisions, guides |
Each feature should be self-contained:
src/features/awesome-feature/
├── api/ # API calls and hooks for this feature
├── components/ # Feature-specific components
├── hooks/ # Feature-specific hooks
├── data/ # Feature-specific data
├── shared/ # Feature-specific shared components/hooks/utils
├── stores/ # Feature-specific state
├── types/ # Feature-specific types
└── utils/ # Feature-specific utilities
- Semua dokumentasi WAJIB Bahasa Indonesia
- AGENTS.md di setiap folder penting — menjelaskan fungsi folder, aturan, boundary
.docs/untuk engineering documentation — architecture decision records, design docs, technical guides- README.md untuk onboarding — cara setup, develop, build, deploy
- CHANGELOG.md untuk catatan perubahan — format Keep a Changelog
- Jangan gunakan emoji di dokumentasi teknis
- Tone: professional, clean, practical, engineering-focused
# Setup
bun install # Install dependencies
bun dev # Start development server
# Quality Gates
bun check-types # TypeScript type checking
bun lint # ESLint
bun format # Prettier
bun test # Vitest (unit + integration)
# Build
bun build # Production build- Pre-commit: lint-staged (ESLint + Prettier)
- Pre-push: typecheck + test
Semua harus lolos sebelum push.
main— production-readyfeat/*— fitur barufix/*— bug fixrefactor/*— refactoringdocs/*— dokumentasi
Gunakan Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
feat: Fitur barufix: Bug fixrefactor: Refactoring (bukan fitur/fix)docs: Dokumentasichore: Build, config, toolingstyle: Formatting (bukan logic change)test: Test (tambah/ubah)perf: Performance improvement
ui: component, stylingapi: api integrationhooks: custom hooksstore: state managementconfig: configurationi18n: internationalizationtypes: type definitions
feat(auth): add login with email/password
fix(ui): resolve button overflow on mobile
refactor(hooks): extract use-debounce to shared hooks
docs(api): update endpoint documentation- Unit test: Setiap utility function, hook, dan komponen murni
- Integration test: Alur utama aplikasi (login, CRUD, navigasi)
- E2E test: Critical path dengan Playwright
- Coverage minimal: 70% (unit + integration)
- Setiap komponen HTML semantic (button, nav, main, section)
- Keyboard navigasi berfungsi
- Focus trap untuk modal/dialog
- Screen reader friendly (aria-label, role)
- Gambar pakai
next/image - Dynamic import untuk komponen berat
- React.memo untuk list items
- Debounce/throttle untuk event berat (scroll, resize, search)
- Setiap API call punya error boundary
- User-facing error messages harus informatif
- Global error boundary di layout
- Sentry atau error tracking (opsional)
- Buat folder di
src/features/<nama-feature>/ - Struktur:
api/,components/,hooks/,stores/,types/,utils/ - Tambah route di
src/app/(App Router) - Export dari
index.ts - Test feature secara independen
- Buat folder di
src/app/<route>/ - Buat
page.tsx,layout.tsxjika perlu - Gunakan komponen dari feature modules
- Komponen atomik →
src/components/ui/ - Komponen komposit →
src/components/widgets/ - Komponen spesifik feature →
src/features/<feature>/components/
- Buat file di
src/app/api/<route>/route.ts - Export GET, POST, PUT, PATCH, DELETE handler
- Validasi input dengan Zod
- Duplikasi kode > 3 kali
- Function terlalu panjang (> 50 baris)
- Component terlalu banyak responsibility
- Import graph mulai complex
- Test sulit ditulis karena coupling
- Jangan ubah API interface yang sudah dipakai
- Jangan ubah struktur folder tanpa approval
- Jangan hapus file existing — deprecate dulu
- Satu refactor = satu PR
- Update AGENTS.md yang terdampak
- Update CHANGELOG.md
- Beri komentar di kode jika ada breaking change
- Pastikan semua test tetap passing
- Module independence: Setiap feature bisa di-develop, di-test, di-deploy secara independen
- Lazy by default: Import berat pakai
next/dynamic, query besar pakai pagination - Caching strategy: React Query untuk server state, Zustand persist untuk client state
- API abstraction: Semua external API lewat
src/lib/, bukan langsung di komponen - Type safety: Zod untuk runtime validation, TypeScript untuk compile-time safety
- Monitoring: Error boundary di setiap layer, logging terstruktur
Handbook ini hidup — update jika ada keputusan arsitektur baru.