How nunomacastro/edu-pap-3ig-opsa-2526 works
1. What this repository is
- This repo is primarily a specification + prototype repository for OPSA, not a full production implementation.
- The core product described is an ERP financeiro para PME, with accounting, stock, sales, purchasing, banking, and AI-assisted analysis.
2. Repository shape
- The largest area is documentation under docs/, especially docs/planificacao/.
- The only substantial executable app code is in mockup/, which is a Vite + React + TypeScript UI prototype.
- There is also a small repo-level script area in scripts/ for validating the documentation/planning structure.
3. Documentation as the system blueprint
- docs/RF.md and docs/RNF.md define the functional and non-functional requirements.
- docs/planificacao/ contains the planning model: roadmap, sprint plans, backlog matrices, and per-module backlog guides.
- This documentation layer is effectively the source of truth for architecture, domain boundaries, and delivery sequencing.
4. Delivery structure and domain breakdown
- The planning docs split the product into functional macro-phases MF0 through MF8.
- These phases map to domain areas such as:
- identity/access and company setup,
- sales and purchasing,
- inventory and accounting,
- banking and reconciliation,
- reporting and exports,
- AI insights and alerts,
- quality, performance, and operational hardening.
- For an architecture diagram, these phases can be shown as incremental layers over the same ERP core.
5. Frontend prototype subsystem
- mockup/ is a single-page UI prototype with:
- src/app/App.tsx as the app entry shell,
- Layout.tsx for page structure,
- Login.tsx for authentication UI,
- a set of module views under src/app/components/modules/.
- The module views mirror the ERP domains: Dashboard, Vendas, Compras, Inventario, Contabilidade, Bancos, IA, and Configuracoes.
6. UI composition and shared component layer
- The mockup uses a large reusable UI kit in src/app/components/ui/, including dialogs, tables, forms, tabs, sidebars, charts, alerts, and inputs.
- This indicates a component-driven frontend architecture with shared primitives across modules rather than isolated page-specific UIs.
- AuthContext.tsx suggests authentication state is managed centrally in the UI prototype.
7. Main business data flow
- The intended flow is: user logs in → chooses company/role context → works inside domain modules → transactions produce accounting and reporting outputs.
- Sales and purchases feed stock movement, accounting entries, and receivables/payables.
- Banking imports and reconciliation feed treasury state and cash visibility.
- Reporting modules consume transactional and accounting data to produce balances, VAT maps, SAF-T, and KPIs.
8. AI subsystem boundary
- The AI area is explicitly separate in the docs and in the mockup as its own module.
- Its job is to generate insights, alerts, suggestions, and natural-language answers using existing business data.
- A critical architectural rule is that AI does not directly mutate accounting data; it recommends and explains, but execution stays in the transactional/core system.
9. Compliance and audit as cross-cutting concerns
- The product is designed around Portuguese accounting/fiscal constraints: SNC, IVA, SAF-T, retention rules, and auditability.
- Planning docs emphasize:
- role-based access,
- multi-company access,
- audit logs,
- approvals,
- session/security controls,
- traceability for sensitive operations.
- In diagram terms, these are cross-cutting services touching every domain module.
10. Operational and integration boundaries
- The roadmap includes external-facing flows such as:
- email for password recovery and notifications,
- bank statement imports in CSV/OFX,
- export formats like PDF, Excel, CSV, and SAF-T.
- The repository does not show real backend connectors yet, but the architecture clearly anticipates import/export and integration adapters as separate concerns from core CRUD flows.
11. Automation around documentation
- docs/planificacao/scripts/ contains Python utilities for maintaining the planning material, such as auditing, migration, and traceability generation.
- scripts/validate-planificacao.sh appears to enforce consistency in the planning structure.
- These are governance tools, not product runtime components, but they matter because they keep the specification aligned with the delivery model.
12. What is missing from the repository
- There is no production backend implementation in the tree shown.
- There is no persistent data layer code, API service, job worker, or deployment stack yet in the repository contents provided.
- So the architecture diagram should distinguish between:
- the documented target architecture,
- the front-end mockup/prototype,
- and the planning/governance tooling.
13. Best diagram framing
- Represent OPSA as three layers:
- Governance & planning: requirements, backlogs, sprint docs, validation scripts.
- Product prototype: React/Vite mockup with shared UI and module shells.
- Target ERP domain architecture: identity, company setup, sales, purchasing, inventory, accounting, banking, AI, reporting, audit/compliance.
- The most important boundaries are between transactional ERP data, AI recommendations, and audit/compliance controls.
Main entry points: README.md Planificação · App.tsx App shell · BACKLOG-MVP.md Backlogs · button.tsx UI primitives
Components 22
Governance & planning
Requirements, roadmap, backlog, sprint planning, and validation tooling that define the target system.
- RF · Functional requirements and product scope for the OPSA ERP.
docs/RF.md - RNF · Non-functional requirements covering performance, security, usability, and compliance.
docs/RNF.md - Planificação · Roadmap, sprints, backlog structure, and implementation sequencing.
docs/planificacao/README.md - Backlogs · Canonical backlog matrices and per-phase planning artifacts.
docs/planificacao/backlogs/BACKLOG-MVP.md - MF0–MF4 · Core delivery phases covering identity, sales, stock, accounting, banking, reporting, and AI.
docs/planificacao/guias-bk/MF0/BK-MF0-01-registo-login-e-logout-com-cookies-httponly.md - MF5–MF8 · Quality, performance, security, hardening, observability, and localization phases.
docs/planificacao/guias-bk/MF5/BK-MF5-01-interface-intuitiva-clara-e-consistente-entre-modulos-vendas-compras-inventario-contabilidade.md - Validate plan · Shell validation for the planning documentation structure.
scripts/validate-planificacao.sh
Product prototype
Vite + React UI mockup that demonstrates the ERP shell and module structure.
- App shell · Entry point and top-level UI composition for the prototype.
mockup/src/app/App.tsx - Layout · Page framing, navigation structure, and shared shell behavior.
mockup/src/app/components/Layout.tsx - Login · Authentication screen used by the prototype to enter the ERP.
mockup/src/app/components/Login.tsx - Auth state · Centralized login and session state for the mockup.
mockup/src/app/context/AuthContext.tsx - UI primitives · Reusable dialogs, tables, forms, navigation, charts, and feedback components.
mockup/src/app/components/ui/button.tsx - Dashboard · Overview screen for KPIs, alerts, and summary activity.
mockup/src/app/components/modules/Dashboard.tsx - ERP modules · Domain screens for Vendas, Compras, Inventario, Contabilidade, Bancos, IA, and Configuracoes.
mockup/src/app/components/modules/Vendas.tsx
Target ERP architecture
Documented functional domains and cross-cutting controls for the intended OPSA product.
- ERP core · Target transactional backbone for company context, master data, and business operations.
- Access & setup · Users, roles, company setup, fiscal periods, and base master data.
- Sales & buying · Invoices, credit notes, receipts, supplier bills, approvals, and automated postings.
- Stock & books · Inventory movements, costing, manual entries, trial balance, and financial statements.
- Banking & reports · Cash accounts, statement import, reconciliation, treasury, SAF-T, and KPIs.
- AI insights · Recommendations, explanations, alerts, and natural-language answers using business data only.
- Audit & compliance · RBAC, multi-company access, auditability, approvals, retention, and fiscal constraints.
- Imports & exports · Email, CSV/OFX imports, and PDF/Excel/CSV/SAF-T outputs as external interfaces.
Connections 27
- RF → Planificação: defines scope
- RNF → Planificação: constrains delivery
- Planificação → Backlogs: organizes
- Backlogs → MF0–MF4: phases
- Backlogs → MF5–MF8: phases
- Validate plan → Planificação: checks consistency
- App shell → Layout: renders
- App shell → Login: gates access
- App shell → ERP modules: hosts
- Login → Auth state: uses
- Layout → UI primitives: shares primitives
- ERP modules → UI primitives: composes
- Dashboard → UI primitives: composes
- RF → ERP core: targets
- Access & setup → ERP core: anchors
- Sales & buying → ERP core: produces transactions
- Stock & books → ERP core: posts stock and ledger
- Banking & reports → ERP core: consumes transactions
- AI insights → ERP core: analyzes data
- Audit & compliance → Access & setup: governs
- Audit & compliance → Sales & buying: governs
- Audit & compliance → Stock & books: governs
- Audit & compliance → Banking & reports: governs
- Audit & compliance → AI insights: bounds
- Imports & exports → Banking & reports: imports/exports
- Imports & exports → Sales & buying: imports/exports
- Imports & exports → Audit & compliance: logs