first commit

This commit is contained in:
2025-11-07 22:42:41 +03:00
parent 229e182fab
commit 76046e07f0
7 changed files with 266 additions and 66 deletions

1
.env.dev Normal file
View File

@@ -0,0 +1 @@
VITE_API_URL="http://localhost:3000"

1
.env.prod Normal file
View File

@@ -0,0 +1 @@
VITE_API_URL="https://smarthome.wisecolt-panda.net"

1
.serena/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/cache

84
.serena/project.yml Normal file
View File

@@ -0,0 +1,84 @@
# list of languages for which language servers are started; choose from:
# al bash clojure cpp csharp csharp_omnisharp
# dart elixir elm erlang fortran go
# haskell java julia kotlin lua markdown
# nix perl php python python_jedi r
# rego ruby ruby_solargraph rust scala swift
# terraform typescript typescript_vts zig
# Note:
# - For C, use cpp
# - For JavaScript, use typescript
# Special requirements:
# - csharp: Requires the presence of a .sln file in the project folder.
# When using multiple languages, the first language server that supports a given file will be used for that file.
# The first language is the default language and the respective language server will be used as a fallback.
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
languages:
- typescript
# the encoding used by text files in the project
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
encoding: "utf-8"
# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true
# list of additional paths to ignore
# same syntax as gitignore, so you can use * and **
# Was previously called `ignored_dirs`, please update your config if you are using that.
# Added (renamed) on 2025-04-07
ignored_paths: []
# whether the project is in read-only mode
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
# Added on 2025-04-18
read_only: false
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
# Below is the complete list of tools for convenience.
# To make sure you have the latest list of tools, and to view their descriptions,
# execute `uv run scripts/print_tool_overview.py`.
#
# * `activate_project`: Activates a project by name.
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
# * `create_text_file`: Creates/overwrites a file in the project directory.
# * `delete_lines`: Deletes a range of lines within a file.
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
# * `execute_shell_command`: Executes a shell command.
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
# * `initial_instructions`: Gets the initial instructions for the current project.
# Should only be used in settings where the system prompt cannot be set,
# e.g. in clients you have no control over, like Claude Desktop.
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
# * `insert_at_line`: Inserts content at a given line in a file.
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
# * `list_memories`: Lists memories in Serena's project-specific memory store.
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
# * `read_file`: Reads a file within the project directory.
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
# * `remove_project`: Removes a project from the Serena configuration.
# * `replace_lines`: Replaces a range of lines within a file with new content.
# * `replace_symbol_body`: Replaces the full definition of a symbol.
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
# * `search_for_pattern`: Performs a search for a pattern in the project.
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
# * `switch_modes`: Activates modes by providing a list of their names
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
excluded_tools: []
# initial prompt for the project. It will always be given to the LLM upon activating the project
# (contrary to the memories, which are loaded on demand).
initial_prompt: ""
project_name: "smarthome"
included_optional_tools: []

221
README.md
View File

@@ -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.

0
api/.env.mongo Normal file
View File

View File

@@ -5,34 +5,12 @@ const config = {
// Site Url // Site Url
baseURL: process.env.BASE_URL, baseURL: process.env.BASE_URL,
port: process.env.PORT || 3000, port: process.env.PORT || 3000,
// Veridy Token // Verify Token
verifyToken: process.env.VERIFY_TOKEN, verifyToken: process.env.VERIFY_TOKEN,
// If the Remember me option is not selected
cookieExpirationTimeRememberTrue: parseInt(process.env.COOKIE_EXP_TIME_REMEMBER_TRUE), // 1 mounth
// Remember me option is selected
cookieExpirationTimeRememberFalse: parseInt(process.env.COOKIE_EXP_TIME_REMEMBER_FALSE), // 30 minute
// Token Settings
tookenExpirationTime: parseInt(process.env.TOOKEN_EXP_TIME), // 1 mounth
secret: process.env.SECRET,
// Crypt Salt Secret
cryptoSalt: process.env.CRYPTO_SALT,
// Avatar upload settings
avatarNameLength: 15,
avatarSizeLimit: 250000, // 250 KB
avatarFileTypes: /jpeg|jpg|png/,
// Mongo Settings // Mongo Settings
//mongodburl: process.env.MONGODB_URI_PRO, //mongodburl: process.env.MONGODB_URI_PRO,
mongodburl: process.env.MONGODB_URI, mongodburl: process.env.MONGODB_URI,
// mongodburl: 'mongodb://mongo:27017/jwt' //server // mongodburl: 'mongodb://mongo:27017/jwt' //server
// The Movie DB api key
tmdbApiKey: process.env.TMDB_API_KEY,
// Flixinfo api default language
thmdbDefaultLanguage: "en-US",
// Redis Cache değerleri
redisCacheLength: parseInt(process.env.REDIS_CACHE_LENGTH) || 100, // server başladığında ilk chachelenecek kayıt miktarı
redisTTL: parseInt(process.env.REDIS_TTL) || 86400, // veriler ne kadar süre cachede tutulacak
//redisUrl: process.env.REDIS_URL_PRO,
redisUrl: process.env.REDIS_URL,
}; };
module.exports = config; module.exports = config;