Skip to content
@MyHouse-OS

MyHouse OS

🏠 MyHouse OS - Système de Domotique Automatisée

Latest Release

API Dashboard ESP32

codecov License


Système de domotique professionnel avec architecture distribuée ESP32 + Serveur Backend API + Dashboard Next.js

ArchitectureInstallationAPISécuritéTests


🚀 Quick Start

# Télécharger la dernière release
curl -L https://github.com/MyHouse-OS/MyHouseOS/releases/latest/download/docker-compose.yml -o docker-compose.yml

# Lancer les services
docker-compose up -d

📦 Les images Docker sont automatiquement récupérées depuis GitHub Container Registry


📦 Écosystème MyHouse OS

Orchestration & Releases

Release v1.1 Release v1.0

Script de déploiement unifié

API

Backend Bun + Elysia

Docker Image

REST API • WebSocket • PostgreSQL

🖥️ Dashboard

Frontend Next.js

Docker Image

Interface temps réel responsive

Access Point & Router

Point d'accès WiFi • Auth 2FA matérielle

🌡️ ESP Emitter

Capteur & Contrôle

Température • Lumière • Chauffage • Porte

Afficheur & LED

Dashboard physique • Indicateurs LED


📋 Table des Matières


🌟 Vue d'ensemble

MyHouse OS est un système de domotique ultra-sécurisé et entièrement automatisé, construit autour d'une architecture distribuée robuste. Le projet combine des microcontrôleurs ESP32, un backend haute performance basé sur Bun, et un dashboard web responsive développé avec Next.js.

Caractéristiques Principales

Architecture Distribuée - 3 ESP32 (1 serveur + 2 clients) avec répartition intelligente des rôles
🔐 Sécurité Renforcée - Authentification à deux facteurs matérielle avec validation manuelle
Temps Réel - WebSocket bidirectionnel pour synchronisation instantanée
🤖 Automatisation Intelligente - Moteur de règles événementielles avec 4+ scénarios prédéfinis
📊 Historique Complet - Enregistrement de tous les événements pour analyse et dashboards
🧪 Testabilité Professionnelle - Suite de tests complète avec couverture de code
📖 Documentation Swagger - API REST auto-documentée et interactive


🏗 Architecture

Topologie Réseau

Le système utilise un réseau Wi-Fi isolé avec allocation IP statique garantissant la sécurité et la stabilité.

┌─────────────────────────────────────────────────────────────────┐
│                    ESP32 SERVEUR (AP Mode)                      │
│                      IP: 192.168.4.1                            │
│                                                                 │
│  • Point d'accès WiFi principal                                 │
│  • Gestion des requêtes /link                                   │
│  • Validation manuelle 2FA (boutons Accept/Reject)              │
└─────────────────────────────────────────────────────────────────┘
                              │
        ┌─────────────────────┼─────────────────────┐
        │                     │                     │
        ▼                     ▼                     ▼
┌───────────────┐   ┌───────────────┐   ┌───────────────┐
│  BUN SERVER   │   │   NEXT.JS     │   │ ESP CLIENTS   │
│ 192.168.4.2   │   │ 192.168.4.3   │   │ 192.168.4.4/5 │
│   :3000       │   │   :8080       │   │               │
├───────────────┤   ├───────────────┤   ├───────────────┤
│ • API REST    │   │ • Dashboard   │   │ • Client #1:  │
│ • WebSocket   │◄──┤ • Real-time   │   │   Capteur     │
│ • DB          │   │   updates     │   │   Température │
│ • Rules       │   │ • Responsive  │   │               │
│ • History     │   │               │   │ • Client #2:  │
│               │   │               │   │   Affichage   │
│               │   │               │   │   + LED       │
└───────────────┘   └───────────────┘   └───────────────┘
         │                                      ▲
         │                                      │
         └──────────────────────────────────────┘
              Authentification & Contrôle

Ordre de Connexion Critique ⚠️

