# projeto-pw-402/back-office architecture

> Architecture diagram of the GitHub repository projeto-pw-402/back-office, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/projeto-pw-402/back-office
- Repository: https://github.com/projeto-pw-402/back-office

## Overview

##### Project Type and Purpose
- This is a front-end SPA built with Vue 3, using Vite as bundler/dev server.
- It serves as a “Back-Office” admin interface (dashboards, CRUD pages) that communicates with one or more backend REST APIs.

##### File Structure
- src/main.ts: Application entry point — mounts the Vue app.
- src/router/index.ts: Controls navigation between pages.
- src/pages & src/subpages: Top-level views (Dashboard, Login, Materiais, etc.) and modal/detail subviews.
- src/components: Reusable UI pieces (Navbar, charts, statistics).
- src/services: HTTP client modules (auditoriasService, materialService, userService) that wrap calls to external APIs.
- src/models: TypeScript interfaces/classes for domain entities (User, Material, Auditoria).
- public & index.html: Static assets and HTML container.
- Configuration: vite.config.ts, tsconfig*.json, eslint.config.ts.

##### README for Insights
- Reinforces that this is a Vue 3 + Vite template.
- No built-in backend — all data flows via services to external endpoints.
- Uses pnpm, ESLint, Volar for TypeScript support.

##### Main Components and Their Relationships
a. Browser/User
– Initiates the SPA by loading index.html.
b. Vite Dev/Build Pipeline
– Dev server serves modules, supports HMR.
– Build process bundles and outputs static assets.
c. SPA Layer
– main.ts: bootstraps Vue app.
– Router: client-side routing between pages/subpages.
– Pages & Subpages: view components representing screens and dialogs.
– Components: UI building blocks used across pages.
– Services: abstraction layer for all HTTP interactions.
– Models: Type definitions ensuring type safety end-to-end.
d. External Backend API(s)
– REST endpoints for users, materials, auditorias, etc.
– Services call these endpoints, parse JSON into Models, surface results to components.

