first commit
This commit is contained in:
56
belgeler/proje-yapisi.md
Normal file
56
belgeler/proje-yapisi.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Proje Yapısı
|
||||
|
||||
```
|
||||
goaresv3/
|
||||
├── main.go
|
||||
├── .env
|
||||
├── app/
|
||||
│ ├── accounts/
|
||||
│ │ ├── controllers/user.go
|
||||
│ │ └── models/accounts.go
|
||||
│ ├── settings/
|
||||
│ │ ├── controllers/settings.go
|
||||
│ │ └── models/{setting,hero,cors}.go
|
||||
│ ├── shop/
|
||||
│ │ ├── controllers/shop.go
|
||||
│ │ └── models/{product,cart}.go
|
||||
│ └── blog/
|
||||
│ ├── controllers/blog.go
|
||||
│ └── models/blog.go
|
||||
├── config/database.go
|
||||
├── pkg/
|
||||
│ ├── jwt/jwt.go
|
||||
│ ├── mailer/mailer.go
|
||||
│ ├── middleware/{auth,cors_dynamic,rate_limit_dynamic}.go
|
||||
│ └── swaggerui/initializer.go
|
||||
├── router/router.go
|
||||
├── docs/{docs.go,swagger.json,swagger.yaml}
|
||||
└── belgeler/
|
||||
```
|
||||
|
||||
## Uygulama Akışı
|
||||
|
||||
1. `.env` yüklenir (`godotenv`).
|
||||
2. `config.ConnectDB()` ile MySQL bağlantısı açılır.
|
||||
3. `config.RunAutoMigrate()` tüm modüllerin şemalarını uygular.
|
||||
4. `config.SeedSecurityDefaults()` CORS/RateLimit başlangıç kayıtlarını (yoksa) ekler.
|
||||
5. Gin başlatılır, global middlewareler çalışır:
|
||||
- `DynamicCORS()`
|
||||
- `DynamicRateLimit()`
|
||||
6. `router.Setup(r)` ile endpointler yüklenir.
|
||||
|
||||
## Yetki Modeli
|
||||
|
||||
- `AuthRequired()`:
|
||||
- Access token doğrular
|
||||
- Context'e `user_id`, `email`, `username` yazar
|
||||
- `AdminRequired()`:
|
||||
- `users.is_admin` alanını kontrol eder
|
||||
- `POST/PUT/DELETE/PATCH` gibi mutating endpointlerde kullanılır
|
||||
|
||||
## Route Grupları
|
||||
|
||||
- Public: `/api/v1/auth/*`
|
||||
- Auth zorunlu (read + user işlemleri): `/api/v1/*`
|
||||
- Admin zorunlu (mutating yönetim işlemleri): `/api/v1/*` altında admin grubu
|
||||
- Swagger UI: `/swagger/*any`
|
||||
Reference in New Issue
Block a user