183 lines
4.4 KiB
Markdown
183 lines
4.4 KiB
Markdown
# SmartHome Web Application
|
||
|
||
A modern smart home management system built with Svelte frontend and Node.js/Express backend with MongoDB integration.
|
||
|
||
## 📁 Proje Yapısı
|
||
|
||
```
|
||
smarthome/
|
||
├── src/ # Svelte frontend kaynak kodları
|
||
├── api/ # Node.js backend API
|
||
│ ├── models/ # MongoDB veri modelleri
|
||
│ ├── controllers/ # API kontrolörleri
|
||
│ ├── routes/ # API route'ları
|
||
│ ├── configs/ # Yapılandırma dosyaları
|
||
│ └── library/ # Yardımcı kütüphaneler
|
||
├── public/ # Statik dosyalar
|
||
├── scripts/ # Build script'leri
|
||
└── .env.* # Environment dosyaları
|
||
```
|
||
|
||
## 🚀 Özellikler
|
||
|
||
- **Frontend**: Svelte + Vite modern, hızlı arayüz
|
||
- **Backend**: Express.js RESTful API
|
||
- **Veritabanı**: MongoDB ile entegre
|
||
- **Gerçek Zamanlı**: Socket.io ile real-time iletişim
|
||
- **Docker Destekli**: Kolay deployment
|
||
- **Responsive**: Mobil uyumlu tasarım
|
||
|
||
## 🛠️ Kurulum
|
||
|
||
### Gereksinimler
|
||
- Node.js (v16 veya üzeri)
|
||
- MongoDB (yönelimli)
|
||
- npm veya yarn
|
||
|
||
### Adımlar
|
||
|
||
1. **Projeyi klonlayın:**
|
||
```bash
|
||
git clone [repository-url]
|
||
cd smarthome
|
||
```
|
||
|
||
2. **Frontend bağımlılıkları:**
|
||
```bash
|
||
npm install
|
||
```
|
||
|
||
3. **Backend bağımlılıkları:**
|
||
```bash
|
||
cd api
|
||
npm install
|
||
cd ..
|
||
```
|
||
|
||
4. **Environment konfigürasyonu:**
|
||
```bash
|
||
# Mevcut .env dosyalarını kopyalayın
|
||
cp .env.example .env.local
|
||
cp api/.env.example api/.env
|
||
```
|
||
|
||
5. **Uygulamayı çalıştırın:**
|
||
```bash
|
||
# Frontend (terminal 1)
|
||
npm run dev
|
||
|
||
# Backend (terminal 2)
|
||
cd api
|
||
npm start
|
||
```
|
||
|
||
## 🔧 Environment Değişkenleri
|
||
|
||
### Frontend Environment Dosyaları
|
||
|
||
Proje dizininde bulunan environment dosyaları:
|
||
|
||
#### `.env.dev` (Geliştirme Ortamı)
|
||
```env
|
||
VITE_API_URL="http://localhost:3000"
|
||
```
|
||
|
||
#### `.env.prod` (Production Ortamı)
|
||
```env
|
||
VITE_API_URL="https://smarthome.wisecolt-panda.net"
|
||
```
|
||
|
||
#### `api/.env.mongo` (MongoDB Konfigürasyonu)
|
||
```env
|
||
# Bu dosya boş veya MongoDB connection string içerir
|
||
# Örnek:
|
||
# MONGODB_URI="mongodb://localhost:27017/smarthome"
|
||
# veya
|
||
# MONGODB_URI="mongodb+srv://username:password@cluster.mongodb.net/smarthome"
|
||
```
|
||
|
||
### Yeni Proje Kurulumu için Environment Şablonu
|
||
|
||
Yeni bir proje kurarken şu dosyaları oluşturun:
|
||
|
||
#### `.env.local` (Frontend için)
|
||
```env
|
||
# API URL konfigürasyonu
|
||
VITE_API_URL="http://localhost:3000"
|
||
|
||
# Opsiyonel: Diğer frontend ayarları
|
||
# VITE_APP_NAME="SmartHome"
|
||
# VITE_APP_VERSION="1.0.0"
|
||
```
|
||
|
||
#### `api/.env` (Backend için)
|
||
```env
|
||
# Port ayarları
|
||
PORT=3000
|
||
|
||
# MongoDB bağlantısı
|
||
MONGODB_URI="mongodb://localhost:27017/smarthome"
|
||
|
||
# JWT Secret (production'da güçlü bir değer kullanın)
|
||
JWT_SECRET="your-secret-key-here"
|
||
|
||
# CORS ayarları
|
||
CORS_ORIGIN="http://localhost:5173"
|
||
|
||
# Socket.io ayarları
|
||
SOCKET_CORS_ORIGIN="http://localhost:5173"
|
||
```
|
||
|
||
## 📝 Environment Dosyalarının Listesi
|
||
|
||
Proje içinde mevcut olan tüm environment dosyaları:
|
||
|
||
1. **`.env.dev`** - Geliştirme ortamı frontend konfigürasyonu
|
||
2. **`.env.prod`** - Production ortamı frontend konfigürasyonu
|
||
3. **`api/.env.mongo`** - MongoDB veritabanı bağlantı ayarları
|
||
|
||
## 🐳 Docker ile Deployment
|
||
|
||
```bash
|
||
# Backend API'yi build et
|
||
cd api
|
||
docker build -t smarthome-api .
|
||
|
||
# Docker Compose ile çalıştır
|
||
docker-compose up -d
|
||
```
|
||
|
||
## 🌐 API Endpoint'leri
|
||
|
||
- `GET /api/devices` - Cihazları listele
|
||
- `POST /api/devices` - Yeni cihaz ekle
|
||
- `PUT /api/devices/:id` - Cihaz güncelle
|
||
- `GET /api/devices/:id/logs` - Cihaz log'larını getir
|
||
|
||
## 📚 Kullanılan Teknolojiler
|
||
|
||
### Frontend
|
||
- [Svelte](https://svelte.dev/) - Modern UI kütüphanesi
|
||
- [Vite](https://vitejs.dev/) - Hızlı build tool
|
||
- [Svelte Routing](https://github.com/EmilTholin/svelte-routing) - Client-side routing
|
||
|
||
### Backend
|
||
- [Express.js](https://expressjs.com/) - Web framework
|
||
- [MongoDB](https://www.mongodb.com/) - NoSQL veritabanı
|
||
- [Mongoose](https://mongoosejs.com/) - MongoDB ODM
|
||
- [Socket.io](https://socket.io/) - Real-time iletişim
|
||
- [Helmet](https://helmetjs.github.io/) - Security middleware
|
||
- [Morgan](https://github.com/expressjs/morgan) - HTTP request logger
|
||
|
||
## 🤝 Katkıda Bulunma
|
||
|
||
1. Fork yapın
|
||
2. Feature branch oluşturun (`git checkout -b feature/amazing-feature`)
|
||
3. Commit yapın (`git commit -m 'Add some amazing feature'`)
|
||
4. Push yapın (`git push origin feature/amazing-feature`)
|
||
5. Pull Request açın
|
||
|
||
## 📄 Lisans
|
||
|
||
Bu proje ISC lisansı altında lisanslanmıştır.
|