# Apper Note - Proje Yapısı

Son Güncelleme: 2025-11-22

## 📁 Dizin Yapısı

### Backend (Laravel 11)

```
app/
├── Actions/
│   ├── Fortify/          # Laravel Fortify authentication actions
│   └── Jetstream/        # Jetstream team actions
│
├── Console/
│   └── Kernel.php        # Console kernel
│
├── Exceptions/
│   └── Handler.php       # Exception handler
│
├── Http/
│   ├── Controllers/
│   │   ├── NoteController.php     # Not CRUD işlemleri
│   │   └── CaptureController.php  # Fotoğraf yakalama
│   │
│   ├── Middleware/
│   │   └── CheckUserAccess.php    # Kullanıcı erişim kontrolü
│   │
│   └── Kernel.php        # HTTP kernel
│
├── Livewire/             # Livewire Components ⚡
│   ├── AllNotes.php      # Ana not listesi component (ANA SAYFA)
│   ├── NoteForm.php      # Not oluşturma/düzenleme formu
│   └── NoteModal.php     # Not detay modal
│
├── Models/               # Eloquent Models
│   ├── Note.php          # Not model
│   ├── Label.php         # Etiket model
│   ├── Company.php       # Şirket model
│   ├── User.php          # Kullanıcı model
│   ├── Team.php          # Takım model
│   ├── Color.php         # Renk model
│   ├── NoteLabel.php     # Not-Etiket pivot
│   ├── NoteCompany.php   # Not-Şirket pivot
│   └── NoteUser.php      # Not-Kullanıcı pivot
│
├── Policies/
│   └── TeamPolicy.php    # Takım yetkilendirme
│
├── Providers/            # Service Providers
│   ├── AppServiceProvider.php
│   ├── AuthServiceProvider.php
│   ├── FortifyServiceProvider.php
│   ├── JetstreamServiceProvider.php
│   └── RouteServiceProvider.php
│
├── Scopes/
│   └── CurrentTeamScope.php  # Global scope for team filtering
│
└── View/
    └── Components/       # Blade components (yardımcı)
```

### Frontend

```
resources/
├── css/
│   └── app.css          # Tailwind CSS ana dosya
│
├── js/
│   ├── app.js           # Ana JavaScript dosyası
│   │                    # Alpine.js entegrasyonu (Livewire ile)
│   │                    # Bootstrap import
│   │
│   └── note-dnd.js      # Drag & Drop fonksiyonları
│                        # handleDragStart()
│                        # handleDrop()
│                        # handleDragOver()
│                        # handleDragLeave()
│
├── views/
│   ├── livewire/        # Livewire Component Views
│   │   ├── all-notes.blade.php  # Ana not listesi UI ⭐
│   │   ├── note-form.blade.php  # Not formu
│   │   └── note-modal.blade.php # Not modal
│   │
│   ├── layouts/
│   │   └── app.blade.php        # Ana layout template
│   │
│   ├── components/      # Blade Components
│   │   ├── input.blade.php
│   │   ├── button.blade.php
│   │   ├── label.blade.php
│   │   ├── modal.blade.php
│   │   └── notification.blade.php
│   │
│   ├── dashboard.blade.php      # Dashboard (sadece @livewire('all-notes'))
│   └── welcome.blade.php        # Landing page
│
└── markdown/            # Markdown dosyaları
```

### Configuration

```
config/
├── app.php              # Uygulama ayarları
├── auth.php             # Authentication
├── database.php         # Veritabanı bağlantıları
├── jetstream.php        # Jetstream ayarları
├── session.php          # Session yapılandırması
└── vite.php             # Vite build ayarları
```

### Database

```
database/
├── factories/
│   ├── UserFactory.php
│   └── TeamFactory.php
│
├── migrations/          # Veritabanı migration'ları
│   ├── ..._create_users_table.php
│   ├── ..._create_notes_table.php
│   ├── ..._create_labels_table.php
│   ├── ..._create_companies_table.php
│   ├── ..._create_note_label_table.php
│   ├── ..._create_note_company_table.php
│   └── ..._create_sessions_table.php
│
└── seeders/
    └── DatabaseSeeder.php
```

