8.3 KiB
EduManager - Regras Globais e Escopo
🚀 Escopo do Projeto
EduManager é um Sistema de Gestão Escolar completo, focado em alta performance, usabilidade premium e automação de processos administrativos e acadêmicos.
🛠️ Stack Tecnológica
- Frontend/Backend: Remix (React)
- Banco de Dados: PostgreSQL (100% Local/Self-Hosted)
- Storage Architecture: 100% Self-Hosted (MinIO) - Decoupled from Supabase Cloud.
- Image Serving: All images are served via a backend proxy route (
/storage/:bucket/:key) to ensure cross-origin compatibility and security. - Synchronization: High-performance local API for bank reconciliation (Asaas).
- Orquestração e CI/CD: Portainer (Docker) com GitHub Actions via Self-Hosted Runner (Oracle ARM64 nativo) e Watchtower.
- Production Entry Point: All production deployments MUST use
server.selfhosted.jsrenamed/copied asserver.jsin the Docker containers to ensure full local feature availability.
⚠️ Regras de Negócio Críticas (MANDATÓRIO)
[!IMPORTANT] Migração de Dados (Legado 'schoodat'): Ao realizar a migração completa dos dados do sistema legado 'schoodat' para o nosso banco de dados local Postgres, é terminantemente proibido alterar, resetar ou re-hashear as senhas existentes. As credenciais devem ser mantidas exatamente como estão para garantir que o acesso dos usuários não seja interrompido.
🚨 Regras de Fluxo de Trabalho (CRÍTICO)
[!CAUTION] Git Push Proibido Sem Demanda Explícita: NUNCA execute
git add,git commitougit pushsem que o USUÁRIO solicite explicitamente. Alterações devem ser feitas nos arquivos, mas o envio ao repositório remoto é uma ação exclusiva do usuário. Aguarde sempre o comando direto do usuário para realizar qualquer operação de versionamento. ESTA REGRA É INVIOLÁVEL E O ASSISTENTE JÁ FALHOU NELA EM 01/05/2026. NÃO REPITA O ERRO.
📜 Padrões de Desenvolvimento
- Design System: Estética Premium, Dark Mode por padrão (ou glassmorphism), micro-animações e ausência de placeholders.
- Segurança: Todas as rotas sensíveis devem validar o token JWT local (via secrets do ambiente). Proibido usar Supabase SDK para lógica de autenticação ou sincronização no frontend.
- Resiliência: Tratamento rigoroso de erros em chamadas de API de terceiros (Asaas, Evolution API).
- Upload de Arquivos: Proibido o uso de Base64 para envio de novos arquivos ao servidor. Use obrigatoriamente
FormDatae envie o objetoFile/Blobpara as rotas de API que integram com o MinIO. - Build & Deploy Stability: O pipeline de deploy deve obrigatoriamente utilizar
runs-on: self-hostede compilar apenas a plataformalinux/arm64(sem emulação QEMU). A atualização da stack em produção deve ser automatizada via container transiente do Watchtower. - Express Compatibility: Avoid using raw
/*wildcards in Express 5 routes; use Regex paths (/^\/route\/(.+)$/) for compatibility withpath-to-regexpv8. - Frontend Independence: NEVER import files from
services/orserver.jsdirectly into React components to prevent Node.js/SDK leakage (causes White Screen). Physical isolation is enforced: backend-only services (like MinIO/S3 storage) MUST stay outside thesrc/directory in Vite/React projects. Usehelpers.tsfor UI logic and standardfetchfor API calls. - Login Persistence: Administrative sessions are persisted via
localStorage('edumanager_session'). The main entry point MUST validate the session on mount to ensure UX continuity. - Real-time & Sync: In self-hosted environments, use Intelligent Polling (30s) to synchronize notifications and critical data between Portal and Manager, as standard Supabase Realtime is disabled.
- Justification Logic: Attendance justifications MUST include
fromStudentIdin notification metadata and support botharquivoandarquivo_base64keys for attachment compatibility. Notifications SHOULD include the motive text in themessagefield (JSON format:{text, motivo}) to allow previews in the manager bell. - Modal Standards: System modals should utilize
bg-transparent(no background darkening or blur) withshadow-2xlfor depth, ensuring a clean and float-like aesthetic. - Messages Automation: Preventive reminders and overdue settings MUST be managed within their respective template modals (contextual logic), with independent manual triggers for each phase (Overdue vs. Upcoming).
- Grading & Evaluation Standards: Assessments are categorized as
exam(violet/violet labels) oractivity(sky/blue labels). The report card (Boletim) MUST support multiple evaluations per period, showing the individual breakdown (name and value). The module MUST be named "Atividades e Provas" for clarity. - Asaas Safety: All financial generation forms MUST implement a loading state (
isCreating) to disable submit buttons and prevent duplicate charges. - Retake Policy: Students ARE allowed to retake activities and exams. The system MUST implement a "Lock" (Cadeado) logic: if locked, the retake button is hidden; if unlocked, the button is visible and the new submission overwrites the previous grade.
- Financial Categories: The system supports categories:
monthly(Mensalidade),registration(Matrícula),handout(Apostila), andothers(Outros). Automated forms must map references (Cursos -> monthly, Registration -> registration, Handout -> handout). - Modal Floating Principle: All system modals must avoid backdrop-blur and background overlays. Use
bg-transparentfor the fixed container andbg-white(solid) for the modal box, ensuring contrast via large soft shadows (shadow-2xlor equivalent). - Automated Messaging (Cron Jobs): The system uses
node-cronfor independent message scheduling (Preventive vs. Overdue). Overdue logic MUST implement safety checks usingoverdue_warnings_countandlast_overdue_warning_atto avoid spamming the student. Immediate webhook triggers forPAYMENT_OVERDUEare disabled in favor of scheduled routines. - Numerical Data Integrity: When retrieving data from PostgreSQL
NUMERICorDECIMALcolumns, values MUST be explicitly cast toNumber()in the backend before being sent to the frontend to prevent crashes when using.toFixed()in React. - Exam Duplication: The system supports cloning evaluations. Duplicated exams MUST default to
draftstatus and include(Cópia)in the title to allow verification before deployment to new classes. - Automatic Attendance Closure: The system implements an automatic closure routine (
processAutoAbsences) that generates physical "Absence" records in the PostgreSQL database for any past lesson where a student has no presence or justification. This routine is triggered during data save operations to ensure retroactive consistency between lessons and records. - Unified Notification System (SQL): The system uses the
notificacoesPostgreSQL table as the single source of truth for both Portal and Manager. JSON-based notifications inschool_dataare deprecated. New features (exams, justifications) MUST use SQL INSERT/SELECT and implement Intelligent Polling (30s) in the UI to ensure synchronization. - Soft Delete Policy (Lixeira): Evaluations (exams/activities) MUST NOT be hard-deleted to preserve grade history. Use the
isDeletedflag to hide them from students and active management views, keeping them accessible in the "Lixeira" for restoration and ensuring reference integrity in the Report Card. - Grading Arithmetic Logic: All grade averages (Period, Subject, and General) MUST be calculated as arithmetic means (Average of Means). Summing grades for a final period result is prohibited to ensure consistency between Portal and Manager.
- SQL Date Handling: When fetching timestamps from PostgreSQL to be matched with JSON dates/ISO strings in the frontend, ALWAYS use
TO_CHAR(column, 'YYYY-MM-DD"T"HH24:MI:SS')in the SQL query to prevent Node.js timezone shifts from corrupting string-based matching logic. - SQL-First Architecture Pattern: New features or module refactors SHOULD prioritize 100% SQL persistence (using
notas_boletimas a template). The legacy JSONschool_datashould be treated as secondary or deprecated for these modules, ensuring real-time consistency between Manager and Portal.