Technical
Documentation Technique
Documentation technique de la plateforme 2Krika
Documentation Technique
Cette section couvre les aspects techniques de la plateforme 2Krika, incluant l'API, le déploiement, la configuration et l'infrastructure.
Vue d'Ensemble
La plateforme 2Krika est composée de plusieurs éléments:
Frontend
- App Customers: Application Next.js 15 pour clients et vendeurs
- App Staffs: Application Next.js pour l'administration
- App Docs: Documentation Fumadocs
Backend
- API REST: Backend Node.js/Express
- Base de données: PostgreSQL
- Cache: Redis
- Storage: AWS S3 ou équivalent
- Real-time: Socket.io
Infrastructure
- Hébergement: Vercel (frontend), AWS/DigitalOcean (backend)
- CDN: Cloudflare ou AWS CloudFront
- Monitoring: Sentry, LogRocket
- CI/CD: GitHub Actions
Sections
API Reference
Documentation de l'API REST
Déploiement
Guide de déploiement en production
Configuration
Variables d'environnement et configuration
Architecture Globale
┌─────────────────────┐
│ CDN (Cloudflare) │
└──────────┬──────────┘
│
┌──────┴──────┐
│ │
┌───▼───┐ ┌────▼────┐
│ Apps │ │ API │
│Customer│ │Backend │
│Staffs │ │ │
└───┬───┘ └────┬────┘
│ │
│ ┌─────┴─────┐
│ │ │
│ ┌──▼──┐ ┌───▼───┐
│ │ DB │ │ Redis │
│ │(PG) │ │ │
│ └─────┘ └───────┘
│
┌───▼────────┐
│ Socket.io │
│ Server │
└────────────┘Stack Technique Complet
Frontend
- Next.js 15/16
- React 19
- TypeScript 5.8+
- Tailwind CSS 4.x
- Mantine UI 7.x/8.x
- React Query v5
- Zustand
- Socket.io Client
- next-intl
- Axios
Backend
- Node.js 18+
- Express
- TypeScript
- Prisma (ORM)
- PostgreSQL
- Redis
- Socket.io Server
- JWT Authentication
- Multer (file uploads)
- Nodemailer
DevOps
- Docker
- GitHub Actions
- Vercel
- AWS/DigitalOcean
- Nginx (reverse proxy)
Monitoring & Analytics
- Sentry (error tracking)
- LogRocket (session replay)
- Google Analytics
- PostHog (product analytics)
Flux de Données
Authentification
User → Login Form → API /auth/login
↓
Verify Credentials
↓
Generate JWT Tokens
↓
Return Tokens → Store in Client
↓
Authenticated RequestsCréation de Service
Seller → Service Form → API /services
↓
Validate Data
↓
Upload Images (S3)
↓
Create Service (DB)
↓
Queue for Moderation
↓
Return Service IDProcessus de Commande
Client → Select Service → Checkout
↓
Process Payment
↓
Create Order (DB)
↓
Notify Seller (Socket.io)
↓
Send Confirmation EmailSécurité
Authentification
- JWT avec access & refresh tokens
- Tokens stockés dans httpOnly cookies (backend) ou localStorage (frontend)
- Expiration des tokens
- Rate limiting sur les endpoints sensibles
Autorisation
- Vérification des rôles (client, seller, admin)
- Vérification de propriété des ressources
- Middleware de protection des routes
Protection des Données
- Chiffrement des mots de passe (bcrypt)
- Validation des entrées (Joi/Zod)
- Sanitization des données
- Protection CSRF
- CORS configuré
Upload de Fichiers
- Validation des types MIME
- Taille maximale définie
- Scan antivirus (optionnel)
- Stockage sécurisé (S3 avec permissions)
Performance
Optimisations Frontend
- Code splitting automatique (Next.js)
- Image optimization (next/image)
- Static generation où possible
- ISR (Incremental Static Regeneration)
- React Query caching
- Lazy loading des composants
- Memoization (React.memo, useMemo)
Optimisations Backend
- Database indexing
- Query optimization
- Caching avec Redis
- Connection pooling
- Response compression (gzip)
- CDN pour assets statiques
Monitoring
- Temps de réponse API
- Core Web Vitals
- Error rates
- Database query performance
- Cache hit rates
Environnements
Développement (Local)
Frontend: http://localhost:3000 (customers)
http://localhost:3001 (staffs)
http://localhost:3002 (docs)
Backend: http://localhost:8000
Socket: ws://localhost:8001Staging
Frontend: https://staging.2krika.com
Backend: https://api-staging.2krikaservices.cloud
Socket: wss://socket-staging.2krikaservices.cloudProduction
Frontend: https://www.2krika.com
Backend: https://api.2krikaservices.cloud
Socket: wss://socket.2krikaservices.cloud