first commit

This commit is contained in:
ExtraNetwork
2026-05-12 17:04:54 +03:00
commit e5c4b6aa13
1425 changed files with 284735 additions and 0 deletions

391
API_FLOW.md Normal file
View File

@@ -0,0 +1,391 @@
# API Akış Şeması — ExtraNetWork
300+ endpoint, 60+ controller, 9 channel manager entegrasyonu, 3 metasearch entegrasyonu.
---
## 1. Middleware Zinciri
```mermaid
graph LR
A[Client] --> B[cors]
B --> C[LanguageSetting]
C --> D{Public?}
D -->|Evet| Z[Controller]
D -->|Hayır| E[jwt.auth]
E --> F[userRoutePermissionAuthorize]
F --> G[property]
G --> H{Wizard gerekli mi?}
H -->|Evet| I[contentWizard]
H -->|Hayır| J{Channel sync?}
I --> J
J -->|Evet| K[checkPropertyChannelConnection]
J -->|Hayır| Z
K --> Z
Z --> S[Service]
S --> R[Repository]
R --> DB[(MySQL)]
```
| Middleware | Amaç |
| -------------------------------- | ---------------------------------------------- |
| `cors` | CORS başlıkları |
| `LanguageSetting` | TR/EN/DE dil seçimi |
| `jwt.auth` | JWT + `api_access_token` doğrulama |
| `userRoutePermissionAuthorize` | RBAC permission kontrolü |
| `property` | `user_property_mapping` ile property ownership |
| `contentWizard` | Onboarding tamamlanma kontrolü |
| `checkPropertyChannelConnection` | Channel bağlantı durumu |
| `bookingEngineToken` | BookingEngine widget token |
| `myWebToken` | MyWeb template token |
---
## 2. Genel Request Lifecycle
```mermaid
sequenceDiagram
participant C as Client
participant MW as Middleware Stack
participant Ctrl as Controller
participant Svc as Service
participant Repo as Repository
participant DB as MySQL
C->>MW: HTTP + authToken
MW->>MW: cors → lang → jwt → permission → property → wizard
MW->>Ctrl: Request + credentials + property
Ctrl->>Ctrl: Validator->validate(params)
Ctrl->>Svc: business call
Svc->>Repo: findByCriteria / create / update
Repo->>DB: SQL
DB-->>Repo: rows
Repo-->>Svc: data
Svc-->>Ctrl: ['status','data','message']
Ctrl-->>C: apiResponse(status, message, data, code)
```
---
## 3. Auth Akışı (Login / Refresh / Logout)
```mermaid
sequenceDiagram
participant U as User
participant A as AuthController
participant J as JwtService
participant T as ApiAccessTokenService
participant M as UserPropertyMappingService
participant DB
U->>A: POST auth/login {email, password, remember_me}
A->>DB: user where email & status=1
A->>A: Hash::check
A->>J: jwtCreate(user_id, remember_me, day_counter=5)
J-->>A: {token, exp}
A->>T: create({token: md5(jwt), expire_date, user_id, invalidate=0})
A->>M: select(user_property_mapping where user_id, status=1)
M-->>A: property_list
A-->>U: {token, expire_time, locale, property_list, user}
Note over U,A: Refresh
U->>A: GET auth/refresh-token (authToken header)
A->>T: token bul (md5, expire>now, invalidate=0)
A->>J: jwtCreate(day_counter=0.5)
A->>T: update aynı token row
A-->>U: {new token, expire_time}
Note over U,A: Logout
U->>A: POST logout (authToken header)
A->>T: update invalidate=1
A-->>U: 200 Logged out
```
---
## 4. Property Erişim Kontrolü
```mermaid
graph TD
A[Request + property_id] --> B[jwt.auth ✓]
B --> C[userRoutePermissionAuthorize]
C -->|permission yok| X[403]
C --> D[PropertyMiddleware]
D --> E{user_property_mapping<br/>user_id+property_id+status=1}
E -->|yok| X
E --> F{Wizard route?}
F -->|Evet| G{property.wizard_status<br/>= complete?}
G -->|Hayır| Y[422 Wizard incomplete]
G --> H[Controller]
F -->|Hayır| H
H --> I[Service: property_id ile scope]
I --> J[(DB)]
```
---
## 5. Booking Lifecycle (BookingEngine)
```mermaid
sequenceDiagram
participant G as Guest
participant BE as BookingEngine Widget
participant API as BookingEngine\BookingController
participant Inv as Inventory/Rate
participant Pay as PaymentLinkController
participant DB
G->>BE: arama (checkin/checkout, pax)
BE->>API: POST /v1/search
API->>Inv: availability + rates
Inv->>DB: property_room_rate_mapping + availability
API-->>BE: rate listesi
G->>BE: oda seç
BE->>API: POST /v1/booking
API->>DB: insert booking + booking_contact + booking_room + booking_room_pax
API-->>BE: booking_code (status=2 Pending)
G->>BE: ödemeyi onayla
BE->>API: POST /v1/bookingConfirm
API->>Pay: paymentLinkInitialize
Pay->>DB: insert payment_transaction (status=2 Start)
Pay-->>BE: redirect URL
G->>Pay: 3D Secure / POS
Pay->>API: callback /paymentRedirect/{code}
API->>DB: payment_transaction.status=1, booking.status=1
API->>API: send confirmation email
API-->>G: confirmation page
```
**Status kodları:**
- `booking.status`: 0=İptal/Refund, 1=Confirmed, 2=Pending
- `booking_payment.status`: 0=İptal, 1=Confirmed, 2=Pending
- `payment_transaction.status`: 0=Error, 1=Success, 2=Start, 3=Pending, 4=Cancel/Refund, 5=Manual
---
## 6. Channel Sync Akışı
```mermaid
graph TD
A[Property Manager] -->|property/property-channel-mapping/add| B[PropertyChannelMappingController]
B --> C[(property_channel_mapping)]
C --> D[Job: PropertyCatalogServiceJob]
D --> E{Channel?}
E -->|Reseliva| R1[ChannelManager/Reseliva]
E -->|Channex| R2[ChannelManager/Channex]
E -->|HotelRunner| R3[ChannelManager/HotelRunner]
E -->|ElektraWeb| R4[ChannelManager/ElektraWeb]
E -->|Athena/Fina/SistemOtel/1C/HyperGuest| R5[Diğer Adapters]
R1 & R2 & R3 & R4 & R5 --> X[Remote Channel API]
X --> L[Sync log + status update]
L --> N[Dashboard'da görünür]
```
---
## 7. Inventory & Rate Update (Channel-Connection-Protected)
```mermaid
sequenceDiagram
participant M as Manager
participant API as PropertyRoomRateMappingController
participant CC as checkPropertyChannelConnection
participant DB
participant Ch as Remote Channel
M->>API: POST property/room-rate-mapping/bulk-update
API->>CC: Channel bağlı mı?
CC->>DB: property_channel_mapping.status
alt Bağlı değil
CC-->>M: 403 Channel disconnected
else Bağlı
API->>DB: update room_rate_mapping (price/availability)
API->>Ch: push update
Ch-->>API: ack
API-->>M: success
end
```
---
## 8. Wizard Onboarding
```mermaid
graph TD
A[property/create] --> B[(property: wizard incomplete)]
B --> C1[contact/update]
B --> C2[room/add-room-bed]
B --> C3[room-fact-mapping/update]
B --> C4[room-photo-mapping/update]
B --> C5[awards-certificates/list]
B --> C6[fact/get-subcategory-facts]
B --> C7[executive/list]
C1 & C2 & C3 & C4 & C5 & C6 & C7 --> D[property/update/content-code]
D --> E[(wizard_status = complete)]
E --> F[Diğer property endpoint'leri açılır]
```
---
## 9. Web Site Builder (MyWeb)
```mermaid
sequenceDiagram
participant M as Manager
participant API as PropertyWebController
participant DB
participant FS as FileStorage/CDN
participant V as Visitor
participant MyW as MyWebContentController
M->>API: web/create → property_web
M->>API: web/update-content → component & content
M->>API: web/meta-tag/sync
M->>API: web/popup/create
M->>API: web/publish → status=PUBLISHED
API->>FS: assets
V->>MyW: web/home (myWebToken)
MyW->>DB: property_web_content + components
MyW-->>V: render data (frontend tarafı şablonlar)
```
---
## 10. Reputation Management
```mermaid
graph TD
A[reputation-management/channel/get] --> B[(reputation_channels)]
A --> C[reputation-management/channel/sync]
C --> J[Job: PropertyReviewServiceJob]
J --> D{Source}
D -->|TripAdvisor| T[TripAdvisor API]
D -->|Google| G[Google Places API]
D -->|Booking| BK[Booking API]
T & G & BK --> R[(reviews)]
R --> AN[Job: PropertyReviewAnalyzeServiceJob<br/>NLP/sentiment]
AN --> S[(review_statistics)]
S --> RS[reputation-management/review/statistics]
```
---
## 11. CPA (Competitor Price Analysis)
```mermaid
graph TD
A[cpa/property/competitor/create] --> B[(property_competitors)]
B --> C[cpa/property/competitor/sync]
C --> D[Crawler/OTA API]
D --> E[(competitor_prices günlük)]
E --> F[cpa/property/competitor/analysis]
F --> G[cpa/property/best-available-price]
F --> H[cpa/property/promotion-available]
F --> I[cpa/property/quick-pricing/rate]
G & H & I --> J[Manager dashboard önerileri]
```
---
## 12. Endpoint Domain Özet Tablosu
| # | Domain | Controller(lar) | Endpoint | Açıklama |
| --: | ------------------- | ----------------------------------------------------- | -------: | ------------------------------------------------------------------------------------ |
| 1 | Auth | AuthController | 3 | login / refresh / logout |
| 2 | User | UserController | 17 | register, profile, password, mapping |
| 3 | Property | PropertyController | 12 | CRUD + dashboard + raporlar |
| 4 | Property Info | Contact, Brand, Config, Executive | 14 | Detay bilgi yönetimi |
| 5 | Content | Content, Fact, FactMapping, AdditionalInfo | 11 | Property metadata |
| 6 | Photo | PropertyPhoto + Category + Mapping | 11 | Foto yönetimi & CDN |
| 7 | Place | PropertyPlaceController | 15 | Tesis içi yer/alan |
| 8 | Awards | PropertyAwardCertificates | 5 | Sertifikalar |
| 9 | Room | PropertyRoom + Type/View/Bed/Size | 20+ | Oda yapısı |
| 10 | Rate | PropertyRoomRate + Mapping/Channel/Setup/Inclusion | 27 | Rate & inventory |
| 11 | Channel | PropertyChannel + Mapping/Group/Contact/Category | 23 | OTA dağıtım |
| 12 | Cancellation Policy | PropertyCancellationPolicy | 5 | İptal kuralları |
| 13 | Pricing Policy | PropertyPersonPricingPolicy | 7 | Yetişkin/çocuk fiyat |
| 14 | Booking | PropertyBookingController + Ticket | 11 | Rezervasyon ops |
| 15 | Payment | PaymentController + PaymentLink | 16 | Ödeme + manual link + taksit |
| 16 | Offer | PropertyOfferController | 11 | Teklif yönetimi |
| 17 | Promotion | PropertyPromotionController | 7 | Promosyon & kampanya |
| 18 | Coupon/Addon | PropertyCoupon + Addon | 4 | Ek ürün/kupon |
| 19 | CPA | CompetitorPriceAnalysis + Group + QuickPricing | 15+ | Rakip analizi |
| 20 | Web Builder | PropertyWebController + Content/Popup/Component | 30+ | Website yönetimi |
| 21 | MyWeb | MyWebContentController | 22+ | Public site render |
| 22 | Booking Engine | BookingEngine\BookingController + Search | 17 | Embedded widget |
| 23 | Channel Manager | 9 entegrasyon adapter'ı | 21 | Reseliva, Channex, HotelRunner, ElektraWeb, Athena, Fina, SistemOtel, 1C, HyperGuest |
| 24 | MetaSearch | Trivago, Yandex, Google | 8 | Meta arama |
| 25 | Reputation | ReputationManagementController | 4 | Yorum & istatistik |
| 26 | AI | AIController | 1 | OpenAI |
| 27 | Export | ExportPdfController | 5 | PDF/Excel |
| 28 | Utility | Language, Currency, Destination, Chain, Test, Contact | 11 | Referans veri |
**Toplam:** ~300+ endpoint, ~60 controller dosyası.
---
## 13. Auth Header Konvansiyonu
| Tip | Header | Doğrulayan |
| --------------- | ----------------------------- | ------------------------------ |
| App API | `authToken: <jwt>` | `JwtMiddleware` |
| BookingEngine | `bookingEngineToken: <token>` | `BookingEngineTokenMiddleware` |
| MyWeb | `myWebToken: <token>` | `MyWebTokenMiddleware` |
| Channel Manager | partner-specific header | İlgili adapter |
---
## 14. Body Konvansiyonu
| Endpoint Tipi | Body Şeması |
| ------------------ | -------------------------------------------------------------------------- |
| Login | `{ "email", "password", "remember_me", "locale", "onesignal_key" }` (flat) |
| Tüm App API (POST) | `{ "params": { ... } }` (controller'lar `$this->request->params` okur) |
| BookingEngine | `{ "params": { ... } }` veya path param |
| ChannelManager | adapter'a özel JSON şeması |
---
## 15. Asenkron Olaylar (Queue Driver: database)
| Job | Tetikleyici | Görev |
| --------------------------------- | ----------------------- | ---------------- |
| `PropertyCatalogServiceJob` | property/channel update | Catalog senkronu |
| `PropertyReviewServiceJob` | reputation sync | Review fetch |
| `PropertyReviewAnalyzeServiceJob` | review save | NLP/sentiment |
| `SlackLogJob` | sistem logu | Slack bildirim |
Mail kuyrukları: `userCreateMail`, `UserForgotPassword`.
---
## 16. Status Kodları Özeti
| Tablo | Alan | Değerler |
| ------------------- | ---------- | --------------------------------------------------------------- |
| user | status | 0 inaktif / 1 aktif |
| user | user_type | 0 normal / 1 admin |
| api_access_token | invalidate | 0 geçerli / 1 iptal |
| booking | status | 0 İptal / 1 Onaylı / 2 Pending |
| booking_payment | status | 0 İptal / 1 Onaylı / 2 Pending |
| payment_transaction | status | 0 Error / 1 Success / 2 Start / 3 Pending / 4 Cancel / 5 Manual |
| property | status | 0 inaktif / 1 aktif |
---
## 17. Hızlı Bakış: Tipik İstek Hayatı
```
1. Client → POST /app/v1/property/info/get (Header: authToken)
2. cors → LanguageSetting → jwt.auth → userRoutePermissionAuthorize → property
3. PropertyController@getProperty
4. PropertyService->select(criteria scoped to property_id)
5. PropertyRepository->findByCriteria
6. MySQL property + relations (with: 'propertyContact', 'propertyType', ...)
7. apiResponse(1, null, $data, 200)
```