refactor: migrate main.py to modular routers and add project roadmap
CI / Test (Python 3.11) (push) Has been cancelled
CI / Test (Python 3.12) (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Type Check (push) Has been cancelled
CI / Summary (push) Has been cancelled

- Migrated monolithic main.py to feature-scoped routers in app/routers/
- Added GEMINI.md for project context and AI instructional guidelines
- Updated README.md with a comprehensive modernization plan (SQL migration, robust scraping DSL, frontend modernization)
- Improved authentication with cookie support and modular JS
- Updated test suite and documentation
This commit is contained in:
root
2026-03-24 10:12:04 +00:00
parent 1b5d7f9238
commit d4d8d8a3b6
42 changed files with 4518 additions and 2426 deletions
+68 -120
View File
@@ -121,15 +121,15 @@
<h1 class="auth-title">🎬 Ohm Stream</h1>
<div class="auth-tabs">
<div class="auth-tab active" onclick="switchTab('login')">Connexion</div>
<div class="auth-tab" onclick="switchTab('register')">Inscription</div>
<div class="auth-tab active" data-tab="login">Connexion</div>
<div class="auth-tab" data-tab="register">Inscription</div>
</div>
<div class="auth-error" id="authError"></div>
<div class="auth-success" id="authSuccess"></div>
<div class="auth-error" id="authError" aria-live="polite"></div>
<div class="auth-success" id="authSuccess" aria-live="polite"></div>
<!-- Login Form -->
<form class="auth-form active" id="loginForm" onsubmit="handleLogin(event)">
<form class="auth-form active" id="loginForm">
<div class="form-group">
<label for="loginUsername">Nom d'utilisateur</label>
<input
@@ -137,7 +137,10 @@
id="loginUsername"
placeholder="Entrez votre nom d'utilisateur"
required
aria-required="true"
aria-describedby="loginUsernameHelp"
>
<span id="loginUsernameHelp" class="visually-hidden">Champ obligatoire</span>
</div>
<div class="form-group">
<label for="loginPassword">Mot de passe</label>
@@ -146,13 +149,14 @@
id="loginPassword"
placeholder="Entrez votre mot de passe"
required
aria-required="true"
>
</div>
<button type="submit" class="btn-primary btn-block">Se connecter</button>
<button type="submit" id="loginSubmit" class="btn-primary btn-block">Se connecter</button>
</form>
<!-- Register Form -->
<form class="auth-form" id="registerForm" onsubmit="handleRegister(event)">
<form class="auth-form" id="registerForm">
<div class="form-group">
<label for="registerUsername">Nom d'utilisateur</label>
<input
@@ -161,6 +165,7 @@
placeholder="Choisissez un nom d'utilisateur"
minlength="3"
required
aria-required="true"
>
</div>
<div class="form-group">
@@ -187,6 +192,7 @@
placeholder="Au moins 6 caractères"
minlength="6"
required
aria-required="true"
>
</div>
<div class="form-group">
@@ -197,9 +203,10 @@
placeholder="Confirmez votre mot de passe"
minlength="6"
required
aria-required="true"
>
</div>
<button type="submit" class="btn-primary btn-block">S'inscrire</button>
<button type="submit" id="registerSubmit" class="btn-primary btn-block">S'inscrire</button>
</form>
<div class="back-link">
@@ -207,127 +214,68 @@
</div>
</div>
<!-- Load auth modules in order -->
<script src="/static/js/auth-utils.js"></script>
<script src="/static/js/auth-api.js"></script>
<script src="/static/js/auth-ui.js"></script>
<script>
const API_BASE = window.location.protocol + '//' + window.location.host;
// Debug: Check what's loaded
console.log('Auth modules loaded:');
console.log('- window.safeJsonParse:', typeof window.safeJsonParse);
console.log('- window.authApi:', typeof window.authApi);
console.log('- window.authUi:', typeof window.authUi);
console.log('- window.authApi.login:', typeof window.authApi?.login);
console.log('- window.authUi.handleLogin:', typeof window.authUi?.handleLogin);
function switchTab(tab) {
const tabs = document.querySelectorAll('.auth-tab');
const forms = document.querySelectorAll('.auth-form');
// Expose setToken from auth.js if available
if (typeof window.setToken === 'undefined') {
window.setToken = function(token) {
localStorage.setItem('auth_token', token);
document.cookie = 'auth_token=' + token + ';path=/;SameSite=Strict';
};
}
tabs.forEach(t => t.classList.remove('active'));
forms.forEach(f => f.classList.remove('active'));
// Attach event listeners after all scripts are loaded
document.addEventListener('DOMContentLoaded', function() {
console.log('DOM Content Loaded');
console.log('window.authUi:', window.authUi);
if (tab === 'login') {
tabs[0].classList.add('active');
document.getElementById('loginForm').classList.add('active');
const loginForm = document.getElementById('loginForm');
const registerForm = document.getElementById('registerForm');
if (loginForm && window.authUi && window.authUi.handleLogin) {
loginForm.addEventListener('submit', window.authUi.handleLogin);
console.log('✓ Login handler attached');
} else {
tabs[1].classList.add('active');
document.getElementById('registerForm').classList.add('active');
}
hideMessages();
}
function showError(message) {
const errorDiv = document.getElementById('authError');
errorDiv.textContent = message;
errorDiv.classList.add('show');
document.getElementById('authSuccess').classList.remove('show');
}
function showSuccess(message) {
const successDiv = document.getElementById('authSuccess');
successDiv.textContent = message;
successDiv.classList.add('show');
document.getElementById('authError').classList.remove('show');
}
function hideMessages() {
document.getElementById('authError').classList.remove('show');
document.getElementById('authSuccess').classList.remove('show');
}
async function handleLogin(event) {
event.preventDefault();
hideMessages();
const username = document.getElementById('loginUsername').value;
const password = document.getElementById('loginPassword').value;
try {
const response = await fetch(`${API_BASE}/api/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, password })
console.error('✗ authUi.handleLogin not available', {
hasLoginForm: !!loginForm,
hasAuthUi: !!window.authUi,
hasHandleLogin: !!window.authUi?.handleLogin
});
const data = await response.json();
if (response.ok) {
// Store token in localStorage
localStorage.setItem('auth_token', data.access_token);
localStorage.setItem('user', JSON.stringify(data.user));
showSuccess('Connexion réussie! Redirection...');
// Redirect to home page after 1 second
setTimeout(() => {
window.location.href = '/web';
}, 1000);
} else {
showError(data.detail || 'Erreur lors de la connexion');
}
} catch (error) {
console.error('Login error:', error);
showError('Erreur de connexion au serveur');
}
}
async function handleRegister(event) {
event.preventDefault();
hideMessages();
const username = document.getElementById('registerUsername').value;
const email = document.getElementById('registerEmail').value || null;
const full_name = document.getElementById('registerFullName').value || null;
const password = document.getElementById('registerPassword').value;
const passwordConfirm = document.getElementById('registerPasswordConfirm').value;
// Validate passwords match
if (password !== passwordConfirm) {
showError('Les mots de passe ne correspondent pas');
return;
}
try {
const response = await fetch(`${API_BASE}/api/auth/register`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, password, email, full_name })
if (registerForm && window.authUi && window.authUi.handleRegister) {
registerForm.addEventListener('submit', window.authUi.handleRegister);
console.log('✓ Register handler attached');
} else {
console.error('✗ authUi.handleRegister not available');
}
// Attach tab click handlers
const tabs = document.querySelectorAll('.auth-tab');
console.log('Found tabs:', tabs.length);
tabs.forEach(tab => {
tab.addEventListener('click', function() {
console.log('Tab clicked:', this.dataset.tab);
if (window.authUi && window.authUi.switchTab) {
window.authUi.switchTab(this.dataset.tab);
} else {
console.error('✗ authUi.switchTab not available');
}
});
const data = await response.json();
if (response.ok) {
showSuccess('Inscription réussie! Vous pouvez maintenant vous connecter.');
// Switch to login tab after 1.5 seconds
setTimeout(() => {
switchTab('login');
document.getElementById('loginUsername').value = username;
}, 1500);
} else {
showError(data.detail || 'Erreur lors de l\'inscription');
}
} catch (error) {
console.error('Register error:', error);
showError('Erreur de connexion au serveur');
}
}
});
console.log('✓ Tab handlers attached');
});
</script>
</body>
</html>