Files
goaresv3/belgeler/proje-yapisi.md
Beyhan Oğur b6e74bd024 first commit
2026-04-26 21:41:46 +03:00

57 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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ıı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`