L'ordre de connexion est impératif pour le bon fonctionnement du système :

  1. ESP Serveur démarre en mode AP → 192.168.4.1
  2. PC Serveur API se connecte au WiFi ESP → reçoit 192.168.4.2
  3. Lancement Docker (docker-compose up)
  4. PC Serveur Next.js se connecte → reçoit 192.168.4.3
  5. ESP Clients se connectent → reçoivent 192.168.4.4 et 192.168.4.5

Composants Matériels

Composant Rôle IP Description
ESP32 Serveur Access Point + Router 192.168.4.1 Gestion réseau, authentification 2FA, routage des requêtes /link
ESP32 Client #1 Capteur Actif 192.168.4.4 Mesure température toutes les 3s, contrôle lumière/chauffage/porte
ESP32 Client #2 Afficheur Passif 192.168.4.5 Lecture état système, LED de statut, rafraîchissement toutes les 5s
PC Docker Backend Server 192.168.4.2:3000 Bun runtime, PostgreSQL, API REST, WebSocket
PC Dashboard Frontend Server 192.168.4.3:8080 Next.js, interface responsive, temps réel

🛠 Stack Technique

Backend (Bun Server)

{
  "runtime": "Bun 1.x",
  "framework": "Elysia.js 1.4.19",
  "database": "PostgreSQL 16 Alpine",
  "orm": "Prisma 7.1.0",
  "language": "TypeScript 5.x",
  "containerization": "Docker + Docker Compose"
}

Dépendances Principales :

  • 🚀 Elysia - Framework web ultra-rapide pour Bun
  • 📖 @elysiajs/swagger - Documentation API interactive
  • 🔌 WebSocket natif - Communication temps réel
  • 🔒 Cryptographie native Bun - Hash de mots de passe bcrypt
  • 🗄️ Prisma - ORM type-safe avec migrations automatiques
  • 🐘 PostgreSQL - Base de données relationnelle

Outils de Développement :

  • Biome - Linter & Formatter ultra-rapide (remplace ESLint + Prettier)
  • 🧪 Bun Test - Runner de tests natif avec couverture de code
  • 🔍 Knip - Détection de code mort et imports inutilisés
  • 🪝 Lefthook - Git hooks pour CI/CD local

Frontend (Dashboard)

  • Next.js 14+ - Framework React avec SSR/SSG
  • WebSocket Client - Connexion persistante au serveur Bun
  • Responsive Design - Compatible mobile/tablette/desktop

Hardware

  • ESP32
  • Capteur Température
  • LED RGB
  • Boutons physiques

📦 Installation & Déploiement

Prérequis

  • Bun ≥ 1.0.0
  • Docker + Docker Compose
  • PostgreSQL 16 (via Docker)
  • Node.js 18+ (pour Next.js Dashboard)

Installation Locale (Développement)

# 1. Cloner le dépôt
git clone <repository-url>
cd BunServer

# 2. Installer les dépendances
bun install

# 3. Configuration environnement
cp .env.example .env
# Éditer .env avec vos paramètres

# 4. Démarrer PostgreSQL
docker-compose up db -d

# 5. Initialiser la base de données
bun run prisma:migrate
bun run seed

# 6. Générer le client Prisma
bun run prisma:generate

# 7. Démarrer le serveur
bun run start

Déploiement Production (Docker)

# Construction et démarrage de tous les services
docker-compose up --build -d

# Vérification des logs
docker-compose logs -f app

# Exécution des seeds (première fois)
docker-compose exec app bun run seed

Le serveur sera accessible sur :

  • 🔗 API : http://192.168.4.2:3000
  • 📖 Swagger : http://192.168.4.2:3000/swagger
  • 🔌 WebSocket : ws://192.168.4.2:3000/ws

🌐 Configuration Réseau

Configuration ESP32 Serveur (AP Mode)

// Configuration Point d'Accès
const char* ssid = "MyHouseOS";
const char* password = "12345678";

IPAddress localIP(192, 168, 4, 1);
IPAddress gateway(192, 168, 4, 1);
IPAddress subnet(255, 255, 255, 0);

