kw-flask
Flask + MongoDB + Docker + Session Auth — tek komutla hazır, modüler REST API şablonu.
pip install kw-flask
kw-flask benim-projem
Özellikler
- 🏗️ Blueprint tabanlı modüler yapı — her modül kendi route/service/model/validator'ına sahip
- 🔐 Flask-Login session auth — server-side session,
remember me, rol bazlı erişim - 🍃 MongoEngine ODM — class tabanlı MongoDB modelleri
- 🐳 Docker Compose — app + MongoDB + Mongo Express UI hazır
- ⚙️ Ortam bazlı config — development / production / testing
- 🛡️ Global hata yönetimi — tüm hatalar tutarlı JSON döner
- 🔑 Otomatik SECRET_KEY — her projede benzersiz anahtar üretilir
Hızlı Başlangıç
# Kur
pip install kw-flask
# Proje oluştur
kw-flask siparis-api
cd siparis-api
# Docker ile başlat
docker compose up -d
API http://localhost:5000 adresinde hazır.
Mongo Express UI: http://localhost:8081
Endpoint'ler
| Metod | Endpoint | Açıklama |
|---|---|---|
| POST | /api/v1/auth/register |
Kayıt ol (oturum otomatik açılır) |
| POST | /api/v1/auth/login |
Giriş yap (remember: true → 30 gün) |
| POST | /api/v1/auth/logout |
Çıkış yap |
| GET | /api/v1/auth/me |
Oturum açık kullanıcı |
| GET | /api/v1/auth/check |
Session kontrolü |
| GET | /api/v1/users |
Kullanıcı listesi (admin) |
| GET | /api/v1/users/<id> |
Kullanıcı detayı |
| PATCH | /api/v1/users/<id> |
Profil güncelle |
| POST | /api/v1/users/<id>/change-password |
Şifre değiştir |
| DELETE | /api/v1/users/<id> |
Hesabı devre dışı bırak |
| GET | /health |
Servis + DB sağlık durumu |
Proje Yapısı
app/
├── core/
│ ├── config.py # Ortam bazlı konfigürasyon
│ ├── database/connection.py # DatabaseManager (MongoEngine)
│ ├── exceptions/ # AppException hiyerarşisi + global handler'lar
│ └── middlewares/
│ ├── session.py # Flask-Login + @require_roles dekoratörü
│ └── health.py # /health endpoint'i
├── modules/
│ └── user/
│ ├── models/ # MongoEngine User (UserMixin dahil)
│ ├── services/ # AuthService, UserService (class tabanlı)
│ ├── routes/ # Blueprint'ler
│ └── validators/ # Marshmallow şemaları
└── utils/
├── response.py # success_response / error_response
├── validators.py # validate_request yardımcısı
└── logger.py # Yapılandırılmış loglama
Yeni Modül Eklemek
app/modules/
└── urun/
├── __init__.py
├── models/urun_model.py
├── services/urun_service.py
├── routes/urun_routes.py
└── validators/schemas.py
app/__init__.py içindeki _register_blueprints fonksiyonuna blueprint'i kaydet:
from .modules.urun.routes.urun_routes import urun_bp
app.register_blueprint(urun_bp, url_prefix="/api/v1/urunler")
Rol Bazlı Erişim
from app.core.middlewares.session import require_roles
@urun_bp.delete("/<id>")
@login_required
@require_roles("admin")
def delete_urun(id):
...
Ortam Değişkenleri
| Değişken | Açıklama |
|---|---|
FLASK_ENV |
development / production |
MONGO_URI |
MongoDB bağlantı adresi |
MONGO_DB_NAME |
Veritabanı adı |
SECRET_KEY |
Session imzalama anahtarı (otomatik üretilir) |
BCRYPT_LOG_ROUNDS |
Bcrypt iş faktörü (varsayılan: 12) |
Lisans
MIT
Metadata
Release files for kw-flask 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kw_flask-1.0.0.tar.gz | 16.9 kB | Without provenance | Details for kw_flask-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kw_flask-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for kw_flask-1.0.0-py3-none-any.whl |
Total release size: 41.3 kB
Release files / kw_flask-1.0.0.tar.gz
| Download URL | kw_flask-1.0.0.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8362284633a45594ba89e7ba14a7c1b311dd13f5217507576ff2a91d3e21ac51
|
|
BLAKE2b-256 checksum How to use checksums |
3c0b35320e4db7a69809c4410535f7cce0eadbe3024da3cff69a584b3b7efacb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / kw_flask-1.0.0-py3-none-any.whl
| Download URL | kw_flask-1.0.0-py3-none-any.whl |
|---|---|
| Size | 24.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
178675aa3172c556fc342255cc1fc862adc780eebeaa8ce763624a4790f00cc2
|
|
BLAKE2b-256 checksum How to use checksums |
9122802155f5e658f0249c821c1fd475850c5a0727ecf8d0cd34b77cf382e8ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for kw-flask 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.