Modern, çok dilli web uygulaması - Go Backend + Next.js Frontend + MongoDB + Docker
Bu projeyi Go dilini öğrenmek ve kendi AUTH sistemimi hazırlamak için oluşturdum.
- Yorum satırlarını oluşturmak için Yapay Zeka araçlarından bol bol yararlanıldı.
- JWT tabanlı kimlik doğrulama (72 saatlik token süresi)
- Session management sistemi (multi-device support)
- Secure password hashing (bcrypt ile 14 round)
- IP & Device tracking (mobile, tablet, desktop detection)
- Auto session cleanup (expired session'ları otomatik temizleme)
- Next.js 15 (App Router + Turbopack)
- TypeScript desteği
- Tailwind CSS 4 (responsive design)
- Dark/Light theme (next-themes)
- Animations (AOS, Lottie, React Typewriter)
- Modern UI Components (React Icons, Marquee)
- RESTful API (Gorilla Mux router)
- MongoDB integration (native driver v2)
- Middleware system (CORS, Auth)
- Performance optimized (MongoDB indexing)
- Environment configuration (.env support)
# Repository'yi klonla
git clone https://github.com/bymayfe/multilang_web.git
cd MultiLang_Web
# Environment dosyasını oluştur
cp .env.example .env
# Docker Compose ile başlat
docker-compose up --build
# Frontend: http://localhost:3000
# Backend API: http://localhost:3001cd go/
go mod download
go run main.gocd nextjs/
npm install
npm run devMultiLang_Web/
├── 📂 go/ # Backend (Go)
│ ├── main.go # Ana server dosyası
│ ├── middleware/
│ │ └── auth.go # JWT & Session middleware
│ ├── models/
│ │ ├── user.go # User model
│ │ └── session.go # Session model
│ ├── routes/
│ │ ├── handlers.go # API handlers
│ │ └── router.go # Route definitions
│ └── utils/
│ ├── hash.go # Password hashing
│ ├── jwt.go # JWT operations
│ └── userid.go # User ID generation
├── 📂 nextjs/ # Frontend (Next.js)
│ ├── app/ # App Router
│ ├── components/ # Reusable components
│ ├── providers/
│ │ └── AuthProvider/ # Custom auth system
│ │ ├── index.tsx # Main provider
│ │ ├── hook.ts # useAuth hook
│ │ ├── storage.ts # Storage adapters
│ │ └── index.tsx # Type definitions
│ ├── scripts/
│ │ └── services/
│ │ └── auth.ts # API service calls
│ ├── public/ # Static files
│ └── styles/ # Global styles
├── docker-compose.yml # Development setup
└── README.md # Bu dosya
| Method | Endpoint | Açıklama |
|---|---|---|
POST |
/user/signup |
Yeni kullanıcı kaydı |
POST |
/user/login |
Kullanıcı girişi |
| Method | Endpoint | Açıklama |
|---|---|---|
GET |
/user/session |
Kullanıcı oturum bilgileri |
GET |
/user/sessions |
Aktif oturum listesi |
POST |
/user/logout |
Çıkış (tek cihaz) |
POST |
/user/logout-all |
Tüm cihazlardan çıkış |
GET |
/user/protected |
Örnek korumalı endpoint |
curl -X POST http://localhost:3001/user/signup \
-H "Content-Type: application/json" \
-d '{
"name": "Ali Veli",
"email": "ali@example.com",
"password": "güçlü123şifre",
"username": "aliveli",
"firstname": "Ali",
"lastname": "Veli",
"age": 21
}'curl -X POST http://localhost:3001/user/login \
-H "Content-Type: application/json" \
-d '{
"email": "ali@example.com",
"password": "güçlü123şifre"
}'curl -X GET http://localhost:3001/user/session \
-H "Authorization: Bearer YOUR_JWT_TOKEN"{
"_id": ObjectId,
"userID": 100001, // Auto-increment ID
"name": "Ali Veli",
"email": "ali@example.com",
"password": "$2a$14$...", // Bcrypt hash
"username": "aliveli",
"firstname": "Ali",
"lastname": "Veli",
"role": "MEMBER", // MEMBER, ADMIN, etc.
"age": 25,
"image": "",
"createdAt": "2024-01-15 10:30:00",
"updatedAt": "2024-01-15 10:30:00"
}{
"_id": ObjectId,
"userID": 100001,
"token": "eyJhbGciOiJIUzI1NiIs...",
"expiresAt": ISODate("2024-01-18T10:30:00Z"),
"createdAt": ISODate("2024-01-15T10:30:00Z"),
"ipAddress": "192.168.1.100",
"userAgent": "Mozilla/5.0...",
"deviceType": "desktop" // desktop, mobile, tablet
}.env dosyası oluştur:
# MongoDB
MONGODB_URI=mongodb://localhost:27017/authdb
# JWT Secret (güçlü bir key kullan!)
JWT_SECRET=your-super-secret-key-here-minimum-32-chars
# Server
PORT=3001
# Frontend URLs (CORS için)
FRONTEND_URL=http://localhost:3000- Password Security: bcrypt ile 14 round hashing
- JWT Tokens: 72 saatlik expiration
- Session Tracking: IP ve cihaz bazlı takip
- CORS Protection: Sadece tanımlı origin'lere izin
- Auto Cleanup: Expired session'ları otomatik silme
- Multi-Device: Aynı kullanıcı birden fazla cihazda login olabilir
- Secure Headers: Authorization header validation
Proje, Next-Auth benzeri bir authentication sistemi içerir ancak tamamen custom olarak geliştirilmiştir:
// Custom AuthProvider sistemi
providers/
└── AuthProvider/
├── index.tsx # Ana provider (Next-Auth gibi)
├── hook.ts # useAuth hook
├── storage.ts # Storage adapters
└── types.ts # Type definitions- ✅ Context API tabanlı state management
- ✅ useAuth hook ile kolay kullanım
- ✅ Token persistence (localStorage/sessionStorage)
- ✅ TypeScript desteği
- ✅ Session lifecycle management
- ✅ Multi-device login desteği
- ✅ Automatic cleanup (expired sessions)
- ✅ Device detection (mobile/tablet/desktop)
- ✅ IP tracking & audit logging
- ✅ Logout from all devices özelliği
- ✅ Active sessions listeleme
- Login → Yeni session oluştur
- API Call → Session & JWT validate et
- Logout → Session'ı sil
- Auto Cleanup → Expired session'ları temizle
- ⚡ Next.js 15 (App Router, Turbopack)
- 📝 TypeScript 5 (Type safety)
- 🎨 Tailwind CSS 4 (Utility-first styling)
- 🌙 Theme System (Dark/Light mode)
- 📱 Responsive Design (Mobile-first)
- 🔄 Animations (AOS, Lottie, Typewriter)
- 📊 Analytics (Vercel Analytics)
// Core
github.com/gorilla/mux // HTTP router
go.mongodb.org/mongo-driver // MongoDB driver
// Security
github.com/golang-jwt/jwt/v5 // JWT tokens
golang.org/x/crypto // Password hashing
// Utils
github.com/joho/godotenv // Environment variables# Development modunda çalıştır
docker-compose up
# Sadece backend'i rebuild et
docker-compose up --build backend
# Logları takip et
docker-compose logs -f
# Temizlik
docker-compose down
docker system prune -f| Code | Açıklama |
|---|---|
200 |
✅ Başarılı |
201 |
✅ Oluşturuldu |
400 |
❌ Geçersiz istek |
401 |
❌ Yetkisiz erişim |
403 |
❌ Yasaklanmış |
404 |
❌ Bulunamadı |
409 |
❌ Çakışma (email zaten kayıtlı) |
500 |
❌ Sunucu hatası |
// Otomatik oluşturulan indexler:
db.users.createIndex({ email: 1 }, { unique: true });
db.users.createIndex({ userID: 1 }, { unique: true });
db.sessions.createIndex({ token: 1 }, { unique: true });
db.sessions.createIndex({ userID: 1, expiresAt: 1 });
db.sessions.createIndex({ expiresAt: 1 }, { expireAfterSeconds: 0 });- Session Cleanup: Her saat expired session'ları temizler
- Health Monitoring: MongoDB bağlantısını kontrol eder
Bu proje MIT License altında lisanslanmıştır. Detaylar için LICENSE dosyasına bakın.
Bu proje açık kaynak kod topluluğu katkıları ile büyümektedir. Katkıda bulunmak istiyorsanız:
- Repository'yi fork edin
- Feature branch oluşturun (
git checkout -b feature/amazing-feature) - Değişikliklerinizi commit edin (
git commit -m 'Add amazing feature') - Branch'inizi push edin (
git push origin feature/amazing-feature) - Pull Request oluşturun
Bu projede Contributor Covenant davranış kurallarını benimser.
- JWT tabanlı kimlik doğrulama (72 saatlik token süresi)
- Session management (multi-device support)
- Tailwind CSS v4 entegrasyonu (global theme + animation pipeline)
- Next.js 15 geçişi (App Router + Turbopack)
- MongoDB Atlas bağlantısı (native driver + indexing)
- Go backend mimarisi (JWT/context/middleware ile)
- Admin Panel (user management dashboard)
- Multi-language support (i18n implementation)
- Real-time Notifications (WebSocket integration)
- API Rate Limiting middleware
- Swagger Documentation (OpenAPI 3.0)
- Unit Tests (Go & TypeScript)
- E2E Testing (Playwright/Cypress)
- Performance Monitoring (logging, metrics)
- Microservices Architecture (service splitting)
- CI/CD Pipeline (GitHub Actions)