From 4b3da56c4000ebb511a26d55fb9957fc19d23af3 Mon Sep 17 00:00:00 2001 From: E-Voting Developer Date: Thu, 6 Nov 2025 01:20:57 +0100 Subject: [PATCH] docs: Add comprehensive documentation (PROJECT_STRUCTURE, QUICK_START) and cleanup - Remove old STATUS.md and STRUCTURE_NOTES.md - Add detailed PROJECT_STRUCTURE.md with full architecture documentation - Add QUICK_START.md with quick reference guide - Documentation covers: project overview, file structure, database models, API routes, Docker setup, authentication flow, security, and deployment --- e-voting-system/.claude/PROJECT_STRUCTURE.md | 324 +++++++++++++++++++ e-voting-system/.claude/QUICK_START.md | 133 ++++++++ e-voting-system/.claude/STATUS.md | 268 --------------- e-voting-system/.claude/STRUCTURE_NOTES.md | 23 -- 4 files changed, 457 insertions(+), 291 deletions(-) create mode 100644 e-voting-system/.claude/PROJECT_STRUCTURE.md create mode 100644 e-voting-system/.claude/QUICK_START.md delete mode 100644 e-voting-system/.claude/STATUS.md delete mode 100644 e-voting-system/.claude/STRUCTURE_NOTES.md diff --git a/e-voting-system/.claude/PROJECT_STRUCTURE.md b/e-voting-system/.claude/PROJECT_STRUCTURE.md new file mode 100644 index 0000000..c9c2315 --- /dev/null +++ b/e-voting-system/.claude/PROJECT_STRUCTURE.md @@ -0,0 +1,324 @@ +# E-Voting System - Architecture & Structure + +## ๐Ÿ“‹ Vue d'ensemble + +Systรจme de vote รฉlectronique sรฉcurisรฉ utilisant la **cryptographie post-quantique** et **le vote chiffrรฉ**. + +**Stack technique:** +- **Backend:** Python FastAPI + SQLAlchemy + MariaDB +- **Frontend:** React 19 + React Router + Axios +- **Cryptographie:** ElGamal + Preuve Zero-Knowledge + PQC Hybrid +- **Dรฉploiement:** Docker Compose + +--- + +## ๐Ÿ“ Structure du projet + +``` +e-voting-system/ +โ”œโ”€โ”€ backend/ # API FastAPI +โ”‚ โ”œโ”€โ”€ main.py # Point d'entrรฉe FastAPI +โ”‚ โ”œโ”€โ”€ config.py # Configuration (DB, JWT, etc) +โ”‚ โ”œโ”€โ”€ database.py # Setup SQLAlchemy +โ”‚ โ”œโ”€โ”€ models.py # Tables SQLAlchemy (Voter, Election, Vote, Candidate) +โ”‚ โ”œโ”€โ”€ schemas.py # Schรฉmas Pydantic (validation) +โ”‚ โ”œโ”€โ”€ services.py # Logique mรฉtier (VoterService, ElectionService, VoteService) +โ”‚ โ”œโ”€โ”€ auth.py # JWT et hashing (bcrypt) +โ”‚ โ”œโ”€โ”€ dependencies.py # Dรฉpendances FastAPI +โ”‚ โ”œโ”€โ”€ crypto/ # Modules cryptographie +โ”‚ โ”‚ โ”œโ”€โ”€ encryption.py # ElGamal encryption +โ”‚ โ”‚ โ”œโ”€โ”€ hashing.py # Key derivation (PBKDF2, bcrypt) +โ”‚ โ”‚ โ”œโ”€โ”€ signatures.py # Digital signatures +โ”‚ โ”‚ โ”œโ”€โ”€ zk_proofs.py # Zero-Knowledge proofs +โ”‚ โ”‚ โ””โ”€โ”€ pqc_hybrid.py # PQC Hybrid approach +โ”‚ โ”œโ”€โ”€ routes/ # Endpoints +โ”‚ โ”‚ โ”œโ”€โ”€ auth.py # Login, Register, Profile +โ”‚ โ”‚ โ”œโ”€โ”€ elections.py # ร‰lections CRUD +โ”‚ โ”‚ โ””โ”€โ”€ votes.py # Soumission/Rรฉcupรฉration votes +โ”‚ โ””โ”€โ”€ scripts/ +โ”‚ โ””โ”€โ”€ seed_db.py # Script initialisation DB +โ”‚ +โ”œโ”€โ”€ frontend/ # Application React +โ”‚ โ”œโ”€โ”€ public/ +โ”‚ โ”‚ โ”œโ”€โ”€ index.html # HTML root +โ”‚ โ”‚ โ””โ”€โ”€ config.js # Config runtime (API_BASE_URL) +โ”‚ โ”œโ”€โ”€ src/ +โ”‚ โ”‚ โ”œโ”€โ”€ App.js # Routeur principal +โ”‚ โ”‚ โ”œโ”€โ”€ index.js # Entry point React +โ”‚ โ”‚ โ”œโ”€โ”€ components/ # Composants rรฉutilisables +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Header.jsx # Navigation +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Footer.jsx # Footer +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Alert.jsx # Messages d'erreur/succรจs +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Modal.jsx # Modals +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ LoadingSpinner.jsx +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ VoteCard.jsx # Carte candidat +โ”‚ โ”‚ โ”œโ”€โ”€ pages/ # Pages/routes +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ LoginPage.js # Page de connexion (FIXED) +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ HomePage.jsx # Accueil +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ RegisterPage.jsx +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ DashboardPage.js # Tableau de bord +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ VotingPage.jsx # Page de vote +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ArchivesPage.jsx +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ProfilePage.jsx +โ”‚ โ”‚ โ”œโ”€โ”€ config/ +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ api.js # Configuration API endpoints +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ theme.js # Thรจme UI +โ”‚ โ”‚ โ”œโ”€โ”€ hooks/ +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ useApi.js # Hook pour appels API +โ”‚ โ”‚ โ”œโ”€โ”€ styles/ +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ globals.css +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ components.css +โ”‚ โ”‚ โ””โ”€โ”€ utils/ +โ”‚ โ”‚ โ””โ”€โ”€ api.js # Utilitaires API +โ”‚ โ”œโ”€โ”€ package.json # Dรฉpendances npm +โ”‚ โ”œโ”€โ”€ build/ # Compilation production +โ”‚ โ””โ”€โ”€ Dockerfile # Containerisation +โ”‚ +โ”œโ”€โ”€ docker/ +โ”‚ โ”œโ”€โ”€ Dockerfile.backend # Image FastAPI +โ”‚ โ”œโ”€โ”€ Dockerfile.frontend # Image React +โ”‚ โ””โ”€โ”€ init.sql # Script init DB +โ”‚ +โ”œโ”€โ”€ docker-compose.yml # Orchestration (mariadb + backend + frontend) +โ”œโ”€โ”€ Makefile # Commandes utiles +โ”œโ”€โ”€ README.md # Documentation principale +โ””โ”€โ”€ .claude/ # Documentation dรฉveloppeur + โ”œโ”€โ”€ PROJECT_STRUCTURE.md # Ce fichier + โ”œโ”€โ”€ DEPLOYMENT.md # Guide dรฉploiement + โ””โ”€โ”€ POSTQUANTUM_CRYPTO.md # Infos PQC +``` + +--- + +## ๐Ÿ”‘ Composants clรฉs + +### Backend - Routes principales + +#### `/api/auth/` +- **POST /register** โ†’ Crรฉer compte votant +- **POST /login** โ†’ Authentification, retourne JWT +- **GET /profile** โ†’ Profil votant actuel + +#### `/api/elections/` +- **GET /active** โ†’ ร‰lection en cours +- **GET /completed** โ†’ ร‰lections terminรฉes +- **GET /active/results** โ†’ Rรฉsultats + +#### `/api/votes/` +- **POST /** โ†’ Soumettre un vote chiffrรฉ +- **GET /history** โ†’ Historique votes votant + +### Frontend - Pages principales + +| Page | Route | Description | +|------|-------|-------------| +| **LoginPage.js** | `/login` | Connexion votant | +| **HomePage.jsx** | `/` | Accueil | +| **DashboardPage.js** | `/dashboard` | Elections actives | +| **VotingPage.jsx** | `/vote/:id` | Interface vote | +| **ArchivesPage.jsx** | `/archives` | Elections passรฉes | + +--- + +## ๐Ÿ” Flux d'authentification + +``` +1. Utilisateur โ†’ LoginPage.js +2. POST /api/auth/login (email + password) +3. Backend vรฉrifie credentials (bcrypt.checkpw) +4. โœ… JWT token retournรฉ +5. Token + voter data โ†’ localStorage +6. Redirection โ†’ /dashboard +``` + +### Important: LoginPage.js + +**Corrigรฉ le 5 nov 2025:** +- โœ… Utilise `API_ENDPOINTS.LOGIN` (au lieu de URL hardcodรฉe) +- โœ… Prop correct: `onLogin` (au lieu de `onLoginSuccess`) +- โœ… Structure donnรฉes correcte: `email`, `first_name`, `last_name` + +--- + +## ๐Ÿ—„๏ธ Modรจles Base de donnรฉes + +### `voters` +``` +id (PK) +email (UNIQUE) +password_hash (bcrypt) +first_name +last_name +citizen_id (UNIQUE) +public_key (ElGamal) +has_voted (bool) +created_at +updated_at +``` + +### `elections` +``` +id (PK) +name +description +start_date +end_date +elgamal_p (nombre premier) +elgamal_g (gรฉnรฉrateur) +public_key (clรฉ publique) +is_active (bool) +results_published (bool) +``` + +### `candidates` +``` +id (PK) +election_id (FK) +name +description +order +``` + +### `votes` +``` +id (PK) +voter_id (FK) +election_id (FK) +candidate_id (FK) +encrypted_vote (ElGamal ciphertext) +zero_knowledge_proof +ballot_hash +timestamp +ip_address +``` + +--- + +## ๐Ÿณ Docker Compose + +3 services: + +### `mariadb` (port 3306) +- Image: `mariadb:latest` +- Init script: `docker/init.sql` +- Volume: `evoting_data` + +### `backend` (port 8000) +- Build: `docker/Dockerfile.backend` +- CMD: `uvicorn backend.main:app --host 0.0.0.0 --port 8000` +- Dรฉpend de: `mariadb` (healthcheck) + +### `frontend` (port 3000) +- Build: `docker/Dockerfile.frontend` +- CMD: `serve -s build -l 3000` +- Dรฉpend de: `backend` + +--- + +## ๐Ÿš€ Dรฉmarrage + +### Local (dรฉveloppement) +```bash +# Backend +cd backend +uvicorn main:app --reload + +# Frontend (autre terminal) +cd frontend +npm start +``` + +### Docker +```bash +docker-compose up -d +# Frontend: http://localhost:3000 +# Backend: http://localhost:8000 +``` + +### Makefile +```bash +make up # docker-compose up -d +make down # docker-compose down +make logs # docker-compose logs -f backend +make test # pytest tests/ -v +``` + +--- + +## ๐Ÿ”’ Sรฉcuritรฉ + +### Authentification +- Passwords: **bcrypt** (salt + hash) +- Tokens: **JWT** (HS256, 30min expiration) + +### Votes +- **Chiffrement:** ElGamal +- **Preuve:** Zero-Knowledge +- **Traรงabilitรฉ:** ballot_hash + +### Post-Quantum +- Hybride PQC/Classique pour transition future +- Module: `backend/crypto/pqc_hybrid.py` + +--- + +## ๐Ÿ“ Variables d'environnement + +### Backend (`.env`) +``` +DB_HOST=mariadb +DB_PORT=3306 +DB_NAME=evoting_db +DB_USER=evoting_user +DB_PASSWORD=evoting_pass123 +SECRET_KEY=your-secret-key-change-in-production +DEBUG=false +``` + +### Frontend (`public/config.js`) +```javascript +window.API_CONFIG = { + API_BASE_URL: 'http://localhost:8000' +}; +``` + +--- + +## โœ… Tests + +```bash +# Tous les tests +pytest tests/ -v + +# Tests spรฉcifiques +pytest tests/test_backend.py -v +pytest tests/test_crypto.py -v +pytest tests/test_pqc.py -v +``` + +--- + +## ๐ŸŽฏ Statut (5 nov 2025) + +โœ… **Systรจme fonctionnel** +- [x] Login/Register +- [x] Dashboard +- [x] JWT authentication +- [x] Docker deployment +- [x] API endpoints +- [ ] Vote submission (en cours) +- [ ] Results display (planifiรฉ) + +--- + +## ๐Ÿ“š Rรฉfรฉrences + +- **FastAPI:** https://fastapi.tiangolo.com/ +- **React Router:** https://reactrouter.com/ +- **SQLAlchemy:** https://www.sqlalchemy.org/ +- **ElGamal:** Crypto asymรฉtrique probabiliste +- **Zero-Knowledge Proofs:** Preuve sans rรฉvรฉler info + +--- + +**Derniรจre mise ร  jour:** 5 novembre 2025 diff --git a/e-voting-system/.claude/QUICK_START.md b/e-voting-system/.claude/QUICK_START.md new file mode 100644 index 0000000..1d4b766 --- /dev/null +++ b/e-voting-system/.claude/QUICK_START.md @@ -0,0 +1,133 @@ +# Quick Start & Notes + +## ๐Ÿš€ Dรฉmarrage rapide + +```bash +# Docker (recommandรฉ) +cd /home/paul/CIA/e-voting-system +docker-compose up -d + +# Frontend: http://localhost:3000 +# Backend API: http://localhost:8000 +# Database: localhost:3306 +``` + +## ๐Ÿ”ง Fixes rรฉcentes (5 nov 2025) + +### LoginPage.js +- โœ… Utilise `API_ENDPOINTS.LOGIN` au lieu de URL hardcodรฉe +- โœ… Prop correct: `onLogin` (รฉtait `onLoginSuccess`) +- โœ… Mapping donnรฉes correct: `email`, `first_name`, `last_name` +- โœ… Teste les identifiants: `paul.roost@epita.fr` / `tennis16` + +### DashboardPage.js +- โœ… Utilise `API_ENDPOINTS.ELECTIONS_ACTIVE` + +### Docker +- โœ… Dockerfile.backend: suppression du double CMD +- โœ… Frontend build inclus dans docker-compose + +### Nettoyage +- โœ… Suppression du dossier `src/` (doublon) +- โœ… Installation de `lucide-react` +- โœ… Suppression des console.log de debug + +--- + +## ๐Ÿ“‹ Fichiers ร  connaรฎtre + +| Fichier | Rรดle | +|---------|------| +| `backend/main.py` | Point d'entrรฉe FastAPI | +| `backend/routes/auth.py` | Routes login/register | +| `frontend/src/pages/LoginPage.js` | **Page de login** | +| `frontend/src/config/api.js` | Configuration API endpoints | +| `docker-compose.yml` | Orchestration services | +| `.env.example` | Variables d'environnement | + +--- + +## ๐Ÿงช Test login + +```bash +# Via curl +curl -X POST http://localhost:8000/api/auth/login \ + -H "Content-Type: application/json" \ + -d '{"email": "paul.roost@epita.fr", "password": "tennis16"}' + +# Rรฉponse attendue +{ + "access_token": "eyJ...", + "token_type": "bearer", + "expires_in": 1800, + "id": 1, + "email": "paul.roost@epita.fr", + "first_name": "Paul", + "last_name": "Roost" +} +``` + +--- + +## ๐Ÿ”‘ Points clรฉs + +### API Base URL +- **Local dev:** `http://localhost:8000` +- **Docker:** Configuration dans `frontend/public/config.js` + +### JWT Token +- Stockรฉ dans `localStorage` sous clรฉ `token` +- Utilisรฉ dans header `Authorization: Bearer ` +- Expiration: 30 minutes + +### Voter Data +- Stockรฉ dans `localStorage` sous clรฉ `voter` +- Structure: `{ id, email, name, first_name, last_name }` + +--- + +## โš ๏ธ Erreurs courantes + +| Erreur | Cause | Solution | +|--------|-------|----------| +| `CORS error` | Frontend cherche localhost depuis Docker | Utiliser `API_ENDPOINTS` | +| `onLoginSuccess is not a function` | Prop nommรฉ incorrectement | Utiliser `onLogin` | +| `t is not a function` | Composant pas reรงu le bon prop | Vรฉrifier noms props parent/enfant | +| Build cache | Ancien JS chargรฉ | Force refresh: `Ctrl+Shift+R` | + +--- + +## ๐Ÿ“Š Architecture rรฉseau Docker + +``` +User Browser (localhost:3000) + โ†“ +Frontend Container (nginx serve) + โ†“ +Backend Container (:8000) + โ†“ +MariaDB Container (:3306) +``` + +**Important:** Du navigateur, utiliser `localhost:8000`. Du container, utiliser `evoting_backend:8000`. + +--- + +## ๐Ÿ” Credentials de test + +- **Email:** `paul.roost@epita.fr` +- **Password:** `tennis16` +- **DB User:** `evoting_user` +- **DB Pass:** `evoting_pass123` + +--- + +## ๐Ÿ“š Autres fichiers .claude + +- **PROJECT_STRUCTURE.md** - Architecture complรจte (ce rรฉpertoire) +- **DEPLOYMENT.md** - Guide dรฉploiement production +- **POSTQUANTUM_CRYPTO.md** - Dรฉtails cryptographie + +--- + +**Derniรจre mise ร  jour:** 5 novembre 2025 diff --git a/e-voting-system/.claude/STATUS.md b/e-voting-system/.claude/STATUS.md deleted file mode 100644 index e3502b7..0000000 --- a/e-voting-system/.claude/STATUS.md +++ /dev/null @@ -1,268 +0,0 @@ -# ๐Ÿ—ณ๏ธ E-Voting System - Status Final - -**Date:** 5 novembre 2025 -**Status:** โœ… **PRODUCTION READY** -**Branch:** `paul/evoting` on gitea.vidoks.fr - ---- - -## ๐Ÿ“Š Architecture - -``` -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ DOCKER NETWORK โ”‚ -โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ โ”‚ -โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ -โ”‚ โ”‚ FRONTEND โ”‚ โ”‚ BACKEND โ”‚ โ”‚ -โ”‚ โ”‚ React 18 CRA โ”‚ โ”‚ FastAPI (3.12) โ”‚ โ”‚ -โ”‚ โ”‚ :3000 โ”‚ โ”‚ :8000 โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ”‚ โ”‚ โ”‚ -โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ -โ”‚ โ”‚ MariaDB โ”‚ โ”‚ -โ”‚ โ”‚ :3306 โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ”‚ โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ -``` - ---- - -## ๐Ÿ“ Structure du Projet - -``` -/home/paul/CIA/e-voting-system/ -โ”œโ”€โ”€ frontend/ # React Create React App (18.x) -โ”‚ โ”œโ”€โ”€ public/ # Static files -โ”‚ โ”œโ”€โ”€ src/ # React components -โ”‚ โ”œโ”€โ”€ package.json -โ”‚ โ””โ”€โ”€ build/ # Production build -โ”‚ -โ”œโ”€โ”€ backend/ # FastAPI application -โ”‚ โ”œโ”€โ”€ main.py # Entry point -โ”‚ โ”œโ”€โ”€ models.py # SQLAlchemy ORM -โ”‚ โ”œโ”€โ”€ schemas.py # Pydantic models -โ”‚ โ”œโ”€โ”€ routes/ # API endpoints -โ”‚ โ”‚ โ”œโ”€โ”€ elections.py -โ”‚ โ”‚ โ”œโ”€โ”€ votes.py -โ”‚ โ”‚ โ””โ”€โ”€ auth.py -โ”‚ โ”œโ”€โ”€ crypto/ # Cryptography modules -โ”‚ โ”‚ โ”œโ”€โ”€ hashing.py # SHA-256 -โ”‚ โ”‚ โ”œโ”€โ”€ encryption.py # ElGamal -โ”‚ โ”‚ โ”œโ”€โ”€ signatures.py # RSA-PSS -โ”‚ โ”‚ โ””โ”€โ”€ pqc_hybrid.py # Post-Quantum (ML-DSA-65, ML-KEM-768) -โ”‚ โ”œโ”€โ”€ pyproject.toml # Poetry dependencies -โ”‚ โ””โ”€โ”€ poetry.lock -โ”‚ -โ”œโ”€โ”€ docker/ # Docker configuration -โ”‚ โ”œโ”€โ”€ Dockerfile.backend -โ”‚ โ”œโ”€โ”€ Dockerfile.frontend -โ”‚ โ”œโ”€โ”€ init.sql # Database initialization -โ”‚ -โ”œโ”€โ”€ docs/ # Documentation -โ”‚ โ”œโ”€โ”€ DEPLOYMENT.md -โ”‚ โ””โ”€โ”€ POSTQUANTUM_CRYPTO.md -โ”‚ -โ”œโ”€โ”€ docker-compose.yml # Service orchestration -โ”œโ”€โ”€ .env # Environment variables -โ””โ”€โ”€ README.md # Main readme - -``` - ---- - -## ๐Ÿš€ Dรฉmarrage Rapide - -### Lancer les services - -```bash -cd /home/paul/CIA/e-voting-system -docker-compose up -d -``` - -### Accรจs - -- **Frontend:** http://localhost:3000 -- **API:** http://localhost:8000 -- **API Docs:** http://localhost:8000/docs (Swagger UI) -- **Database:** localhost:3306 - -### Arrรชter - -```bash -docker-compose down -``` - ---- - -## ๐Ÿ” Fonctionnalitรฉs - -### โœ… Frontend (React) -- SPA responsive avec pages multiples -- Enregistrement de votant -- Interface de vote -- Affichage des rรฉsultats -- Gestion d'รฉtat avec Context API -- Communication API avec Axios - -### โœ… Backend (FastAPI) -- 7 endpoints REST (/elections, /votes, /voters) -- Authentification JWT -- Validation Pydantic -- ORM SQLAlchemy -- Logs structurรฉs -- CORS activรฉ - -### โœ… Cryptographie -- **Classique:** RSA-PSS, ElGamal, SHA-256, PBKDF2 -- **Post-Quantum:** ML-DSA-65 (Dilithium), ML-KEM-768 (Kyber) - FIPS 203/204 -- **Hybrid:** Approche dรฉfense-en-profondeur (classique + PQC) - -### โœ… Base de Donnรฉes -- 5 tables normalisรฉes (voters, elections, candidates, votes, audit_logs) -- 1 รฉlection active prรฉ-chargรฉe avec 4 candidats -- Intรฉgritรฉ rรฉfรฉrentielle -- Timestamps - ---- - -## ๐Ÿ“Š Services Docker - -``` -โœ… evoting-frontend Node 20 Alpine โ†’ port 3000 -โœ… evoting-backend Python 3.12 โ†’ port 8000 -โœ… evoting_db MariaDB 12 โ†’ port 3306 -``` - -**Vรฉrifier le statut:** -```bash -docker ps -docker logs evoting_backend # Backend logs -docker logs evoting_frontend # Frontend logs -docker logs evoting_db # Database logs -``` - ---- - -## ๐Ÿงช Tests - -```bash -# Unit tests -cd /home/paul/CIA/e-voting-system -pytest - -# Coverage -pytest --cov=backend tests/ -``` - ---- - -## ๐Ÿ“ Git History - -``` -Commit 4a6c595 (HEAD paul/evoting) -โ”œโ”€ Restructure: React CRA frontend + FastAPI backend in separate dirs -โ”‚ โ””โ”€ 48 files changed, 20243 insertions -โ”‚ -Commit 94939d2 -โ”œโ”€ Move DEPLOYMENT.md to .claude/ directory -โ”‚ -Commit 15a52af -โ”œโ”€ Remove liboqs-python: use optional import for PQC compatibility -โ”‚ -Commit 6df490a -โ””โ”€ Add post-quantum cryptography (FIPS 203/204) - โ””โ”€ 798 insertions, 2173 deletions -``` - ---- - -## โš™๏ธ Configuration - -### `.env` (Production - ร€ mettre ร  jour) - -```env -# Database -DB_HOST=mariadb -DB_PORT=3306 -DB_NAME=evoting_db -DB_USER=evoting_user -DB_PASSWORD=CHANGE_THIS_PASSWORD_IN_PRODUCTION - -# Backend -SECRET_KEY=CHANGE_THIS_SECRET_KEY_IN_PRODUCTION -DEBUG=false - -# Frontend -REACT_APP_API_URL=http://your-production-domain.com/api -``` - ---- - -## ๐Ÿ”— Endpoints API - -### Elections -``` -GET /api/elections/active โ†’ Current election + candidates -GET /api/elections/{id}/results โ†’ Election results -``` - -### Votes -``` -POST /api/votes/submit โ†’ Submit a vote -GET /api/votes/verify/{id} โ†’ Verify vote signature -``` - -### Voters -``` -POST /api/voters/register โ†’ Register voter (generates keys) -GET /api/voters/check?email=... โ†’ Check voter existence -``` - ---- - -## ๐Ÿ›ก๏ธ Security Features - -- โœ… JWT authentication -- โœ… Password hashing (bcrypt) -- โœ… CORS configuration -- โœ… SQL injection protection (ORM) -- โœ… Rate limiting ready -- โœ… Vote encryption with hybrid PQC -- โœ… Digital signatures (RSA + Dilithium) -- โœ… Audit logging - ---- - -## ๐Ÿ“š Documentation - -- `docs/DEPLOYMENT.md` - Deployment guide & troubleshooting -- `docs/POSTQUANTUM_CRYPTO.md` - PQC implementation details -- `README.md` - Main project readme - ---- - -## ๐ŸŽฏ Prochaines ร‰tapes - -1. โœ… **Frontend React fonctionnel** - COMPLร‰Tร‰ -2. โœ… **Backend API fonctionnel** - COMPLร‰Tร‰ -3. โœ… **Base de donnรฉes intรฉgrรฉe** - COMPLร‰Tร‰ -4. โœ… **Cryptographie PQC prรชte** - COMPLร‰Tร‰ -5. โณ **Intรฉgrer PQC dans les endpoints** - ร€ faire -6. โณ **Tests E2E complets** - ร€ faire -7. โณ **Dรฉployer en production** - ร€ faire - ---- - -## ๐Ÿ“ž Support - -Pour des questions sur: -- **PQC:** Voir `docs/POSTQUANTUM_CRYPTO.md` -- **Dรฉploiement:** Voir `docs/DEPLOYMENT.md` -- **API:** Accรฉder ร  http://localhost:8000/docs - ---- - -**Last Updated:** 2025-11-05 -**Project Status:** โœ… Ready for Testing & Development diff --git a/e-voting-system/.claude/STRUCTURE_NOTES.md b/e-voting-system/.claude/STRUCTURE_NOTES.md deleted file mode 100644 index fe5ff5b..0000000 --- a/e-voting-system/.claude/STRUCTURE_NOTES.md +++ /dev/null @@ -1,23 +0,0 @@ -# ๐Ÿ“ IMPORTANT - Structure des Documentation - -## โœ… RรˆGLE : Tous les .md (SAUF README.md) doivent รชtre dans `.claude/` - -**Raison:** Garder la racine minimale et propre. - -### Fichiers ร  TOUJOURS garder dans `.claude/`: -- โœ… `POSTQUANTUM_CRYPTO.md` - Documentation PQC -- โœ… `DEPLOYMENT.md` - Guide de dรฉploiement -- โœ… `STATUS.md` - Status du projet (MOVE HERE!) -- โœ… Tout autre .md technique - -### Fichiers ร  la RACINE: -- โœ… `README.md` SEULEMENT - -### ร€ FAIRE: -```bash -# Dรฉplacer STATUS.md vers .claude/ -mv STATUS.md .claude/STATUS.md -git add -A && git commit -m "Move STATUS.md to .claude/" -``` - -**Ne plus oublier ceci!**