WiFi.softAPConfig(localIP, gateway, subnet);
WiFi.softAP(ssid, password);

Configuration ESP32 Clients (Station Mode)

WiFi.begin("MyHouseOS", "SuperSecurePassword123!");

// Attendre l'attribution IP
while (WiFi.status() != WL_CONNECTED) {
  delay(500);
}

// IP attribuée automatiquement : 192.168.4.4 ou .5

Variables d'Environnement (Backend)

# Database
DATABASE_URL="postgresql://root:root@db:5432/myhouse"

# Server
PORT_BUN_SERVER=3000
PORT_WEB_SERVER=8080
NODE_ENV=production

# Security (optionnel - utilise des clés par défaut)
ENCRYPTION_KEY=your-32-char-secret-key-here
ENCRYPTION_SALT=your-fixed-salt-here

🔐 Authentification & Sécurité

Architecture de Sécurité Multi-Niveaux

Le système implémente une authentification à deux facteurs matérielle (Hardware 2FA) unique en son genre.

1️⃣ Processus d'Enregistrement Client ESP

sequenceDiagram
    participant User as Utilisateur
    participant EC as ESP Client
    participant ES as ESP Serveur
    participant BS as Bun Server
    participant DB as PostgreSQL

    User->>EC: Appuie sur bouton "Link"
    EC->>ES: POST /link { id: "clientID" }
    ES->>User: Attente validation (LED clignote)
    User->>ES: Appuie bouton "Accept" ou "Reject"
    
    alt Accepté
        ES->>BS: GET /check?id=clientID
        BS->>DB: SELECT * FROM Client WHERE id=clientID
        
        alt Client existe déjà
            DB-->>BS: { exists: true, token: "abc123" }
            BS-->>ES: { exists: true, token: "abc123" }
            ES-->>EC: 200 OK { token: "abc123" }
        else Nouveau client
            DB-->>BS: { exists: false }
            ES->>ES: Génère token aléatoire
            ES->>BS: POST /auth { id: "clientID", token: "xyz789" }
            Note over ES,BS: Headers: Authorization: master:master
            BS->>DB: INSERT INTO Client VALUES (...)
            DB-->>BS: Success
            BS-->>ES: 200 OK
            ES-->>EC: 200 OK { token: "xyz789" }
        end
        
        EC->>EC: Stocke token en EEPROM
    else Rejeté
        ES-->>EC: 403 Forbidden
    end
Loading

2️⃣ Authentification Requêtes API

Toutes les routes (sauf / et /swagger) nécessitent l'en-tête :

Authorization: clientID:token

Exemple :

curl -X POST http://192.168.4.2:3000/temp \
  -H "Authorization: LivingRoomESP:a1b2c3d4e5f6" \
  -H "Content-Type: application/json" \
  -d '{"temp": "22.5"}'

3️⃣ Middleware de Vérification

// src/middleware/auth.ts
export const authMiddleware = (app: Elysia) =>
  app.derive(async ({ headers, set }) => {
    const [clientId, clientToken] = headers.authorization.split(":");
    
    // Récupération client en DB
    const client = await prisma.client.findUnique({
      where: { ClientID: clientId }
    });
    
    // Vérification token crypté
    const decryptedToken = decrypt(client.ClientToken);
    if (decryptedToken !== clientToken) {
      throw new Error("Invalid credentials");
    }
    
    return { user: client };
  });

4️⃣ Cryptographie

Tokens ESP : Chiffrement AES-256 symétrique

// src/utils/crypto.ts
import { createCipheriv, createDecipheriv } from "crypto";

export const encrypt = (text: string): string => {
  const cipher = createCipheriv("aes-256-cbc", SECRET_KEY, IV);
  return cipher.update(text, "utf8", "hex") + cipher.final("hex");
};

Mots de passe Dashboard : Bcrypt avec salting automatique

// Utilise le hachage natif Bun (Argon2 ou bcrypt)
const passwordHash = await Bun.password.hash("root");

5️⃣ Comptes par Défaut (Seeding)

