Initial commit

This commit is contained in:
2026-03-03 19:34:44 +03:00
commit 6221137a35
113 changed files with 23525 additions and 0 deletions

146
mds/deploy.md Normal file
View File

@@ -0,0 +1,146 @@
```markdown
# 🚀 Raspberry Pi Proje Dağıtım Rehberi (SSL Güncellemeli)
Bu rehber, mevcut merkezi altyapıyı (Gitea, Runner, Central Database, Nginx) kullanarak yeni NestJS (Backend) ve Next.js (Frontend) projelerini nasıl ayağa kaldıracağını ve **SSL (HTTPS) sorunları yaşamadan** nasıl yayına alacağını adım adım açıklar.
---
## 🏗 1. Altyapı Hazırlığı (Infrastructure)
### A. Veritabanı Oluşturma
Her yeni proje için merkezi PostgreSQL konteynerinde yeni bir veritabanıılmalıdır.
```bash
# PROJE_ADI kısmını küçük harf ve boşluksuz yaz (örn: e_ticaret_db)
docker exec -it backend_db createdb -U 'Rub1c0N-UseR.!' PROJE_ADI_db
```
### B. DNS Ayarları
Domain panelinden (Cloudflare vb.) yeni subdomain'leri Raspberry Pi'nin dış IP'sine yönlendir:
* `api-proje.bilgich.com` -> **Raspberry Pi IP**
* `ui-proje.bilgich.com` -> **Raspberry Pi IP**
---
## 🔐 2. Gitea Secret Ayarları
**⚠️ Önemli:** Proje canlıya çıkarken SSL kullanacağımız için URL'leri şimdiden **https** olarak tanımlıyoruz.
Gitea reponuzda **Settings > Actions > Secrets** yolunu izleyerek aşağıdaki anahtarları tanımlayın.
### Backend İçin:
| Key | Value Örneği | Açıklama |
| :--- | :--- | :--- |
| `DATABASE_URL` | `postgresql://Rub1c0N-UseR.%21:SIFRE%3D@backend_db:5432/PROJE_ADI_db?schema=public` | Özel karakterler encode edilmeli (!=%21, =%3D) |
| `JWT_SECRET` | `rastgele_uzun_string` | Güvenlik anahtarı |
### Frontend İçin:
| Key | Value Örneği | Açıklama |
| :--- | :--- | :--- |
| `NEXT_PUBLIC_API_URL` | `https://api-proje.bilgich.com/api` | **https** olmasına dikkat et |
| `NEXTAUTH_URL` | `https://ui-proje.bilgich.com` | **https** olmasına dikkat et |
| `NEXTAUTH_SECRET` | `openssl_rand_base64_32_cikti` | Auth güvenliği için |
---
## 🛠 3. Backend (NestJS) Proje Ayarları
1. **main.ts:** Global prefix ve Swagger yollarını kontrol et.
2. **Dockerfile:** Mevcut çalışan NestJS Dockerfile'ı kullan.
3. **deploy.yml Değişiklikleri:**
* `--name backend-PROJE-container` (Her proje için unique isim)
* `-p 150X:3000` (Sıradaki boş port: 1502, 1503...)
* `--network gitea-server_gitea` (Database'e erişim için şart)
---
## 🎨 4. Frontend (Next.js) Proje Ayarları
1. **next.config.js:** `output: 'standalone'` satırını ekle.
2. **Dockerfile:** `ARG` ve `ENV` satırlarına `NEXT_PUBLIC_` değişkenlerini ekle.
3. **deploy-ui.yml Değişiklikleri:**
* `--build-arg` ile tüm Gitea secret'larını build aşamasına geç.
* `--name ui-PROJE-container` (Unique isim)
* `-p 180X:3000` (Sıradaki boş port: 1801, 1802...)
* `-e NEXTAUTH_URL` ve `NEXTAUTH_SECRET` runtime değişkenlerini ekle.
---
## 🚦 5. Nginx ve SSL Yönlendirmesi (KRİTİK ADIM)
Diğer projelerle çakışma olmaması için her yeni domain'e mutlaka SSL kurulmalıdır.
### A. Konfigürasyon Dosyası Oluştur
Backend veya Frontend için dosya oluşturun:
```bash
sudo nano /etc/nginx/sites-available/proje-api
# Veya
sudo nano /etc/nginx/sites-available/proje-ui
```
### B. İçeriği Yapıştır (Sadece HTTP)
İlk aşamada sadece 80 portunu dinleyen şu bloğu yapıştırın:
```nginx
server {
listen 80;
server_name api-proje.bilgich.com; # Domain adını buraya yaz
location / {
proxy_pass http://127.0.0.1:150X; # Uygulamanın dış portu (1502, 1802 vb.)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# Gerçek IP Logları
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
### C. Nginx'i Aktif Et
Dosyayı `sites-enabled` klasörüne linkleyin ve Nginx'i reload edin:
```bash
sudo ln -s /etc/nginx/sites-available/proje-api /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
```
### D. SSL Sertifikası Kur (Certbot)
Bu komut Nginx ayarlarını otomatik güncelleyip 443 portunu açacaktır. Bu adımı yapmazsanız HTTPS girişleri başka projelere yönlenir!
```bash
sudo certbot --nginx -d api-proje.bilgich.com
```
*Soru sorarsa "2" (Redirect) seçeneğini seçin.*
---
## 💡 "Senior" İpuçları & Bakım
### Port Yönetimi (Defteri Kebir)
Kullandığın portları çakışmaması için mutlaka not et:
* **1501:** Digicraft BE
* **1502:** YeniProje BE
* **1800:** Digicraft UI
* **1801:** YeniProje UI
### Disk Temizliği
Raspberry Pi diski dolmaması için haftalık/aylık temizlik yap:
```bash
docker system prune -f
```
### Log Takibi
Bir sorun olduğunda ilk buraya bak:
```bash
docker logs -f KONTEYNER_ADI
```
```

65
mds/learned_protocols.md Normal file
View File

@@ -0,0 +1,65 @@
# Learned Protocols & Standards
This document serves as the persistent memory of the protocols, standards, and personas learned from the `skript-be` and `skript-ui` repositories.
## 1. Frontend Standards (skript-ui)
### Design & Aesthetics (`frontend-design`)
- **Anti-AI Slop:** Avoid generic, cookie-cutter "AI" aesthetics (e.g., standard purple gradients, predictable layouts).
- **Boldness:** Commit to a specific aesthetic direction (Minimalist, Brutalist, Magazine, etc.).
- **Typography:** Use distinctive fonts; avoid system defaults like Arial/Inter unless intentional.
- **Micro-interactions:** Prioritize one or two high-impact animations over scattered noise.
- **Creativity:** Use noise textures, gradient meshes, asymmetry, and overlapping elements.
### Architecture (`senior-frontend` & `nextjs-architecture-expert`)
- **Next.js App Router:** STRICT adherence to App Router patterns (layouts, error.tsx, loading.tsx).
- **Server Components (RSC):** Default to Server Components. Use Client Components ('use client') only when interactivity is required.
- **State Management:** component-first thinking; use Context/Zustand for global state, local state for UI.
- **Performance:** Aim for sub-3s load times. Use `next/image`, code splitting, and lazy loading.
- **Tailwind CSS:** Use correctly; avoid long string pollution where possible (use utils/cva).
### Quality Assurance (`senior-qa`)
- **E2E Testing:** Critical flows must be tested.
- **Coverage:** High unit test coverage for utilities and complex logic.
## 2. Backend Standards (skript-be)
### Code Quality (`code-reviewer`)
- **Review:** Verify BEFORE implementing.
- **Simplicity:** No over-engineering.
- **Security:** No secrets in code. Input validation is mandatory.
- **YAGNI:** "You Aren't Gonna Need It" - don't build features "just in case".
### Security (`security-engineer` & `api-security-audit`)
- **Zero Trust:** Verify every request.
- **OWASP:** Check against Top 10 (Injection, Broken Auth, etc.).
- **Data:** Validate all inputs using libraries (e.g., Zod, Joi).
- **Logging:** Sanitize logs (no PII/secrets).
### Database (`database-optimizer`)
- **N+1:** Watch out for N+1 queries in loops/ORMs.
- **Indexing:** Index foreign keys and search columns.
- **Explain:** Check execution plans for complex queries.
### General Engineering
- **TypeScript:** Strict mode enabled. No `any`. Use generics and utility types (`typescript-pro`).
- **Feedback:** "Receive Code Review" protocol technical correctness > polite agreement. Verify suggestions before applying.
### TypeScript Expertise (`typescript-pro`)
- **Seniority:** I write *Senior-level* code. This means focusing on maintainability, scalability, and robustness, not just "making it work".
- **Modern Techniques:** I utilize the latest TypeScript features:
- **Advanced Types:** Conditional types, Template Literal Types, Mapped Types.
- **Utility Types:** `Pick`, `Omit`, `Partial`, `Readonly`, `ReturnType`, `Parameters`, etc.
- **Generics:** Proper constraints (`T extends ...`) and defaults.
- **Type Inference:** Leveraging inference where clean, explicit typing where necessary for clarity.
- **Strictness:**
- `noImplicitAny` is law.
- Avoid `any` at all costs; use `unknown` with type narrowing/guards if dynamic typing is truly needed.
- Strict null checks always on.
- **Architecture:** Value objects, opaque types, and branded types for domain safety.
## 3. Operational Protocols
- **Agent Persona:** I act as the specific specialist required for the task (e.g., if debugging, I am `debugger`; if designing, I am `frontend-developer`).
- **Proactiveness:** I do not wait for permission to fix obvious bugs or improve clear performace bottlenecks if they are within scope.
- **Persistence:** These rules apply to ALL future tasks in this session.