saveinmed/backend/README.md
Gabbriiel 90467db1ec refactor: substitui backend Medusa por backend Go e corrige testes do marketplace
- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core)
- Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token
- Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers
- Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 04:56:37 -06:00

2.3 KiB

SaveInMed Backend API

Status (pronto x faltando)

Pronto

  • Conteúdo descrito neste documento.

Faltando

  • Confirmar no código o estado real das funcionalidades e atualizar esta seção conforme necessário.

This service handles the core business logic, data persistence, and external integrations for the SaveInMed B2B Marketplace.

🏗 Architecture

The backend follows a layered architecture to ensure separation of concerns and maintainability.

graph TD
    %% Clients
    Client([Client Application])
    
    %% Entry Point
    subgraph "API Layer"
        Router[Router / Middleware]
        AuthH[Auth Handler]
        UserH[User Handler]
        ProdH[Product Handler]
        CartH[Cart Handler]
        OrderH[Order Handler]
        PayH[Payment Handler]
        ShipH[Shipping Handler]
    end

    %% Business Logic
    subgraph "Service Layer"
        AuthS[Auth Service]
        UserS[User Service]
        ProdS[Catalog Service]
        OrderS[Order Service]
        PayS[Payment Service]
        ShipS[Shipping Service]
    end

    %% Data / Infra
    subgraph "Infrastructure Layer"
        DB[(PostgreSQL)]
        MP[Mercado Pago Adapter]
        Asaas[Asaas Adapter]
        Stripe[Stripe Adapter]
        Mapbox[Mapbox Service]
    end

    %% Flows
    Client --> Router
    Router --> AuthH
    Router --> UserH
    Router --> ProdH
    Router --> CartH
    Router --> OrderH
    Router --> PayH
    Router --> ShipH

    AuthH --> AuthS
    UserH --> UserS
    ProdH --> ProdS
    CartH --> OrderS
    OrderH --> OrderS
    PayH --> PayS
    ShipH --> ShipS

    AuthS --> DB
    UserS --> DB
    ProdS --> DB
    OrderS --> DB
    
    PayS --> MP
    PayS --> Asaas
    PayS --> Stripe
    
    ShipS --> Mapbox

    %% Styling
    style Client fill:#f9f,stroke:#333
    style Router fill:#ff9,stroke:#333
    style DB fill:#94a3b8,stroke:#333

🛠 Tech Stack

  • Language: Go 1.24+
  • Framework: Standard Library + Chi/Mux (inferred)
  • Database: PostgreSQL
  • Docs: Swagger/OpenAPI

🚀 Key Features

  • High-performance REST API
  • JWT Authentication
  • Role-Based Access Control
  • Payment Gateway Integration (Mercado Pago, Asaas, Stripe)
  • Real-time Inventory Management

🧪 Tests

go test ./... -cover

Para matriz completa (com/sem banco e Playwright), veja: docs/TESTES.md