init
This commit is contained in:
163
README.md
Normal file
163
README.md
Normal file
@ -0,0 +1,163 @@
|
||||
# mb-app — Application Marchand de Biens
|
||||
|
||||
Application mobile et web pour la gestion quotidienne d'une activité de marchand de biens immobiliers.
|
||||
|
||||
**Stack :** React Native (Expo) + PocketBase (self-hosted sur NAS Synology) + IA Claude
|
||||
|
||||
---
|
||||
|
||||
## Démarrage rapide
|
||||
|
||||
### Prérequis
|
||||
- Docker Desktop (Mac/Windows) ou Docker Engine (Linux/NAS)
|
||||
- Node.js 18+
|
||||
- Un compte DuckDNS (gratuit) pour l'accès distant
|
||||
|
||||
### 1. Cloner le projet
|
||||
|
||||
```bash
|
||||
git clone https://github.com/VOUS/mb-app.git
|
||||
cd mb-app
|
||||
```
|
||||
|
||||
### 2. Setup initial
|
||||
|
||||
```bash
|
||||
make setup
|
||||
# → Crée les dossiers nécessaires
|
||||
# → Copie .env.example en .env.local
|
||||
```
|
||||
|
||||
Éditer `.env.local` :
|
||||
```
|
||||
EXPO_PUBLIC_PB_URL=http://localhost:8090
|
||||
ANTHROPIC_API_KEY=sk-ant-VOTRE_CLE
|
||||
```
|
||||
|
||||
### 3. Lancer en développement
|
||||
|
||||
```bash
|
||||
# Terminal 1 — Backend PocketBase
|
||||
make dev
|
||||
# → PocketBase sur http://localhost:8090
|
||||
# → Admin sur http://localhost:8090/_/
|
||||
|
||||
# Terminal 2 — App Expo
|
||||
cd app
|
||||
npm install
|
||||
npx expo start
|
||||
```
|
||||
|
||||
**Première fois :** Aller sur http://localhost:8090/_/ → créer le compte admin
|
||||
→ Settings → Import collections → coller le contenu de `pocketbase/pb_collections.json`
|
||||
|
||||
---
|
||||
|
||||
## Déploiement sur le NAS Synology
|
||||
|
||||
### 1. Cloner sur le NAS
|
||||
|
||||
```bash
|
||||
# Se connecter en SSH au NAS
|
||||
ssh admin@IP_DU_NAS
|
||||
|
||||
# Cloner le projet
|
||||
git clone https://github.com/VOUS/mb-app.git /volume1/docker/mb-app
|
||||
cd /volume1/docker/mb-app
|
||||
```
|
||||
|
||||
### 2. Configurer l'environnement production
|
||||
|
||||
```bash
|
||||
make setup-nas
|
||||
# Puis éditer .env.production :
|
||||
nano .env.production
|
||||
```
|
||||
|
||||
```
|
||||
EXPO_PUBLIC_PB_URL=https://mon-sous-domaine.duckdns.org
|
||||
ANTHROPIC_API_KEY=sk-ant-VOTRE_CLE
|
||||
DUCKDNS_SUBDOMAINS=mon-sous-domaine
|
||||
DUCKDNS_TOKEN=VOTRE_TOKEN_DUCKDNS
|
||||
```
|
||||
|
||||
### 3. Ouvrir les ports sur votre box internet
|
||||
- Port 80 → IP du NAS, port 80
|
||||
- Port 443 → IP du NAS, port 443
|
||||
|
||||
### 4. Obtenir le certificat SSL
|
||||
|
||||
```bash
|
||||
make ssl
|
||||
```
|
||||
|
||||
### 5. Lancer la stack
|
||||
|
||||
```bash
|
||||
make prod
|
||||
```
|
||||
|
||||
### Mettre à jour après un git push
|
||||
|
||||
```bash
|
||||
# Sur le NAS :
|
||||
make deploy
|
||||
# → git pull + restart PocketBase (les hooks sont rechargés)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow de développement
|
||||
|
||||
```
|
||||
[Local] Coder + tester
|
||||
↓
|
||||
git add . && git commit -m "feat: module visites"
|
||||
↓
|
||||
git push origin main
|
||||
↓
|
||||
[NAS] make deploy
|
||||
```
|
||||
|
||||
Les **données** (`pb_data/`) restent sur chaque machine et ne sont jamais dans Git.
|
||||
Le **code** (hooks, migrations, app) est versionné et déployé via Git.
|
||||
|
||||
---
|
||||
|
||||
## Structure du projet
|
||||
|
||||
```
|
||||
mb-app/
|
||||
├── app/ ← Code React Native (Expo Router)
|
||||
├── pocketbase/
|
||||
│ ├── pb_hooks/ ← Hooks JS côté serveur (IA, etc.)
|
||||
│ ├── pb_migrations/ ← Migrations auto PocketBase
|
||||
│ └── pb_collections.json ← Schéma des collections
|
||||
├── docker/
|
||||
│ ├── docker-compose.dev.yml
|
||||
│ ├── docker-compose.prod.yml
|
||||
│ └── nginx.prod.conf
|
||||
├── .cursorrules ← Contexte pour Cursor AI
|
||||
├── AGENTS.md ← Suivi des sessions de développement
|
||||
└── Makefile ← Raccourcis commandes
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Commandes utiles
|
||||
|
||||
| Commande | Description |
|
||||
|---|---|
|
||||
| `make dev` | Lance PocketBase en local |
|
||||
| `make dev-stop` | Arrête le dev |
|
||||
| `make logs` | Logs en temps réel |
|
||||
| `make prod` | Lance la stack NAS |
|
||||
| `make deploy` | git pull + redémarre (sur NAS) |
|
||||
| `make renew-ssl` | Renouvelle le certificat SSL |
|
||||
|
||||
---
|
||||
|
||||
## Backup des données
|
||||
|
||||
Les données PocketBase sont dans `pb_data/` (exclu du Git).
|
||||
Configurer une tâche Synology Hyper Backup sur `/volume1/docker/mb-app/pb_data/`.
|
||||
Reference in New Issue
Block a user