first commit
This commit is contained in:
75
docs/ADMIN_PANEL_PLAN.md
Normal file
75
docs/ADMIN_PANEL_PLAN.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Admin Panel Baslangic Plani
|
||||
|
||||
Bu plan `AGENTS.md`, `ADMIN_PANEL_PROMPT.md` ve `RULES.md` uyumunda hazirlandi.
|
||||
|
||||
## 1) Onerilen Klasor Yapisi
|
||||
|
||||
- `admin-panel/src/api`
|
||||
- `admin-panel/src/components`
|
||||
- `admin-panel/src/pages`
|
||||
- `admin-panel/src/stores`
|
||||
- `admin-panel/src/types`
|
||||
- `admin-panel/src/utils`
|
||||
|
||||
## 2) Teknoloji Onerisi
|
||||
|
||||
- React + TypeScript + Vite
|
||||
- React Router (route guard)
|
||||
- TanStack Query (server state)
|
||||
- Zustand (auth/UI state)
|
||||
|
||||
## 3) Ekran Akislari
|
||||
|
||||
- `GET /login` -> basarili login -> `/dashboard`
|
||||
- `GET /dashboard` -> ozet kartlar + son image bilgisi
|
||||
- `GET /images` -> liste + detay linki
|
||||
- `GET /images/:id` -> variant stream preview
|
||||
- `GET /health` -> backend durum gostergesi
|
||||
- `GET /settings` -> altyapi/TODO
|
||||
|
||||
## 4) Auth ve API Client Mimarisi
|
||||
|
||||
- Merkezi `apiRequest` fonksiyonu ile tum cagrilar
|
||||
- `Authorization: Bearer <access_token>` otomatik ekleme
|
||||
- 401 durumunda tekil refresh (deduplicate)
|
||||
- Refresh basarisizsa logout + login sayfasina yonlendirme
|
||||
- Backend'in global JSON error formatinin normalize edilmesi
|
||||
|
||||
## 5) Component Listesi
|
||||
|
||||
- `AppShell`
|
||||
- `ProtectedRoute`
|
||||
- `QueryState`
|
||||
- sayfa bazli form ve tablo bilesenleri
|
||||
|
||||
## 6) State Management Yaklasimi
|
||||
|
||||
- `stores/auth-store.ts`: user + token + hydrate + clear
|
||||
- server state: React Query ile cache/refetch
|
||||
|
||||
## 7) Route Guard Yaklasimi
|
||||
|
||||
- Public: `/login`
|
||||
- Private: `/dashboard`, `/images`, `/images/:id`, `/health`, `/settings`
|
||||
- Token yoksa `/login` redirect
|
||||
|
||||
## 8) UI/UX Prensipleri
|
||||
|
||||
- Sidebar + topbar layout
|
||||
- Loading / empty / error state ayrimi
|
||||
- Basit responsive duzen
|
||||
|
||||
## 9) Guvenlik Onlemleri
|
||||
|
||||
- Tokenlar central store + storage ile yonetilir
|
||||
- 401/403 ayrimi API error code ile gorunur
|
||||
- Hassas veriler UI'da loglanmaz
|
||||
|
||||
## 10) Gelistirme Roadmap
|
||||
|
||||
1. MVP auth + dashboard + images list/detay (tamamlandi)
|
||||
2. Pagination/filter/sort + detay metadata (arama/format filtresi + client pagination tamamlandi)
|
||||
3. Role-based guard + kullanici yonetimi (`/users`)
|
||||
4. UI sertlestirme (skeleton, toast, empty state varyasyonlari)
|
||||
5. Testler (auth flow, route guard, api error handling)
|
||||
|
||||
272
docs/IMPLEMENTATION.md
Normal file
272
docs/IMPLEMENTATION.md
Normal file
@@ -0,0 +1,272 @@
|
||||
# Implementation Notes
|
||||
|
||||
Bu belge projede su ana kadar yapilan implementasyonlari teknik olarak ozetler.
|
||||
|
||||
## 1. Genel Mimari
|
||||
|
||||
Proje Axum tabanli bir API olarak calisir.
|
||||
|
||||
Baslica moduller:
|
||||
|
||||
- `src/main.rs` -> uygulama bootstrap
|
||||
- `src/app/` -> router birlestirme ve OpenAPI
|
||||
- `src/auth/` -> register/login/refresh/logout/me akisi
|
||||
- `src/images/` -> image upload, process, listeleme ve variant stream akisi
|
||||
- `src/entities/` -> SeaORM entity tanimlari
|
||||
- `src/migration/` -> migration dosyalari
|
||||
- `src/state/` -> `AppState`, JWT ayarlari, DB init
|
||||
- `src/error/` -> unified `ApiError`
|
||||
- `src/tests/` -> endpoint testleri
|
||||
|
||||
Katman mantigi:
|
||||
|
||||
- `controller` -> HTTP request parsing / response
|
||||
- `service` -> business logic
|
||||
- `repository` -> DB / fs / token source erisimi
|
||||
- `processor` -> image decode/resize/encode
|
||||
- `dto` -> request/response tasiyicilari
|
||||
- `model` -> domain enum ve tipler
|
||||
|
||||
## 2. Auth Sistemi
|
||||
|
||||
Account sistemi JWT access + refresh token mantigi ile calisir.
|
||||
|
||||
Mevcut endpointler:
|
||||
|
||||
- `POST /api/v1/auth/register`
|
||||
- `POST /api/v1/auth/login`
|
||||
- `POST /api/v1/auth/refresh`
|
||||
- `POST /api/v1/auth/logout`
|
||||
- `GET /api/v1/auth/me`
|
||||
|
||||
Davranis:
|
||||
|
||||
- sifreler `argon2` ile hashlenir
|
||||
- access / refresh token `jsonwebtoken` ile uretilir
|
||||
- refresh token session'lari:
|
||||
- DB varsa `refresh_tokens` tablosu
|
||||
- DB yoksa in-memory fallback
|
||||
|
||||
## 3. Images Modulu
|
||||
|
||||
Images modulu su endpointleri sunar:
|
||||
|
||||
- `GET /api/v1/images/process`
|
||||
- `POST /api/v1/images/process`
|
||||
- `GET /api/v1/images`
|
||||
- `GET /api/v1/images/{id}/variant`
|
||||
|
||||
### 3.1 GET /api/v1/images/process
|
||||
|
||||
Bu endpoint query parametrelerini dogrular ve donusum metadata'si uretir.
|
||||
|
||||
Desteklenen parametreler:
|
||||
|
||||
- `width` / `w`
|
||||
- `height` / `h`
|
||||
- `format`
|
||||
- `quality`
|
||||
- `crop`
|
||||
|
||||
Default degerler:
|
||||
|
||||
- `format = webp`
|
||||
- `crop = cover`
|
||||
- `quality = 80`
|
||||
|
||||
### 3.2 POST /api/v1/images/process
|
||||
|
||||
Bu endpoint multipart form-data ile dosya kabul eder.
|
||||
|
||||
Beklenen alanlar:
|
||||
|
||||
- `file`
|
||||
- `width`
|
||||
- `height`
|
||||
- `format`
|
||||
- `quality`
|
||||
- `crop`
|
||||
|
||||
Akis:
|
||||
|
||||
1. bearer token okunur
|
||||
2. token validate edilir
|
||||
3. multipart file byte olarak okunur
|
||||
4. orijinal dosya `uploads/originals` altina kaydedilir
|
||||
5. image decode edilir
|
||||
6. gerekirse resize uygulanir
|
||||
7. istenen output format'a encode edilir
|
||||
8. islenmis varyant `uploads/variants` altina kaydedilir
|
||||
9. DB varsa metadata `images` ve `image_variants` tablolarina yazilir
|
||||
10. response olarak metadata donulur
|
||||
|
||||
### 3.3 GET /api/v1/images
|
||||
|
||||
Bu endpoint DB uzerinden image metadata listesi doner.
|
||||
|
||||
Not:
|
||||
|
||||
- DB yoksa `503 Service Unavailable` doner
|
||||
- response, her image icin latest variant bilgisini de icerebilir
|
||||
|
||||
### 3.4 GET /api/v1/images/{id}/variant
|
||||
|
||||
Bu endpoint ilgili image kaydinin en son varyant dosyasini binary olarak stream eder.
|
||||
|
||||
Not:
|
||||
|
||||
- DB gerektirir
|
||||
- son varyant secimi `created_at desc` sirasina gore yapilir
|
||||
|
||||
## 4. Desteklenen Formatlar
|
||||
|
||||
Model tarafinda desteklenen formatlar:
|
||||
|
||||
- `avif`
|
||||
- `png`
|
||||
- `jpg`
|
||||
- `jpeg`
|
||||
- `webp`
|
||||
|
||||
Processor tarafinda gercek encode akisi vardir.
|
||||
|
||||
Not:
|
||||
|
||||
- input decode basarisizsa su an fallback davranisi source bytes donusumu yerine ham byte ile devam etmeye calisabilir veya hata doner; bu kisim ileride daha da sertlestirilebilir
|
||||
- `crop` enum'u dogrulaniyor fakat su an gercek crop stratejileri tam uygulanmiyor; mevcut implementasyon daha cok resize + format convert seviyesinde
|
||||
|
||||
## 5. Token Dogrulama
|
||||
|
||||
Image endpointleri icin bearer token zorunludur.
|
||||
|
||||
Su an iki yol desteklenir:
|
||||
|
||||
1. `IMAGE_ACCESS_TOKEN` env degeri ile gelen dev token
|
||||
2. mevcut auth sisteminden uretilmis JWT access token
|
||||
|
||||
Bu davranis gecis sureci icindir.
|
||||
|
||||
Hedef mimari:
|
||||
|
||||
- Redis tabanli image token validation
|
||||
- namespaced key yapisi, or. `image:token:{token}`
|
||||
|
||||
## 6. Storage Davranisi
|
||||
|
||||
Varsayilan env ayarlari:
|
||||
|
||||
- `IMAGE_UPLOAD_DIR=uploads/originals`
|
||||
- `IMAGE_VARIANT_DIR=uploads/variants`
|
||||
|
||||
Yuklenen orijinal dosya:
|
||||
|
||||
- `uploads/originals/<uuid>.<ext>`
|
||||
|
||||
Uretilen varyant dosya:
|
||||
|
||||
- `uploads/variants/<uuid>.<target-ext>`
|
||||
|
||||
Onemli not:
|
||||
|
||||
- su an response icinde `stored_path` donuluyor
|
||||
- bu, mevcut implementasyonda debugging ve kontrol kolayligi icin acik
|
||||
- hedef uretim mimarisinde raw path expose etmek yerine `image_id` veya signed access token tercih edilmelidir
|
||||
|
||||
## 7. DB ve Migration Yapisi
|
||||
|
||||
### 7.1 Auth Tablolari
|
||||
|
||||
Migration:
|
||||
|
||||
- `m20260409_000001_create_auth_tables`
|
||||
|
||||
Tablolar:
|
||||
|
||||
- `users`
|
||||
- `refresh_tokens`
|
||||
|
||||
### 7.2 Images Tablolari
|
||||
|
||||
Migration:
|
||||
|
||||
- `m20260409_000002_create_image_tables`
|
||||
|
||||
Tablolar:
|
||||
|
||||
- `images`
|
||||
- `image_variants`
|
||||
|
||||
Iliskiler:
|
||||
|
||||
- `users (1) -> (N) images`
|
||||
- `images (1) -> (N) image_variants`
|
||||
|
||||
### 7.3 Migration Calisma Akisi
|
||||
|
||||
`src/state/mod.rs` icinde DB baglantisi varsa uygulama acilisinda `Migrator::up` cagrilir.
|
||||
|
||||
Yani:
|
||||
|
||||
- DB varsa migration'lar otomatik kontrol edilir
|
||||
- DB baglantisi yoksa app fallback modda acilabilir
|
||||
|
||||
## 8. Swagger / OpenAPI
|
||||
|
||||
Swagger UI:
|
||||
|
||||
- `GET /swagger-ui`
|
||||
|
||||
OpenAPI JSON:
|
||||
|
||||
- `GET /api-docs/openapi.json`
|
||||
|
||||
Swagger'a ekli alanlar:
|
||||
|
||||
- auth endpointleri
|
||||
- image process GET
|
||||
- image upload POST (multipart form-data)
|
||||
- image list
|
||||
- image variant stream
|
||||
|
||||
## 9. Env Degiskenleri
|
||||
|
||||
Temel env degiskenleri:
|
||||
|
||||
- `DATABASE_URL`
|
||||
- `JWT_SECRET`
|
||||
- `JWT_ISSUER`
|
||||
- `ACCESS_TOKEN_TTL_SECS`
|
||||
- `REFRESH_TOKEN_TTL_SECS`
|
||||
- `ENABLE_SWAGGER_UI`
|
||||
- `IMAGE_ACCESS_TOKEN`
|
||||
- `IMAGE_UPLOAD_DIR`
|
||||
- `IMAGE_VARIANT_DIR`
|
||||
- `DB_REQUIRED`
|
||||
|
||||
## 10. Mevcut Sinirlar / Sonraki Adimlar
|
||||
|
||||
Su an sistem calisir durumda ama halen gelistirilebilir alanlar var:
|
||||
|
||||
1. Redis tabanli gercek image token repository
|
||||
2. gercek crop stratejileri (`cover`, `contain`, `center` vs.)
|
||||
3. image cache / variant cache
|
||||
4. raw path expose etmek yerine guvenli public serving
|
||||
5. `GET /api/v1/images/{id}/variant` icin format/width/height/crop bazli secim
|
||||
6. islenmis varyantlar icin duplicate-onleme / cache-aside stratejisi
|
||||
7. local fs yerine object storage destegi
|
||||
|
||||
## 11. Windows Build
|
||||
|
||||
Repo icinde `win.sh` scripti bulunur.
|
||||
|
||||
Amaci:
|
||||
|
||||
- `x86_64-pc-windows-gnu` target eklemek
|
||||
- linker config hazirlamak
|
||||
- Windows release build almak
|
||||
|
||||
Script:
|
||||
|
||||
- `.cargo/config.toml` olusturabilir
|
||||
- `cargo build --target x86_64-pc-windows-gnu --release` calistirir
|
||||
|
||||
41
docs/MCP_INTEGRATION.md
Normal file
41
docs/MCP_INTEGRATION.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# MCP Integration
|
||||
|
||||
Bu iskelet, mevcut Axum backend icine MCP uyumlu bir HTTP katmani ekler.
|
||||
|
||||
## Eklenen Ana Bilesenler
|
||||
|
||||
- `src/app/routes/mcp.rs`: MCP HTTP (`POST /api/v1/mcp`) ve SSE (`GET /api/v1/mcp/sse`) endpointleri
|
||||
- `src/app/routes/mcp.rs`: JWT korumali dokuman upload endpointi (`POST /api/v1/mcp/documents/upload`)
|
||||
- `src/app/routes/mcp.rs`: Swagger dostu MCP endpointleri (`POST /api/v1/mcp/tools/list`, `POST /api/v1/mcp/tools/call`)
|
||||
- `src/app/mcp/auth.rs`: MCP route'lari icin JWT access token middleware'i
|
||||
- `src/app/mcp/tools/mod.rs`: MCP tool registry ve tool implementasyonlari
|
||||
- `src/app/services/mcp_service.rs`: Redis destekli tool-list cache ve tool dispatch
|
||||
- `src/app/services/mcp_documents_service.rs`: md/txt yukleme, okuma ve listeleme servisi
|
||||
- `src/app/repository/mcp_documents_repository.rs`: SeaORM tabanli MCP dokuman DB erisim katmani
|
||||
- `src/app/models/mcp.rs`: MCP request/response modelleri
|
||||
- `src/app/errors/mod.rs`: JSON-RPC uyumlu MCP hata modeli
|
||||
|
||||
## Desteklenen MCP Methodlari
|
||||
|
||||
- `initialize`
|
||||
- `tools/list`
|
||||
- `tools/call`
|
||||
|
||||
## Ornek Toollar
|
||||
|
||||
- `system.health`
|
||||
- `system.echo` (ornek tool, mesaji oldugu gibi veya uppercase dondurur)
|
||||
- `system.time` (sunucu unix timestamp doner)
|
||||
- `images.process` (mevcut `images::service::process_image` cagrisi)
|
||||
- `images.list` (mevcut `images::service::list_images` cagrisi)
|
||||
- `documents.list` (JWT sahibinin dokuman listesi)
|
||||
- `documents.read` (dokuman icerigi)
|
||||
- `documents.search` (kullanici dokumanlarinda dosya adi + icerik aramasi)
|
||||
|
||||
## Notlar
|
||||
|
||||
- MCP endpointleri JWT `access` token gerektirir.
|
||||
- Upload endpointi sadece `md` ve `txt` kabul eder.
|
||||
- Tool listesi Redis varsa `mcp:tools:list` anahtari altinda TTL ile cache'lenir.
|
||||
- SSE endpointi bu asamada hazirlik eventi donduren bir iskelettir; canli publish/subscribe akisi icin TODO vardir.
|
||||
|
||||
Reference in New Issue
Block a user