Loading repository data…
Loading repository data…
Assma-IBIKAS / repository
TalAIt Translation Platform 🌐 est un projet fullstack visant à automatiser les traductions FR ↔ EN pour une start-up e‑commerce marocaine. Le front-end 🌐 propose une interface Next.js avec formulaire de texte ✍️, choix de la direction de traduction ↔ et affichage en temps réel du résultat traduit 🔄.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Interface web moderne développée en Next.js avec React et TypeScript pour la plateforme de traduction TalAIt.
┌─────────────────────────────────────┐
│ Next.js Frontend │
│ ┌───────────┐ ┌──────────────┐ │
│ │ /login │ │ /register │ │
│ └─────┬─────┘ └──────┬───────┘ │
│ │ │ │
│ └────────┬────────┘ │
│ ▼ │
│ ┌──────────────┐ │
│ │ /translate │ │
│ └──────┬───────┘ │
└───────────────┼─────────────────────┘
│ JWT Bearer Token
▼
┌──────────────┐
│ Backend API │
│ (FastAPI) │
└──────────────┘
http://localhost:8000git clone https://github.com/Assma-IBIKAS/talAIt_Plateforme_de_Traduction_Frontend.git
npm install
# ou
yarn install
# ou
pnpm install
npm run dev
# ou
yarn dev
# ou
pnpm dev
Ouvrir http://localhost:3000
# Build l'image
docker build -t talait-frontend .
# Lancer le conteneur
docker run -p 3000:3000 talait-frontend
# Depuis la racine du projet
docker-compose up -d frontend
frontend/
├── app/
│ ├── layout.tsx # Layout racine
│ ├── page.tsx # Page d'accueil (redirect)
│ ├── globals.css # Styles globaux
│ ├── login/
│ │ └── page.tsx # Page de connexion
│ ├── register/
│ │ └── page.tsx # Page d'inscription
│ └── translate/
│ └── page.tsx # Page de traduction
├── public/
│ ├── favicon.ico
│ └── images/
├── types/
│ └── index.ts # Types TypeScript
├── Dockerfile
├── next.config.js
├── tailwind.config.ts
├── tsconfig.json
└── package.json
/)Redirection automatique :
/translate/login/login)Fonctionnalités:
/login/translateCode exemple:
const handleLogin = async () => {
const res = await fetch(`${API_URL}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ username, password })
});
const data = await res.json();
localStorage.setItem('access_token', data.access_token);
router.push('/translate');
};
/register)Fonctionnalités:
/register/login après 2s/translate)Fonctionnalités principales:
Interface de traduction
Résultats
Protection:
useEffect(() => {
const token = localStorage.getItem('access_token');
if (!token) {
router.push('/login'); // Redirection si non authentifié
}
}, []);
Appel API:
const handleTranslate = async () => {
const token = localStorage.getItem('access_token');
const res = await fetch(`${API_URL}/translate`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({ text, direction })
});
const data = await res.json();
setTranslatedText(data.translation);
};
1. Accès à l'app
↓
2. Redirection automatique
├─ Si authentifié → /translate
└─ Si non auth → /login
↓
3. Login ou Register
↓
4. Réception JWT
↓
5. Stockage en localStorage
↓
6. Accès à /translate
↓
7. Saisie texte + choix direction
↓
8. Click "Execute()"
↓
9. Envoi requête avec JWT
↓
10. Affichage résultat
↓
11. Logout → suppression JWT → retour /login
// Après login réussi
localStorage.setItem('access_token', token);
localStorage.setItem('username', username);
// Lecture du token
const token = localStorage.getItem('access_token');
// Logout
localStorage.removeItem('access_token');
localStorage.removeItem('username');
// Dans chaque page protégée
useEffect(() => {
const token = localStorage.getItem('access_token');
if (!token) {
router.push('/login');
}
}, [router]);
// Headers pour toutes les requêtes protégées
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
| Code | Action Frontend |
|---|---|
| 401 | Redirect to /login + message |
| 403 | Show "Accès refusé" |
| 422 | Validation errors display |
| 500 | "Erreur serveur" message |
| 503 | "Service temporairement indisponible" |
try {
const res = await fetch(url, options);
const data = await res.json();
if (!res.ok) {
setError(data.detail || 'Une erreur est survenue');
return;
}
// Success
} catch (err) {
setError('Erreur réseau ou serveur');
}
FROM node:22
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm","run","dev"]
frontend:
build:
context: ./talAIt_Plateforme_de_Traduction_Frontend
dockerfile: Dockerfile
container_name: talait_frontend
ports:
- "3000:3000"
depends_on:
- backend
// Vérifier expiration
if (res.status === 401) {
localStorage.removeItem('access_token');
router.push('/login');
}
# Vérifier que le backend autorise l'origin
# Backend config (FastAPI):
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Crafted with 💜 by TalAIt Design Team