Type ID Token/Password Table Usage
Master master master Client Authentification ESP Serveur → API /auth
Root User root root User Connexion Dashboard administrateur
Dashboard Client root root Client Authentification Dashboard → API

⚠️ Important : Changer ces valeurs en production !


🗄️ Base de Données

Schéma Prisma

// prisma/schema.prisma

model User {
  id       Int    @id @default(autoincrement())
  username String @unique
  password String  // Hash bcrypt
}

model Client {
  id          Int    @id @default(autoincrement())
  ClientID    String @unique  // Identifiant ESP unique
  ClientToken String          // Token AES-256 chiffré
}

model HomeState {
  id          Int      @id @default(autoincrement())
  temperature String              // °C en string pour précision
  light       Boolean  @default(false)
  door        Boolean  @default(false)
  heat        Boolean  @default(false)
  updatedAt   DateTime @default(now()) @updatedAt
  createdAt   DateTime @default(now())
}

model History {
  id        Int       @id @default(autoincrement())
  type      EventType // TEMPERATURE | LIGHT | DOOR | HEAT
  value     String
  createdAt DateTime  @default(now())
}

enum EventType {
  TEMPERATURE
  LIGHT
  DOOR
  HEAT
}

Migrations

# Créer une nouvelle migration
bun run prisma:migrate

# Pousser le schéma (développement rapide)
bun run prisma:push

# Visualiser la DB (interface GUI)
bun run prisma:studio

📡 API Reference

Endpoints Publics

GET /

Affiche la bannière ASCII MyHouse OS.

curl http://192.168.4.2:3000/

Réponse :

 __  __       _   _                         ___  ____  
|  \/  |_   _| | | | ___  _   _ ___  ___   / _ \/ ___| 
| |\/| | | | | |_| |/ _ \| | | / __|/ _ \ | | | \___ \ 
| |  | | |_| |  _  | (_) | |_| \__ \  __/ | |_| |___) |
|_|  |_|\__, |_| |_|\___/ \__,_|___/\___|  \___/|____/ 
        |___/                                          

GET /swagger

Documentation API interactive Swagger UI.

http://192.168.4.2:3000/swagger

Authentification

POST /auth 🔐

Enregistrement d'un nouveau client ESP

Headers :

Authorization: master:master

Body :

{
  "id": "LivingRoomESP",
  "token": "a1b2c3d4e5f6"
}

Réponse :

{
  "status": "OK",
  "message": "Client LivingRoomESP registered successfully",
  "client": "LivingRoomESP"
}

GET /check 🔐

Vérifier l'existence d'un client

Headers :

Authorization: master:master

Query :

?id=LivingRoomESP

Réponse (existe) :

{
  "exists": true,
  "token": "a1b2c3d4e5f6"
}

