first commit
This commit is contained in:
221
README.md
221
README.md
@@ -1,47 +1,182 @@
|
||||
# Svelte + Vite
|
||||
# SmartHome Web Application
|
||||
|
||||
This template should help get you started developing with Svelte in Vite.
|
||||
A modern smart home management system built with Svelte frontend and Node.js/Express backend with MongoDB integration.
|
||||
|
||||
## Recommended IDE Setup
|
||||
## 📁 Proje Yapısı
|
||||
|
||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
||||
|
||||
## Need an official Svelte framework?
|
||||
|
||||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
||||
|
||||
## Technical considerations
|
||||
|
||||
**Why use this over SvelteKit?**
|
||||
|
||||
- It brings its own routing solution which might not be preferable for some users.
|
||||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
||||
|
||||
This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
||||
|
||||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
||||
|
||||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
|
||||
|
||||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
|
||||
|
||||
**Why include `.vscode/extensions.json`?**
|
||||
|
||||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
||||
|
||||
**Why enable `checkJs` in the JS template?**
|
||||
|
||||
It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration.
|
||||
|
||||
**Why is HMR not preserving my local component state?**
|
||||
|
||||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/sveltejs/svelte-hmr/tree/master/packages/svelte-hmr#preservation-of-local-state).
|
||||
|
||||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
||||
|
||||
```js
|
||||
// store.js
|
||||
// An extremely simple external store
|
||||
import { writable } from 'svelte/store'
|
||||
export default writable(0)
|
||||
```
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user