docs: add detailed mermaid diagrams for db, backend and marketplace

This commit is contained in:
Tiago Yamamoto 2025-12-27 01:13:11 -03:00
parent 6b23d05383
commit 89036d7b39
3 changed files with 248 additions and 0 deletions

91
backend/README.md Normal file
View file

@ -0,0 +1,91 @@
# SaveInMed Backend API
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.
```mermaid
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

66
docs/DATABASE_SCHEMA.md Normal file
View file

@ -0,0 +1,66 @@
# Database Schema
This document visualizes the SaveInMed database schema using Mermaid.
```mermaid
erDiagram
%% Entities
COMPANY {
int id pk
string name
enum status "ACTIVE | INACTIVE | SUSPENDED"
datetime createdAt
datetime updatedAt
}
USER {
int id pk
string email uk
string password
string name
enum role "USER | ADMIN"
int companyId fk
string refreshToken
datetime createdAt
datetime updatedAt
}
PRODUCT {
int id pk
string name
string sku uk
decimal price "10,2"
datetime createdAt
datetime updatedAt
}
INVENTORY_ITEM {
int id pk
int productId fk, uk
int quantity
datetime updatedAt
}
ORDER {
int id pk
int buyerId fk
int productId fk
int quantity
decimal total "12,2"
datetime createdAt
}
SYSTEM_SETTINGS {
string key pk
string value
string category "default: GENERAL"
boolean isSecure "default: false"
datetime updatedAt
}
%% Relationships
COMPANY ||--|{ USER : "has"
USER ||--|{ ORDER : "places"
PRODUCT ||--|| INVENTORY_ITEM : "has stock"
PRODUCT ||--|{ ORDER : "included in"
```

91
marketplace/README.md Normal file
View file

@ -0,0 +1,91 @@
# SaveInMed Marketplace Frontend
The Marketplace is the customer-facing B2B application where pharmacies purchase products from distributors.
## 🏗 Architecture
The frontend is built with React and Vite, utilizing a component-based architecture state management.
```mermaid
graph TD
%% User
User((User))
%% Core
subgraph "Application Core"
App[App Root]
Router[React Router]
Store[Zustand Store]
Query[TanStack Query]
end
%% Pages
subgraph "Pages / Routes"
LoginP[Login/Auth]
HomeP[Home / Catalog]
ProdP[Product Details]
CartP[Shopping Cart]
CheckoutP[Checkout]
ProfileP[User Profile]
OrdersP[Order History]
end
%% Feature Components
subgraph "Smart Components"
AuthForm[Auth Forms]
ProdGrid[Product Grid]
CartWidget[Cart Widget]
PayWidget[Payment Widget]
AddressForm[Address Manager]
end
%% API Layer
subgraph "API Integration"
API[API Client (Axios)]
Backend[Backend API]
end
%% Flow
User --> App
App --> Router
App --> Store
Router --> LoginP
Router --> HomeP
Router --> ProdP
Router --> CartP
Router --> CheckoutP
Router --> ProfileP
Router --> OrdersP
HomeP --> ProdGrid
CartP --> CartWidget
CheckoutP --> PayWidget
CheckoutP --> AddressForm
ProdGrid --> Store
CartWidget --> Store
PayWidget --> Store
Store --> API
Query --> API
API --> Backend
%% Styling
style User fill:#f9f,stroke:#333,stroke-width:2px
style Backend fill:#f87171,stroke:#333,stroke-width:2px
style Store fill:#60a5fa,stroke:#333
```
## 🛠 Tech Stack
- **Framework**: React 18 + Vite
- **Styling**: TailwindCSS
- **State**: Zustand + TanStack Query
- **Routing**: React Router DOM
- **HTTP**: Axios
## 📦 Key Modules
- **Authentication**: JWT-based login and session management
- **Catalog**: Virtualized product lists with search and filter
- **Checkout**: Multi-step checkout with payment integration
- **Dashboard**: User order history and status tracking