### Routes

```
routes/
├── web.php              # Web routes (dashboard, note CRUD)
├── api.php              # API routes (şu an kullanılmıyor)
└── channels.php         # Broadcasting channels
```

### Public & Build

```
public/
├── index.php            # Laravel entry point
├── robots.txt
└── build/               # Vite build output
    ├── manifest.json
    └── assets/
        ├── app-DKlqGNSx.css  (992 KB)
        └── app-B6lK8SpZ.js   (45 KB)
```

### Storage

```
storage/
├── app/                 # Uygulama dosyaları
├── framework/           # Framework cache/session
│   ├── cache/
│   ├── sessions/
│   └── views/           # Blade compiled views
└── logs/                # Log dosyaları
    └── laravel.log
```

## 🎯 Ana Akış (Flow)

### Kullanıcı İşlem Akışı

```
1. Giriş Yapma
   └─> Login Form (Fortify)
       └─> CheckUserAccess Middleware
           └─> Dashboard (/dashboard)

2. Dashboard
   └─> @livewire('all-notes')
       └─> AllNotes.php Component
           ├─> Notları listele (filteredNotes)
           ├─> Etiket arama (searchText, labels)
           ├─> Şirket arama (companySearchText, filteredCompanies)
           └─> Drag & Drop (note-dnd.js)

3. Not İşlemleri
   ├─> Yeni Not: @livewire('note-modal')
   ├─> Not Düzenle: openNoteModal event
   ├─> Not Sil: deleteNote($noteId)
   └─> Pin/Unpin: pinNote($noteId)

4. Etiket/Şirket İşlemleri
   ├─> Drag & Drop: handleDrop() → Livewire.dispatch()
   ├─> Etiket Arama: wire:model.live="searchText"
   └─> Şirket Arama: wire:model.live="companySearchText"
```

### Veri Akışı

```
Database → Model → Livewire Component → Blade View → Browser
    ↑                                        ↓
    └────────── User Interaction ───────────┘
                (wire:click, wire:model)
```

## 🔧 Önemli Dosyalar

### Ana Component (AllNotes.php)

**Lokasyon**: `app/Livewire/AllNotes.php`

**Sorumluluklar**:
- Tüm notları listeleme
- Arama ve filtreleme
- CRUD işlemleri
- Etiket/Şirket yönetimi
- Drag & Drop event handling

**Önemli Metodlar**:
```php
loadNotes()                  // Notları yükle
getFilteredNotesProperty()   // Arama ile filtrelenmiş notlar
getFilteredCompaniesProperty() // Filtrelenmiş şirketler
pinNote($noteId)             // Not sabitleme
deleteNote($noteId)          // Not silme
addLabelToNote()             // Etiket ekleme
addCompanyToNote()           // Şirket ekleme
toggleLabelSearch()          // Etiket arama toggle
toggleCompanySearch()        // Şirket arama toggle
```

**Public Properties**:
```php
$notes_all         // Tüm notlar
$labels            // Tüm etiketler
$companies         // Tüm şirketler
$searchQuery       // Not arama query
$searchText        // Etiket arama text
$companySearchText // Şirket arama text
$showLabelSearch   // Etiket arama gösterimi
$showCompanySearch // Şirket arama gösterimi
```

### Ana View (all-notes.blade.php)

**Lokasyon**: `resources/views/livewire/all-notes.blade.php`

**Bölümler**:
1. **Loading Indicator**: Livewire işlemler için
2. **Toast Notifications**: Success/Error/Info mesajları
3. **Arama**: Ctrl+K ile hızlı arama
4. **Sabitlenmiş Notlar**: is_pinned = true
5. **Diğer Notlar**: is_pinned = false
6. **Alttaki Bar**: Etiket ve şirket drag-drop

**Önemli Özellikler**:
- Masonry layout (columns-1 md:columns-2 lg:columns-3)
- Drag & Drop entegrasyonu
- Real-time search (wire:model.live)
- Dynamic Tailwind classes (safelist ile)
- Toast notifications (Alpine.js)

