Backend: - Adição das migrações SQL 0012 e 0013 para estrutura de produtos e itens de estoque. - Implementação do método [CreateInventoryItem](cci:1://file:///c:/Projetos/saveinmed/backend-old/internal/http/handler/handler_test.go:168:0-170:1) no repositório Postgres e mocks de teste. - Atualização do [product_handler.go](cci:7://file:///c:/Projetos/saveinmed/backend-old/internal/http/handler/product_handler.go:0:0-0:0) para suportar `original_price_cents` e corrigir filtragem de estoque. - Mapeamento da rota GET `/api/v1/produtos-venda` no [server.go](cci:7://file:///c:/Projetos/saveinmed/backend-old/internal/server/server.go:0:0-0:0). - Ajuste no endpoint `/auth/me` para retornar `empresasDados` (ID da empresa) necessário ao frontend. - Refatoração da query [ListInventory](cci:1://file:///c:/Projetos/saveinmed/backend-old/internal/repository/postgres/postgres.go:771:0-805:1) para buscar da tabela correta e incluir nome do produto. Frontend: - Correção no mapeamento de dados (snake_case para camelCase) na página de Gestão de Produtos. - Ajustes de integração no Wizard de Cadastro de Produtos (`CadastroProdutoWizard.tsx`). - Atualização da tipagem para exibir corretamente preços e estoque a partir da API. |
||
|---|---|---|
| .. | ||
| cmd | ||
| docs | ||
| internal | ||
| .env | ||
| .env.example | ||
| .gitignore | ||
| api | ||
| BACKEND.md | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| login.json | ||
| main | ||
| README.md | ||
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