# victorborges97/efix architecture

> Architecture diagram of the GitHub repository victorborges97/efix, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/victorborges97/efix
- Repository: https://github.com/victorborges97/efix

## Overview

##### Project type and purpose
- This is a full-stack web application (“eFix – Sistema de Gerenciamento de Soluções de Erros”) composed of:
- Backend: NestJS monolith exposing REST endpoints (and a WebSocket gateway)
- Frontend: React (Vite) SPA
- Database: PostgreSQL via Prisma ORM
- Containerization: Docker Compose for local DB

##### File structure
- Top-level folders:
- backend/
- frontend/
- Backend structure (NestJS):
- src/app.module.ts – root module
- Modules: dashboard, evaluations, suggestions, events, prisma, shared
- Prisma folder: schema.prisma, migrations, seed.ts
- Configuration: docker-compose.yml, env.example, eslint, tsconfig
- Frontend structure (Vite + React):
- src/pages – page components (dashboard-page, suggestions-page)
- src/components – layout + UI building blocks (ShadCN UI wrappers)
- src/lib – API client (Axios), socket.io wrapper, utils
- src/shared – DTOs, hooks (use-socket), interfaces, utilities
- Config: vite.config.ts, tailwind.config.js, env.example

##### README for additional insights
- Purpose: CRUD for suggestions + evaluations, reporting dashboard
- Phases: suggestion management, evaluation management, dashboard filters, real-time updates planned
- Tech stack: NestJS, Prisma, PostgreSQL, React, Tailwind, ShadCN UI, Axios, React Hook Form, Zod

##### Elements
- Clear labels:
- “React SPA” with sub-areas: Pages, Components, Hooks
- “NestJS API” with modules listed
- “PostgreSQL” (Prisma)
- Blue rectangles for UI layer
- Green for Backend services

##### Detailed capture of essential elements
- Frontend: Data fetching (Axios), real-time hooks, form validation
- Backend: Business logic (Services), API contracts (DTOs/Zod), DB access (Prisma), real-time gateway
- DB: Schema entities: ErrorSuggestion, Evaluation
- Sequence for a typical flow:
1. User fills suggestion form → Axios POST → SuggestionsController → SuggestionsService → Prisma → DB
2. User views dashboard → HTTP GET → DashboardService aggregates data via Prisma
3. (Real-time) Backend emits events → Frontend use-socket hook updates UI

