250 lines
4.5 KiB
Markdown
250 lines
4.5 KiB
Markdown
# RayLab Core Phase 7 --- Project Structure
|
|
|
|
## Tujuan
|
|
|
|
Fase 7 mendefinisikan struktur repository, organisasi source code, serta
|
|
standar penempatan file pada RayLab Core. Tujuannya adalah memastikan
|
|
seluruh kode memiliki pola yang konsisten sehingga mudah dipelihara,
|
|
dikembangkan, dan dipahami.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Prinsip
|
|
|
|
- Struktur mengikuti domain bisnis.
|
|
- Setiap module berdiri sendiri.
|
|
- Konfigurasi dipisahkan dari business logic.
|
|
- Dokumentasi menjadi bagian dari repository.
|
|
- Mudah diskalakan tanpa mengubah struktur dasar.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Struktur Repository
|
|
|
|
``` text
|
|
raylab-core/
|
|
│
|
|
├── docs/
|
|
├── docker/
|
|
├── prisma/
|
|
├── scripts/
|
|
├── tests/
|
|
├── src/
|
|
├── .env.example
|
|
├── .gitignore
|
|
├── docker-compose.yml
|
|
├── package.json
|
|
├── tsconfig.json
|
|
└── README.md
|
|
```
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Struktur Source Code
|
|
|
|
``` text
|
|
src/
|
|
│
|
|
├── main.ts
|
|
├── app.module.ts
|
|
├── common/
|
|
├── config/
|
|
├── modules/
|
|
├── adapters/
|
|
└── shared/
|
|
```
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Common
|
|
|
|
Berisi komponen yang digunakan lintas modul.
|
|
|
|
Contoh:
|
|
|
|
- Guards
|
|
- Filters
|
|
- Interceptors
|
|
- Middleware
|
|
- Logger
|
|
- Exceptions
|
|
- Decorators
|
|
- Pipes
|
|
- Utilities
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Config
|
|
|
|
Berisi konfigurasi aplikasi.
|
|
|
|
Contoh:
|
|
|
|
- Database
|
|
- Redis
|
|
- JWT
|
|
- Environment
|
|
- Swagger
|
|
|
|
Seluruh konfigurasi diakses melalui ConfigService.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Modules
|
|
|
|
Setiap domain memiliki module sendiri.
|
|
|
|
``` text
|
|
modules/
|
|
├── identity/
|
|
├── authorization/
|
|
├── registry/
|
|
├── configuration/
|
|
├── storage/
|
|
├── media/
|
|
├── audit/
|
|
├── dashboard/
|
|
└── health/
|
|
```
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Struktur Internal Module
|
|
|
|
``` text
|
|
identity/
|
|
│
|
|
├── controllers/
|
|
├── services/
|
|
├── domain/
|
|
├── repositories/
|
|
├── dto/
|
|
├── entities/
|
|
├── interfaces/
|
|
├── mappers/
|
|
├── events/
|
|
└── identity.module.ts
|
|
```
|
|
|
|
Seluruh file yang berkaitan dengan satu domain berada dalam module yang
|
|
sama.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Adapters
|
|
|
|
Seluruh integrasi eksternal ditempatkan pada folder adapters.
|
|
|
|
``` text
|
|
adapters/
|
|
├── nextcloud/
|
|
├── jellyfin/
|
|
├── immich/
|
|
├── minecraft/
|
|
└── ...
|
|
```
|
|
|
|
Adapter tidak menyimpan business logic.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Prisma
|
|
|
|
``` text
|
|
prisma/
|
|
├── schema.prisma
|
|
├── migrations/
|
|
└── seed.ts
|
|
```
|
|
|
|
Seluruh perubahan database dilakukan melalui migration.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Tests
|
|
|
|
``` text
|
|
tests/
|
|
├── unit/
|
|
├── integration/
|
|
└── e2e/
|
|
```
|
|
|
|
Pengujian dipisahkan berdasarkan jenisnya.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Dokumentasi
|
|
|
|
``` text
|
|
docs/
|
|
├── architecture/
|
|
├── adr/
|
|
├── api/
|
|
├── modules/
|
|
└── guides/
|
|
```
|
|
|
|
Dokumentasi menjadi bagian dari source repository dan diperbarui
|
|
bersamaan dengan perubahan kode.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Naming Convention
|
|
|
|
## Folder
|
|
|
|
Menggunakan huruf kecil.
|
|
|
|
Contoh:
|
|
|
|
``` text
|
|
identity
|
|
authorization
|
|
media
|
|
```
|
|
|
|
## File
|
|
|
|
Menggunakan nama yang deskriptif.
|
|
|
|
Contoh:
|
|
|
|
``` text
|
|
create-user.dto.ts
|
|
user.repository.ts
|
|
users.controller.ts
|
|
```
|
|
|
|
## Class
|
|
|
|
Menggunakan PascalCase.
|
|
|
|
Contoh:
|
|
|
|
``` text
|
|
UsersController
|
|
CreateUserDto
|
|
UserRepository
|
|
```
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Aturan Penempatan Kode
|
|
|
|
- Controller hanya berada di folder controllers.
|
|
- DTO hanya berada di folder dto.
|
|
- Entity hanya berada di folder entities.
|
|
- Repository hanya berada di folder repositories.
|
|
- Business logic berada di services dan domain.
|
|
- Integrasi eksternal berada di adapters.
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
# Hasil Akhir Fase 7
|
|
|
|
Pada akhir fase ini, RayLab Core memiliki struktur repository dan
|
|
organisasi kode yang baku. Setiap developer dapat mengetahui lokasi
|
|
suatu komponen tanpa perlu menebak, sehingga pengembangan jangka panjang
|
|
tetap konsisten dan mudah dipelihara.
|