> For the complete documentation index, see [llms.txt](https://docs.devonyx.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devonyx.fr/getting-started/publish-your-docs.md).

# Installation & Démarrage

### Prérequis

| Outil   | Version minimale              | Utilisation                      |
| ------- | ----------------------------- | -------------------------------- |
| Node.js | 18+ (recommandé 20 ou 22 LTS) | Runtime backend & build frontend |
| npm     | fourni avec Node              | Gestion des dépendances          |
| MySQL   | 5.7+ ou MariaDB 10+           | Base de données                  |
| Git     | toute version récente         | Récupération du code             |

### 1. Clone le repository

```bash
git clone https://github.com/t3mq/Dashfarm.git
cd Dashfarm

```

### 2. Installer les dépendances

#### Backend

```bash
cd server
npm install
```

#### Frontend

```bash
cd client
npm install
```

### 3. Configurer la base de données

#### Créer la base et les tables

Depuis la racine du projet :&#x20;

```bash
mysql -u root -p -e "CREATE DATABASE agriculture_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -p agriculture_db < BDD/schema.sql
```

#### Charger le jeu de données de test (recommandé)

```bash
mysql -u root -p agriculture_db < BDD/data.sql
```

#### Vérifier via phpMyAdmin

Ouvre `http://localhost/phpmyadmin`  et vérifie que la base `agriculture_db` contient bien les tables : `utilisateur`, `parcelle`, `observation`, `meteo`,  `alerte`, `regle_alerte`, `historique_culture` .

> La table `type_culture` est créée automatiquement au démarrage du serveur (voir le contrôleur `type_culture.controller.js`).

### 4. Configurer les variables d'environnement

Créer un fichier `.env` dans le dossier `server/`

```dotenv
# Base de données
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=ton_mot_de_passe
DB_NAME=agriculture_db

# Serveur
PORT=3000

# JWT (obligatoire)
JWT_SECRET=remplace_par_une_chaine_aleatoire_longue
JWT_EXPIRES_IN=7d
```

Un fichier `.env` côté client est optionnel. Par défaut, le frontend appelle /api et le proxy Vite redirige vers `http://localhost:3000` (voir `vite.config.ts` )

Si tu veux pointer vers un backend distant en dev :&#x20;

```dotenv
# client/.env
VITE_API_URL=https://mon-domaine.fr/api
```

### 5. Lancer l'application en développement

Ouvrir deux terminaux.

**Terminal 1 :** **BACKEND**

```bash
cd server
npm run dev
```

-> Le serveur écoute sur `http://localhost:3000`

**Terminal 2 :** **Frontend**&#x20;

```bash
cd client
npm run dev
```

-> Vite ouvre l'app sur `http://localhost:5173`

### 6. Premier test

1. Aller sur `http://localhost:5173`&#x20;
2. Cliquer sur "S'inscrire" et créer un compte
3. Tu es redirigé vers le tableau de bord
4. Naviguer vers Parcelles, Cultures, Météo, Alertes

### Build de production (frontend)

```bash
cd client
npm run build
```

Le build se trouve dans `client/dist/` . C'est ce dossier qui sera servi par Nginx en production.

### Démarrer le serveur en production

```bash
cd server
npm start
```

> Pour la production, il faut utiliser PM2 plutôt que `npm start`  (voir la page **Déploiement & Infrastructure**).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devonyx.fr/getting-started/publish-your-docs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