Summary
- Detail on modules’ roles without overcrowding—group where logical

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (React SPA)" 
        direction TB
        FE_Main["SPA Entry Point"]:::frontend
        FE_Routes["Routing Configuration"]:::frontend
        FE_Pages["Pages"]:::frontend
        FE_Layout["Layout Components"]:::frontend
        FE_UI["UI Components (ShadCN)"]:::frontend
        FE_Lib["API & Socket Clients"]:::frontend
        FE_Shared["Shared DTOs & Hooks"]:::frontend
    end

    FE_Main -->|imports| FE_Routes
    FE_Routes -->|routes to| FE_Pages
    FE_Pages -->|uses| FE_Layout
    FE_Layout -->|renders| FE_UI
    FE_Main -->|calls| FE_Lib
    FE_Main -->|uses| FE_Shared

    %% Frontend Pages
    subgraph "Pages" 
        direction TB
        DashboardPage["Dashboard Page"]:::frontend
        SuggestionsPage["Suggestions Page"]:::frontend
    end
    FE_Pages --> DashboardPage
    FE_Pages --> SuggestionsPage

    %% Frontend Layout
    subgraph "Layout" 
        direction TB
        AppLayout["App Layout"]:::frontend
        Navbar["Navbar"]:::frontend
    end
    FE_Layout --> AppLayout
    FE_Layout --> Navbar

    %% Frontend UI Components
    FE_UI --> UI_Components["*.tsx"]:::frontend

    %% Frontend Lib
    subgraph "Lib" 
        direction TB
        API_Client["API Client (Axios)"]:::api
        Socket_Client["WebSocket Client"]:::socket
    end
    FE_Lib --> API_Client
    FE_Lib --> Socket_Client

    %% Frontend Shared
    subgraph "Shared" 
        direction TB
        DTOs_FE["DTOs"]:::shared
        Hooks_FE["use-socket Hook"]:::shared
        Interfaces_FE["Interfaces"]:::shared
    end
    FE_Shared --> DTOs_FE
    FE_Shared --> Hooks_FE
    FE_Shared --> Interfaces_FE

    %% Backend Layer
    subgraph "Backend (NestJS Monolith)" 
        direction TB
        BE_Main["Application Root Module"]:::backend
        BE_Entry["Entry Point"]:::backend
        ModulesGroup["Modules"]:::backend
        Shared_BE["Shared Utilities"]:::backend
    end

    BE_Entry --> BE_Main
    BE_Main --> ModulesGroup
    BE_Main --> Shared_BE

    subgraph "Modules" 
        direction TB
        DashModule["Dashboard Module"]:::module
        SugModule["Suggestions Module"]:::module
        EvalModule["Evaluations Module"]:::module
        EventsModule["Events (WebSocket) Module"]:::module
        PrismaModule["Prisma Module"]:::module
    end
    ModulesGroup --> DashModule
    ModulesGroup --> SugModule
    ModulesGroup --> EvalModule
    ModulesGroup --> EventsModule
    ModulesGroup --> PrismaModule

    %% DB Container
    subgraph "Local DB Container (Docker Compose)" 
        direction TB
        DB_Container["PostgreSQL"]:::container
        Schema["schema.prisma"]:::db
        Migrations["migrations/*"]:::db
        Seed["seed.ts"]:::db
    end

    DB_Container --> Schema
    DB_Container --> Migrations
    DB_Container --> Seed

    %% Interactions
    DashboardPage -->|GET /dashboard| DashModule
    SuggestionsPage -->|POST /suggestions| SugModule
    SugModule -->|calls| PrismaModule
    DashModule -->|aggregates via| PrismaModule
    EvalModule -->|calls| PrismaModule
    EventsModule -->|WebSocket events| Socket_Client
    API_Client -->|REST calls| BE_Entry
    Socket_Client -->|WebSocket| EventsModule
    PrismaModule -->|queries| DB_Container

    %% Click Events
    click FE_Main "https://github.com/victorborges97/efix/blob/master/frontend/src/main.tsx"
    click FE_Routes "https://github.com/victorborges97/efix/blob/master/frontend/src/routes.tsx"
    click DashboardPage "https://github.com/victorborges97/efix/blob/master/frontend/src/pages/dashboard-page.tsx"
    click SuggestionsPage "https://github.com/victorborges97/efix/blob/master/frontend/src/pages/suggestions-page.tsx"
    click AppLayout "https://github.com/victorborges97/efix/blob/master/frontend/src/components/layout/app-layout.tsx"
    click Navbar "https://github.com/victorborges97/efix/blob/master/frontend/src/components/layout/navbar.tsx"
    click UI_Components "https://github.com/victorborges97/efix/tree/master/frontend/src/components/ui"
    click API_Client "https://github.com/victorborges97/efix/blob/master/frontend/src/lib/api.ts"
    click Socket_Client "https://github.com/victorborges97/efix/blob/master/frontend/src/lib/socket.io.tsx"
    click DTOs_FE "https://github.com/victorborges97/efix/tree/master/frontend/src/shared/dto"
    click Hooks_FE "https://github.com/victorborges97/efix/blob/master/frontend/src/shared/hooks/use-socket.ts"
    click Interfaces_FE "https://github.com/victorborges97/efix/tree/master/frontend/src/shared/interfaces"
    click BE_Main "https://github.com/victorborges97/efix/blob/master/backend/src/app.module.ts"
    click BE_Entry "https://github.com/victorborges97/efix/blob/master/backend/src/main.ts"
    click DashModule "https://github.com/victorborges97/efix/blob/master/backend/src/dashboard/dashboard.module.ts"
    click SugModule "https://github.com/victorborges97/efix/blob/master/backend/src/suggestions/suggestions.module.ts"
    click EvalModule "https://github.com/victorborges97/efix/blob/master/backend/src/evaluations/evaluations.module.ts"
    click EventsModule "https://github.com/victorborges97/efix/blob/master/backend/src/events/events.module.ts"
    click PrismaModule "https://github.com/victorborges97/efix/blob/master/backend/src/prisma/prisma.module.ts"
    click Shared_BE "https://github.com/victorborges97/efix/tree/master/backend/src/shared/dto"
    click Schema "https://github.com/victorborges97/efix/blob/master/backend/prisma/schema.prisma"
    click Migrations "https://github.com/victorborges97/efix/tree/master/backend/prisma/migrations"
    click Seed "https://github.com/victorborges97/efix/blob/master/backend/prisma/seed.ts"
    click DB_Container "https://github.com/victorborges97/efix/blob/master/backend/docker-compose.yml"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#3794FF,color:#000
    classDef api fill:#E8F4FF,stroke:#4B9FFF,color:#000
    classDef socket fill:#FFF4E5,stroke:#FFA500,color:#000
    classDef shared fill:#F0F0F0,stroke:#A0A0A0,color:#000
    classDef backend fill:#E8FFE8,stroke:#28A745,color:#000
    classDef module fill:#DFF7DF,stroke:#28A745,color:#000
    classDef container fill:#F0F0F0,stroke:#6C757D,color:#000
    classDef db fill:#FFE8E8,stroke:#D73A49,color:#000
```