### Drag & Drop (note-dnd.js)

**Lokasyon**: `resources/js/note-dnd.js`

**Fonksiyonlar**:
```javascript
handleDragStart(event, itemId, type)  // Drag başlatma
handleDrop(event, noteId)             // Drop işlemi
handleDragOver(event)                 // Drag over styling
handleDragLeave(event)                // Drag leave cleanup
```

**Livewire Events**:
```javascript
window.Livewire.dispatch('add-label-to-note', {
    noteId: noteId,
    labelId: draggedItemId
})

window.Livewire.dispatch('add-company-to-note', {
    noteId: noteId,
    companyId: draggedItemId
})
```

## 🗄️ Veritabanı Şeması

### Temel Tablolar

**notes**
- id, title, content
- color (tailwind color name)
- is_pinned, is_active
- tool (default: 'note')
- current_team_id (multi-tenant)
- user_id, created_at, updated_at

**labels**
- id, name, color
- tool, type
- is_active
- current_team_id, user_id

**companies**
- id, name, description
- current_team_id, user_id

### İlişki Tabloları

**note_label** (Many-to-Many)
- note_id, label_id

**note_company** (Many-to-Many)
- note_id, company_id

**note_user** (Many-to-Many)
- note_id, user_id

## 🎨 Styling

### Tailwind Configuration

**Lokasyon**: `tailwind.config.js`

**Safelist** (Dinamik Classlar):
```javascript
safelist: [
  {
    pattern: /bg-(slate|gray|zinc|...|rose)-(50|100|...|900)/
  },
  {
    pattern: /text-(slate|gray|zinc|...|rose)-(50|100|...|900)/
  },
  {
    pattern: /border-(slate|gray|zinc|...|rose)-(50|100|...|900)/
  },
  {
    pattern: /ring-(slate|gray|zinc|...|rose)-(50|100|...|900)/
  }
]
```

**Plugins**:
- @tailwindcss/forms
- @tailwindcss/typography

## 🔌 Bağımlılıklar

### Composer (PHP)
```json
{
  "laravel/framework": "^11.0",
  "laravel/jetstream": "^5.0",
  "livewire/livewire": "^3.0"
}
```

### NPM (JavaScript)
```json
{
  "vite": "^5.3.5",
  "tailwindcss": "^3.1.0",
  "alpinejs": "^3.15.2",
  "axios": "^1.7.7"
}
```

## 📝 Önemli Notlar

### Livewire 3 Değişiklikleri
- ❌ `Livewire.emit()` → ✅ `window.Livewire.dispatch()`
- ❌ `@livewire('component', ['param' => $value])` → ✅ Computed properties kullan
- ❌ `$emit()` → ✅ `$dispatch()`
- Event parametreleri artık object olarak: `{noteId: 1, labelId: 2}`

### Multi-Tenant Yapı
- Her model `CurrentTeamScope` kullanıyor
- `current_team_id` filtrelemesi otomatik
- Jetstream Teams entegrasyonu

### Session Yönetimi
- Driver: `database`
- Table: `sessions`
- Lifetime: 525600 (1 yıl)

### Deployment
- Local: Herd (http://note.apper.test)
- Remote: Contabo (167.86.89.222)
- SFTP: VS Code SFTP Extension
- Build: `npm run build` → `public/build/`

## 🚀 Gelecek Planlar

### Yakın Gelecek
- [ ] Not versiyonlama
- [ ] Not şablonları
- [ ] Gelişmiş arama (full-text)
- [ ] Export/Import (JSON, PDF)

### Orta Vadeli
- [ ] Real-time collaboration
- [ ] Zengin metin editörü (TinyMCE entegrasyonu)
- [ ] Dosya ekleri
- [ ] Yorumlar

### Uzun Vadeli
- [ ] Mobile app (Flutter/React Native)
- [ ] API için OAuth2
- [ ] Webhook entegrasyonları
- [ ] AI destekli not önerileri