Réponse (n'existe pas) :

{
  "exists": false
}

Température

GET /temp 🔐

Récupérer la température actuelle

Headers :

Authorization: LivingRoomESP:a1b2c3d4e5f6

Réponse :

{
  "temp": "22.5",
  "status": "OK"
}

POST /temp 🔐

Mettre à jour la température

Headers :

Authorization: LivingRoomESP:a1b2c3d4e5f6
Content-Type: application/json

Body :

{
  "temp": "23.5"
}

Réponse :

{
  "message": "Temperature updated",
  "temp": "23.5",
  "status": "OK"
}

Side Effects :

  • ✅ Enregistrement dans History table
  • ✅ Émission événement STATE_CHANGE → déclenchement règles
  • ✅ Broadcast WebSocket → mise à jour Dashboard temps réel

Contrôles Domotiques

GET /toggle/light 🔐

Récupérer l'état de la lumière

Réponse :

{
  "light": true,
  "status": "OK"
}

POST /toggle/light 🔐

Inverser l'état de la lumière

Réponse :

{
  "message": "Light toggled",
  "light": false,
  "status": "OK"
}

GET /toggle/heat 🔐

Récupérer l'état du chauffage

Réponse :

{
  "heat": true,
  "status": "OK"
}

POST /toggle/heat 🔐

Inverser l'état du chauffage

Réponse :

{
  "message": "Heat toggled",
  "heat": false,
  "status": "OK"
}

GET /toggle/door 🔐

Récupérer l'état de la porte

Réponse :

{
  "door": false,
  "status": "OK"
}

POST /toggle/door 🔐

Inverser l'état de la porte

Réponse :

{
  "message": "Door toggled",
  "door": true,
  "status": "OK"
}

Historique

GET /history 🔐

Récupérer l'historique des événements

Query Parameters (optionnel) :

?type=TEMPERATURE&limit=50

Réponse :

{
  "history": [
    {
      "id": 1,
      "type": "TEMPERATURE",
      "value": "22.5",
      "createdAt": "2025-12-21T14:30:00.000Z"
    },
    {
      "id": 2,
      "type": "LIGHT",
      "value": "true",
      "createdAt": "2025-12-21T14:25:00.000Z"
    }
  ],
  "count": 2
}

WebSocket

WS /ws

Connexion temps réel pour mises à jour automatiques

URL :

ws://192.168.4.2:3000/ws

Événements (voir section WebSocket ci-dessous)


🤖 Règles d'Automatisation

Le système intègre un moteur de règles événementielles qui s'exécute automatiquement à chaque changement d'état.

Architecture du Moteur

// src/rules/engine.ts
export const initRuleEngine = () => {
  eventBus.on(EVENTS.STATE_CHANGE, async () => {
    const currentState = await HomeStateService.get();
    
    for (const rule of RULES) {
      if (rule.condition(currentState)) {
        await rule.action();
      }
    }
  });
};

Règles Prédéfinies

1️⃣ HEAT_ON_COLD - Chauffage Automatique Hiver

Condition :

temp < 19°C && heat === false && door === false

Action :

🔥 Active le chauffage automatiquement

Exemple :

Il fait 18°C, la porte est fermée et le chauffage est éteint.
→ Le système active automatiquement le chauffage.


2️⃣ HEAT_OFF_HOT - Économie d'Énergie Température Confortable

Condition :

temp > 23°C && heat === true

Action :

❄️ Désactive le chauffage (confort atteint)

Exemple :

La température atteint 24°C grâce au chauffage.
→ Le système coupe automatiquement le chauffage pour éviter la surchauffe.


3️⃣ LIGHT_ON_ENTRY - Éclairage Automatique d'Accueil

Condition :

door === true && light === false

Action :

💡 Allume la lumière (bienvenue)

Exemple :

La porte s'ouvre et la lumière est éteinte.
→ Le système allume automatiquement la lumière pour accueillir.


4️⃣ ECO_GUARD_DOOR - Garde Économie Énergie

Condition :

door === true && heat === true

Action :

💸 Coupe le chauffage (porte ouverte = gaspillage)

Exemple :

La porte est ouverte alors que le chauffage fonctionne.
→ Le système coupe immédiatement le chauffage pour économiser l'énergie.


Personnalisation des Règles

export const RULES: Rule[] = [
  // ... règles existantes
  {
    id: "NIGHT_MODE",
    description: "Turn off lights at 23:00",
    condition: (state) => {
      const hour = new Date().getHours();
      return hour === 23 && state.light === true;
    },
    action: async () => {
      await HomeStateService.setLight(false);
    }
  }
];

🔌 WebSocket & Temps Réel

Architecture Pub/Sub

Le serveur utilise un système de publication/souscription basé sur EventEmitter pour la communication temps réel.

// src/utils/eventBus.ts
export const eventBus = new EventEmitter();

export const EVENTS = {
  STATE_CHANGE: "STATE_CHANGE",
  NEW_CONNECTION: "NEW_CONNECTION"
};

Connexion WebSocket

Endpoint : ws://192.168.4.2:3000/ws

Messages WebSocket

INIT - État Initial

Envoyé immédiatement après la connexion.

{
  "type": "INIT",
  "data": {
    "id": 1,
    "temperature": "22.5",
    "light": true,
    "door": false,
    "heat": true,
    "updatedAt": "2025-12-21T14:30:00.000Z",
    "createdAt": "2025-12-21T10:00:00.000Z"
  }
}

UPDATE - Changement d'État

Envoyé à chaque modification (POST /temp, /toggle/*).

Exemple Température :

{
  "type": "UPDATE",
  "data": {
    "type": "TEMPERATURE",
    "value": "23.5"
  }
}

Exemple Toggle :

{
  "type": "UPDATE",
  "data": {
    "type": "LIGHT",
    "value": "false"
  }
}

🎛️ ESP Clients - Fonctionnalités

ESP Client #1 - Capteur & Contrôle

IP : 192.168.4.4

Fonctionnalités

1️⃣ Mesure Température Automatique

  • Envoi automatique toutes les 3 secondes
  • Activable/désactivable via bouton toggle
  • Mode manuel toujours disponible (bouton "Envoyer")

2️⃣ Pages de Navigation

  • Page 1 : Authentification (affichage statut connexion)
  • Page 2 : Température (lecture + envoi manuel)
  • Page 3 : Lumière (toggle)
  • Page 4 : Chauffage (toggle)
  • Page 5 : Porte (toggle)

ESP Client #2 - Afficheur & LED

IP : 192.168.4.5

Fonctionnalités

1️⃣ Affichage État Complet

  • Vue unique avec tous les paramètres :
    • 🌡️ Température actuelle
    • 💡 État lumière
    • 🚪 État porte
    • 🔥 État chauffage

2️⃣ Rafraîchissement Automatique

  • Intervalle : 5 secondes
  • Activable/désactivable via bouton
  • Requêtes parallèles pour performance

3️⃣ Indicateurs LED

  • LED 1 : Lumière (ON = allumée, OFF = éteinte)
  • LED 2 : Chauffage (ON = allumé, OFF = éteint)
  • LED 3 : Porte (ON = ouverte, OFF = fermée)

🖥️ Dashboard Web

Fonctionnalités

Design Responsive - Mobile, tablette, desktop
🔄 Temps Réel - Mise à jour instantanée via WebSocket
🎨 UX Intuitive - Dégradé de couleur selon température
📊 Historique Visuel - Graphiques de tendances
📸 Surveillance ESP - Flux quasi-temps réel des écrans ESP
🎛️ Contrôles Interactifs - Toggle depuis le dashboard


🧪 Tests & Qualité

Suite de Tests Complète

# Exécuter tous les tests
bun test

# Tests avec couverture de code
bun test:coverage

# Résultats
✓ routes/auth.test.ts (3 tests)
✓ routes/check.test.ts (4 tests)
✓ routes/features.test.ts (12 tests)
✓ routes/public.test.ts (2 tests)
✓ routes/ws.test.ts (5 tests)
✓ rules/engine.test.ts (8 tests)
✓ utils/crypto.test.ts (4 tests)

Total: 38 tests passed
Coverage: 95.2% statements

Outils de Qualité

# Linting & Formatting (Biome)
bun run lint
bun run format
bun run check  # lint + format ensemble

# Détection code mort
bun run knip

# Exemple sortie Knip
✓ No unused dependencies
✓ No unused files
✓ All exports are used

Git Hooks (Lefthook)

# lefthook.yml
pre-commit:
  commands:
    lint:
      run: bun run check
    test:
      run: bun test

📁 Structure du Projet

BunServer/
├── 📄 index.ts                    # Point d'entrée principal
├── 📄 package.json                # Dépendances & scripts
├── 📄 tsconfig.json               # Configuration TypeScript
├── 📄 biome.json                  # Linter/Formatter config
├── 📄 knip.json                   # Dead code detector
├── 📄 lefthook.yml                # Git hooks
├── 📄 Dockerfile                  # Image Docker multi-stage
├── 📄 compose.yaml                # Orchestration services
├── 📄 DOCUMENTATION.md            # Documentation supplémentaire
├── 📄 INFRASTRUCTURE_NOTES.txt    # Notes architecture (FR)
│
├── 📁 prisma/
│   ├── schema.prisma              # Schéma DB Prisma
│   ├── db.ts                      # Client Prisma configuré
│   ├── seed.ts                    # Données initiales
│   ├── prisma.config.ts           # Configuration Prisma
│   ├── migrations/                # Historique migrations SQL
│   └── generated/                 # Client Prisma généré (auto)
│
├── 📁 src/
│   ├── enums.ts                   # Énumérations globales
│   │
│   ├── 📁 middleware/
│   │   └── auth.ts                # Middleware authentification
│   │
│   ├── 📁 routes/
│   │   ├── index.ts               # Routeur principal
│   │   ├── auth/index.ts          # POST /auth
│   │   ├── check/index.ts         # GET /check
│   │   ├── history/index.ts       # GET /history
│   │   ├── status/index.ts        # GET /status
│   │   ├── temp/index.ts          # GET/POST /temp
│   │   ├── ws/index.ts            # WS /ws
│   │   └── toggle/
│   │       ├── index.ts           # Routeur toggle
│   │       ├── light.ts           # GET/POST /toggle/light
│   │       ├── heat.ts            # GET/POST /toggle/heat
│   │       └── door.ts            # GET/POST /toggle/door
│   │
│   ├── 📁 rules/
│   │   ├── definitions.ts         # Définition des règles
│   │   └── engine.ts              # Moteur d'exécution
│   │
│   ├── 📁 services/
│   │   └── homeState.ts           # Service métier HomeState
│   │
│   └── 📁 utils/
│       ├── crypto.ts              # AES-256 encrypt/decrypt
│       └── eventBus.ts            # EventEmitter pub/sub
│
└── 📁 tests/
    ├── routes/                    # Tests endpoints API
    │   ├── auth.test.ts
    │   ├── check.test.ts
    │   ├── features.test.ts
    │   ├── public.test.ts
    │   └── ws.test.ts
    ├── rules/
    │   └── engine.test.ts         # Tests moteur de règles
    └── utils/
        └── crypto.test.ts         # Tests cryptographie

🚀 Développement

Scripts Disponibles

# Démarrage serveur
bun run start                 # Production
bun run dev                   # Développement (avec watch)

# Base de données
bun run prisma:generate       # Générer client Prisma
bun run prisma:migrate        # Créer migration
bun run prisma:push           # Push schéma (sans migration)
bun run prisma:studio         # Interface GUI DB
bun run seed                  # Initialiser données

# Qualité de code
bun run lint                  # Vérifier code
bun run format                # Formater code
bun run check                 # Lint + Format
bun run knip                  # Détecter code mort

# Tests
bun test                      # Tests unitaires
bun test:coverage             # Avec couverture

Workflow Développement

  1. Créer une branche
git checkout -b feature/new-rule
  1. Développer & Tester
bun run check  # Vérifier qualité
bun test       # Lancer tests
  1. Commit (hooks automatiques)
git add .
git commit -m "feat: add night mode rule"
# ✓ Lefthook exécute lint + tests automatiquement
  1. Push & PR
git push origin feature/new-rule

Variables d'Environnement

Créer .env à la racine :

# Database
DATABASE_URL="postgresql://root:root@localhost:5432/myhouse"

# Server
PORT_BUN_SERVER=3000
PORT_WEB_SERVER=8080
NODE_ENV=development

# Crypto (optionnel)
ENCRYPTION_KEY=your-32-character-secret-key
ENCRYPTION_SALT="MyFixedSalt"

📚 Ressources

Documentation Technique

Outils Utilisés

  • 🚀 Bun - Runtime JavaScript ultra-rapide
  • Elysia - Framework web pour Bun
  • 🗄️ Prisma - ORM moderne type-safe
  • 🧪 Biome - Toolchain tout-en-un
  • 🐳 Docker - Containerisation

👨‍💻 Contributeurs

Projet développé dans le cadre de l'évaluation du module de domotique.


🆘 Support & Contact

Pour toute question ou problème :

  1. Consulter la documentation Swagger
  2. Vérifier les logs Docker
  3. Tester avec Prisma Studio

⚡ Construit avec Bun - Le runtime JavaScript le plus rapide au monde

Made with ❤️ by Antoine, Ilian, François et Hugo

Popular repositories Loading

  1. API API Public

    Backend domotique haute performance pour MyHouse OS. API REST et WebSocket temps réel, moteur d'automatisation basé sur règles, historique des événements et contrôle IoT (lumière, chauffage, porte,…

    TypeScript

  2. EspServer EspServer Public

    Serveur ESP32 autonome pour gestion et authentification de dispositifs IoT. Point d'accès WiFi avec interface graphique M5CoreS3, validation manuelle des pairings et système de tokens.

    C++

  3. Dashboard Dashboard Public

    Tableau de bord domotique intégrant la supervision et le pilotage en temps réel d’équipements IoT (ESP32/M5Stack) via WebSocket, avec détection de présence intelligente et gestion de workflows d’au…

    TypeScript

  4. EspClientMonitoring EspClientMonitoring Public

    Client domotique IoT pour M5Stack CoreS3 avec interface graphique temps réel, streaming d'écran HTTP et contrôle LED synchronisé. Surveillance de lumière, chauffage, porte et température via WiFi/J…

    C++

  5. .github .github Public

    Github profile for organization.

  6. MyHouseOS MyHouseOS Public

    🏠 Système d'exploitation pour maison connectée - Contrôlez lumières, chauffage, portes et température via API REST, dashboard web et assistants IA (protocole MCP). Prêt pour Docker avec simulateur …

    TypeScript

Repositories

Showing 7 of 7 repositories
  • .github Public

    Github profile for organization.

    MyHouse-OS/.github’s past year of commit activity
    0 0 0 0 Updated Dec 29, 2025
  • MyHouseOS Public

    🏠 Système d'exploitation pour maison connectée - Contrôlez lumières, chauffage, portes et température via API REST, dashboard web et assistants IA (protocole MCP). Prêt pour Docker avec simulateur ESP32.

    MyHouse-OS/MyHouseOS’s past year of commit activity
    TypeScript 0 0 0 0 Updated Dec 29, 2025
  • API Public

    Backend domotique haute performance pour MyHouse OS. API REST et WebSocket temps réel, moteur d'automatisation basé sur règles, historique des événements et contrôle IoT (lumière, chauffage, porte, température).

    MyHouse-OS/API’s past year of commit activity
    TypeScript 0 0 0 0 Updated Dec 29, 2025
  • Dashboard Public

    Tableau de bord domotique intégrant la supervision et le pilotage en temps réel d’équipements IoT (ESP32/M5Stack) via WebSocket, avec détection de présence intelligente et gestion de workflows d’automatisation.

    MyHouse-OS/Dashboard’s past year of commit activity
    TypeScript 0 0 0 0 Updated Dec 28, 2025
  • EspClientEmitter Public

    Client émetteur IoT pour M5Stack CoreS3 avec interface graphique tactile, capteur DHT22 et streaming d'écran HTTP. Authentification sécurisée par token, envoi automatique de données météo et contrôle distant d'équipements domotiques (lumière, porte, chauffage).

    MyHouse-OS/EspClientEmitter’s past year of commit activity
    C++ 0 0 0 0 Updated Dec 28, 2025
  • EspServer Public

    Serveur ESP32 autonome pour gestion et authentification de dispositifs IoT. Point d'accès WiFi avec interface graphique M5CoreS3, validation manuelle des pairings et système de tokens.

    MyHouse-OS/EspServer’s past year of commit activity
    C++ 0 0 0 0 Updated Dec 22, 2025
  • EspClientMonitoring Public

    Client domotique IoT pour M5Stack CoreS3 avec interface graphique temps réel, streaming d'écran HTTP et contrôle LED synchronisé. Surveillance de lumière, chauffage, porte et température via WiFi/JSON API.

    MyHouse-OS/EspClientMonitoring’s past year of commit activity
    C++ 0 0 0 0 Updated Dec 21, 2025

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…