##### Architectural Patterns & Principles
- Component-based UI (Vue).
- Separation of concerns:
- Presentation (components/pages)
- Routing (router)
- Data access (services)
- Domain (models)
- Typed contracts between layers (TypeScript interfaces).
- Config-driven build/dev (Vite + tsconfig + eslint).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Tooling & Configuration
    subgraph "Tooling & Configuration"
        direction TB
        ViteDev["Vite Dev Server"]:::tooling
        ViteBuild["Vite Build"]:::tooling
        ESLint["ESLint"]:::tooling
        TSCompiler["TypeScript Compiler"]:::tooling
        vitecfg["vite.config.ts"]:::config
        tsconfig["tsconfig*.json"]:::config
        eslintcfg["eslint.config.ts"]:::config
        prettier[".prettierrc.json"]:::config
    end

    %% Static Assets
    public["public/"]:::static
    index["index.html"]:::static

    %% Front-End SPA Boundary
    subgraph "Front-End SPA (Vue 3 + Vite)"
        direction TB
        Browser["Browser/User"]:::external
        Main["main.ts"]:::entry
        Router["Router"]:::routing

        subgraph "Presentation Layer"
            direction TB
            Dash["Dashboard.vue"]:::frontend
            Login["Login.vue"]:::frontend
            Materiais["Materiais.vue"]:::frontend
            Monitor["Monitoramento.vue"]:::frontend
            Utilizadores["Utilizadores.vue"]:::frontend
            CriarA["CriarAuditoria.vue"]:::frontend
            EditMat["EditMaterial.vue"]:::frontend
            NewMat["NewMaterial.vue"]:::frontend
            NewUser["NewUser.vue"]:::frontend
            Pedidos["Pedidos.vue"]:::frontend
            Chart["ChartAuditorias.vue"]:::frontend
            Estat["Estatistica.vue"]:::frontend
            Nav["Navbar.vue"]:::frontend
        end

        subgraph "Services Layer"
            direction TB
            AS["AuditoriasService"]:::data
            MS["MaterialService"]:::data
            US["UserService"]:::data
        end

        subgraph "Models Layer"
            direction TB
            ModA["Auditoria.ts"]:::model
            ModM["Material.ts"]:::model
            ModU["User.ts"]:::model
        end
    end

    %% External Systems
    ExternalAPI["Backend REST API"]:::external

    %% Connections
    Browser --> index
    index --> Main
    Main --> Router
    Router --> Dash
    Router --> Login
    Router --> Materiais
    Router --> Monitor
    Router --> Utilizadores
    Dash --> Chart
    Dash --> Estat
    AnyUI(( )):::placeholder
    Dash -->|opens modal| CriarA
    Materiais -->|edit/new| EditMat
    Materiais -->|new| NewMat
    Utilizadores -->|new| NewUser
    Monitor -->|view requests| Pedidos

    Dash --> AS
    Login --> US
    Materiais --> MS
    Monitor --> AS
    Utilizadores --> US

    AS --> ExternalAPI
    MS --> ExternalAPI
    US --> ExternalAPI

    ExternalAPI -->|JSON| ModA
    ExternalAPI -->|JSON| ModM
    ExternalAPI -->|JSON| ModU

    ModA --> AS
    ModM --> MS
    ModU --> US

    %% Tooling Flows
    ViteDev --> index
    ViteDev --> Main
    ViteBuild --> public
    ViteBuild --> index

    %% Click Events
    click Main "https://github.com/projeto-pw-402/back-office/blob/main/src/main.ts"
    click Router "https://github.com/projeto-pw-402/back-office/blob/main/src/router/index.ts"
    click Dash "https://github.com/projeto-pw-402/back-office/blob/main/src/pages/Dashboard.vue"
    click Login "https://github.com/projeto-pw-402/back-office/blob/main/src/pages/Login.vue"
    click Materiais "https://github.com/projeto-pw-402/back-office/blob/main/src/pages/Materiais.vue"
    click Monitor "https://github.com/projeto-pw-402/back-office/blob/main/src/pages/Monitoramento.vue"
    click Utilizadores "https://github.com/projeto-pw-402/back-office/blob/main/src/pages/Utilizadores.vue"
    click CriarA "https://github.com/projeto-pw-402/back-office/blob/main/src/subpages/CriarAuditoria.vue"
    click EditMat "https://github.com/projeto-pw-402/back-office/blob/main/src/subpages/EditMaterial.vue"
    click NewMat "https://github.com/projeto-pw-402/back-office/blob/main/src/subpages/NewMaterial.vue"
    click NewUser "https://github.com/projeto-pw-402/back-office/blob/main/src/subpages/NewUser.vue"
    click Pedidos "https://github.com/projeto-pw-402/back-office/blob/main/src/subpages/Pedidos.vue"
    click Chart "https://github.com/projeto-pw-402/back-office/blob/main/src/components/ChartAuditorias.vue"
    click Estat "https://github.com/projeto-pw-402/back-office/blob/main/src/components/Estatistica.vue"
    click Nav "https://github.com/projeto-pw-402/back-office/blob/main/src/components/Navbar.vue"
    click AS "https://github.com/projeto-pw-402/back-office/blob/main/src/services/auditoriasService.ts"
    click MS "https://github.com/projeto-pw-402/back-office/blob/main/src/services/materialService.ts"
    click US "https://github.com/projeto-pw-402/back-office/blob/main/src/services/userService.ts"
    click ModA "https://github.com/projeto-pw-402/back-office/blob/main/src/models/Auditoria.ts"
    click ModM "https://github.com/projeto-pw-402/back-office/blob/main/src/models/Material.ts"
    click ModU "https://github.com/projeto-pw-402/back-office/blob/main/src/models/User.ts"
    click index "https://github.com/projeto-pw-402/back-office/blob/main/index.html"
    click public "https://github.com/projeto-pw-402/back-office/tree/main/public/"
    click vitecfg "https://github.com/projeto-pw-402/back-office/blob/main/vite.config.ts"
    click tsconfig "https://github.com/projeto-pw-402/back-office/blob/main/tsconfig.json"
    click eslintcfg "https://github.com/projeto-pw-402/back-office/blob/main/eslint.config.ts"
    click prettier "https://github.com/projeto-pw-402/back-office/blob/main/.prettierrc.json"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef data fill:#E6FFEA,stroke:#28a745,color:#28a745;
    classDef model fill:#FFF5E6,stroke:#d97706,color:#d97706;
    classDef tooling fill:#FFF0F6,stroke:#db2777,color:#db2777;
    classDef config fill:#F0F4FF,stroke:#4c51bf,color:#4c51bf;
    classDef static fill:#F5F5F5,stroke:#6B7280,color:#374151;
    classDef entry fill:#E5F6FF,stroke:#0C4A6E,color:#075985;
    classDef routing fill:#E0F2FE,stroke:#0284C7,color:#0369A1;
    classDef external fill:#F3F4F6,stroke:#9CA3AF,color:#6B7280;
    classDef placeholder fill:none,stroke:none;
```
