Architecture fullstack avec Next.js, Django REST, SQLite, et Socket.io pour la communication temps réel.
tp3-monorepo/
├── packages/
│ ├── frontend/ # Application Next.js (React)
│ ├── backend/ # API Django REST (Python)
│ ├── api/ # Socket.io Server (Node.js/Express)
│ └── shared/ # Types partagés
├── QUICKSTART.md # Guide de démarrage rapide
└── README.md # Ce fichier
cd packages/backend
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # macOS/Linux
pip install -r requirements.txt
python manage.py migrate
python manage.py runservercd packages/frontend
npm install
npm run devcd packages/api
npm install
npm run devOuvre ton navigateur et vérifie que tout fonctionne :
| Service | URL | Statut |
|---|---|---|
| Frontend | http://localhost:3000 | Doit charger l'app |
| Backend | http://localhost:8000/api/health/ | Doit afficher {"status": "healthy"} |
| Admin Django | http://localhost:8000/admin | Doit afficher la page login |
| API Socket.io | http://localhost:8001 | Doit accepter les connexions |
| Composant | Stack |
|---|---|
| Frontend | Next.js 14 + TypeScript + Tailwind CSS + Zustand + TanStack Query |
| Backend | Django 4.2 + Django REST Framework + SQLite |
| API Temps réel | Express.js + Socket.io |
Copier .env.example en .env.
Les valeurs par défaut fonctionnent avec SQLite :
DEBUG=True
SECRET_KEY=your-secret-key-here
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:3000
python manage.py migrate # Appliquer les migrations
python manage.py makemigrations # Créer de nouvelles migrations
python manage.py createsuperuser # Créer un admin
python manage.py shell # Shell interactif Djangonpm run dev # Développement avec hot-reload
npm run build # Construire pour production
npm start # Démarrer la version compilée
npm run lint # Vérifier le codenpm run dev # Développement
npm run build # Compiler TypeScript
npm start # Démarrer la version compiléeimport { connectSocket } from '@/lib/socket'
const socket = connectSocket()
// Envoyer un message
socket.emit('message', { text: 'Hello!' })
// Recevoir des messages
socket.on('message', (data) => {
console.log('Message:', data)
})# Frontend
cd packages/frontend
npm install
# Backend
cd packages/backend
pip install -r requirements.txt# Frontend (port 3001)
npm run dev -- -p 3001
# Backend (port 8001)
python manage.py runserver 8001# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activatepip install -r requirements.txt- 3 terminaux ouverts en même temps = 3 services qui tournent en parallèle
- SQLite = pas besoin d'installer PostgreSQL
- Développement local = URLs en
localhost - Hot-reload activé = modifie le code, ça recharge automatiquement
- Admin Django = http://localhost:8000/admin
Besoin d'aide ? Vérifiez le QUICKSTART.md pour des explications plus détaillées ! 🚀