# carvalhoglc/loveclothes architecture

> Architecture diagram of the GitHub repository carvalhoglc/loveclothes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carvalhoglc/loveclothes
- Repository: https://github.com/carvalhoglc/loveclothes

## Overview

LoveClothes is a clothing e-commerce MVP: shoppers browse product variants, register or log in, create orders that reserve stock, and initiate Pix payments; they can also view order history. The frontend calls a FastAPI backend organized around routes, services, repositories, and a gateway adapter, with PostgreSQL as persistent storage. The README documents the main capabilities and layer structure. Some wiring is only documented, not shown in excerpts, so uncertain frontend-to-endpoint and repository-to-database links are omitted or identified as documented.

Main entry points: [`backend/app/api/deps.py`](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/deps.py) (Dependency wiring), [`backend/app/main.py`](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/main.py) (App setup), [`backend/app/gateways/juntos_gateway.py`](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/gateways/juntos_gateway.py) (Juntos adapter), [`backend/app/api/routes/auth.py`](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/routes/auth.py) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_frontend["Storefront UI<br/>[App.tsx]"]
  node_frontend_api["API client<br/>[api.ts]"]
end

subgraph group_api["API and security"]
  node_app["App setup<br/>[main.py]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_product_routes["Product routes<br/>[products.py]"]
  node_order_routes["Order routes<br/>[orders.py]"]
  node_dependencies["Dependency wiring<br/>[deps.py]"]
  node_schemas["Request and response DTOs<br/>[dtos.py]"]
  node_security["JWT and passwords<br/>[security.py]"]
  node_rate_limit["Rate limiting<br/>[limiter.py]"]
  node_errors["Error handling<br/>[errors.py]"]
end

subgraph group_commerce["Commerce domain"]
  node_auth_service["Authentication<br/>[auth_service.py]"]
  node_catalog_service["Product catalog<br/>[catalog_service.py]"]
  node_order_service["Order and stock<br/>[order_service.py]"]
  node_payment_service["Payment lifecycle<br/>[payment_service.py]"]
  node_states["Order states<br/>[states.py]"]
end

subgraph group_persistence["Persistence"]
  node_repositories["Data repositories<br/>[repositories.py]"]
  node_entities["Commerce entities<br/>[entities.py]"]
  node_db_session["Database session<br/>[session.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_integrations["Payment integration"]
  node_gateway_adapter["Juntos adapter<br/>[juntos_gateway.py]"]
  node_gateway_contract["Gateway contract<br/>[base.py]"]
end

node_shopper(("Shopper"))
node_juntos["Juntos sandbox"]

node_shopper -->|"uses"| node_frontend
node_frontend -->|"calls"| node_frontend_api
node_frontend_api -.->|"sends requests"| node_app
node_app -->|"registers"| node_auth_routes
node_app -->|"registers"| node_product_routes
node_app -->|"registers"| node_order_routes
node_auth_routes -->|"calls"| node_auth_service
node_product_routes -->|"calls"| node_catalog_service
node_order_routes -->|"calls"| node_order_service
node_order_routes -->|"calls"| node_payment_service
node_dependencies -->|"constructs"| node_auth_service
node_dependencies -->|"constructs"| node_catalog_service
node_dependencies -->|"constructs"| node_order_service
node_dependencies -->|"constructs"| node_payment_service
node_dependencies -->|"constructs"| node_repositories
node_dependencies -->|"provides"| node_gateway_adapter
node_auth_service -->|"hashes and verifies"| node_security
node_order_service -->|"cancels payments"| node_gateway_adapter
node_payment_service -->|"creates payments"| node_gateway_adapter
node_order_service -->|"checks transitions"| node_states
node_payment_service -->|"checks transitions"| node_states
node_gateway_adapter -->|"implements"| node_gateway_contract
node_gateway_adapter -->|"sends HTTP requests"| node_juntos
node_repositories -->|"uses"| node_entities
node_db_session -->|"opens sessions"| node_postgres
node_auth_routes -->|"validates and returns"| node_schemas
node_product_routes -->|"returns"| node_schemas
node_order_routes -->|"validates and returns"| node_schemas
node_app -->|"registers handlers"| node_errors
node_app -->|"configures"| node_rate_limit
node_auth_routes -->|"limits requests"| node_rate_limit

click node_frontend "https://github.com/carvalhoglc/loveclothes/blob/master/frontend/src/App.tsx"
click node_frontend_api "https://github.com/carvalhoglc/loveclothes/blob/master/frontend/src/api.ts"
click node_app "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/main.py"
click node_auth_routes "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/routes/auth.py"
click node_product_routes "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/routes/products.py"
click node_order_routes "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/routes/orders.py"
click node_dependencies "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/deps.py"
click node_schemas "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/schemas/dtos.py"
click node_security "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/core/security.py"
click node_rate_limit "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/core/limiter.py"
click node_errors "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/core/errors.py"
click node_auth_service "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/auth_service.py"
click node_catalog_service "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/catalog_service.py"
click node_order_service "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/order_service.py"
click node_payment_service "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/payment_service.py"
click node_states "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/domain/states.py"
click node_repositories "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/repositories/repositories.py"
click node_entities "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/models/entities.py"
click node_db_session "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/db/session.py"
click node_gateway_adapter "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/gateways/juntos_gateway.py"
click node_gateway_contract "https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/gateways/base.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_frontend_api toneBlue
class node_app,node_auth_routes,node_product_routes,node_order_routes,node_dependencies,node_schemas,node_security,node_rate_limit,node_errors toneAmber
class node_auth_service,node_catalog_service,node_order_service,node_payment_service,node_states toneMint
class node_repositories,node_entities,node_db_session,node_postgres toneRose
class node_gateway_adapter,node_gateway_contract,node_shopper,node_juntos toneIndigo
```

## Components

### Storefront

- [Storefront UI](https://github.com/carvalhoglc/loveclothes/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/carvalhoglc/loveclothes/blob/master/frontend/src/api.ts): `frontend/src/api.ts`

### API and security

- [App setup](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/main.py): `backend/app/main.py`
- [Auth routes](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/routes/auth.py): `backend/app/api/routes/auth.py`
- [Product routes](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/routes/products.py): `backend/app/api/routes/products.py`
- [Order routes](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/routes/orders.py): `backend/app/api/routes/orders.py`
- [Dependency wiring](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/api/deps.py): `backend/app/api/deps.py`
- [Request and response DTOs](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/schemas/dtos.py): `backend/app/schemas/dtos.py`
- [JWT and passwords](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/core/security.py): `backend/app/core/security.py`
- [Rate limiting](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/core/limiter.py): `backend/app/core/limiter.py`
- [Error handling](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/core/errors.py): `backend/app/core/errors.py`

### Commerce domain

- [Authentication](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Product catalog](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/catalog_service.py): `backend/app/services/catalog_service.py`
- [Order and stock](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/order_service.py): `backend/app/services/order_service.py`
- [Payment lifecycle](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/services/payment_service.py): `backend/app/services/payment_service.py`
- [Order states](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/domain/states.py): `backend/app/domain/states.py`

### Persistence

- [Data repositories](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/repositories/repositories.py): `backend/app/repositories/repositories.py`
- [Commerce entities](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/models/entities.py): `backend/app/models/entities.py`
- [Database session](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/db/session.py): `backend/app/db/session.py`
- **PostgreSQL**

### Payment integration

- [Juntos adapter](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/gateways/juntos_gateway.py): `backend/app/gateways/juntos_gateway.py`
- [Gateway contract](https://github.com/carvalhoglc/loveclothes/blob/master/backend/app/gateways/base.py): `backend/app/gateways/base.py`

### Other components

- **Shopper**
- **Juntos sandbox**

## Connections

- Shopper → Storefront UI: uses (evidence: `README.md`)
- Storefront UI → API client: calls (evidence: `frontend/src/App.tsx`)
- API client → App setup: sends requests
- App setup → Auth routes: registers (evidence: `backend/app/main.py`)
- App setup → Product routes: registers (evidence: `backend/app/main.py`)
- App setup → Order routes: registers (evidence: `backend/app/main.py`)
- Auth routes → Authentication: calls (evidence: `backend/app/api/routes/auth.py`)
- Product routes → Product catalog: calls (evidence: `backend/app/api/routes/products.py`)
- Order routes → Order and stock: calls (evidence: `backend/app/api/routes/orders.py`)
- Order routes → Payment lifecycle: calls (evidence: `backend/app/api/routes/orders.py`)
- Dependency wiring → Authentication: constructs (evidence: `backend/app/api/deps.py`)
- Dependency wiring → Product catalog: constructs (evidence: `backend/app/api/deps.py`)
- Dependency wiring → Order and stock: constructs (evidence: `backend/app/api/deps.py`)
- Dependency wiring → Payment lifecycle: constructs (evidence: `backend/app/api/deps.py`)
- Dependency wiring → Data repositories: constructs (evidence: `backend/app/api/deps.py`)
- Dependency wiring → Juntos adapter: provides (evidence: `backend/app/api/deps.py`)
- Authentication → JWT and passwords: hashes and verifies (evidence: `backend/app/services/auth_service.py`)
- Order and stock → Juntos adapter: cancels payments (evidence: `backend/app/services/order_service.py`)
- Payment lifecycle → Juntos adapter: creates payments (evidence: `backend/app/services/payment_service.py`)
- Order and stock → Order states: checks transitions (evidence: `backend/app/services/order_service.py`)
- Payment lifecycle → Order states: checks transitions (evidence: `backend/app/services/payment_service.py`)
- Juntos adapter → Gateway contract: implements (evidence: `backend/app/api/deps.py`)
- Juntos adapter → Juntos sandbox: sends HTTP requests (evidence: `backend/app/gateways/juntos_gateway.py`)
- Data repositories → Commerce entities: uses (evidence: `backend/app/repositories/repositories.py`)
- Database session → PostgreSQL: opens sessions (evidence: `README.md`)
- Auth routes → Request and response DTOs: validates and returns (evidence: `backend/app/api/routes/auth.py`)
- Product routes → Request and response DTOs: returns (evidence: `backend/app/api/routes/products.py`)
- Order routes → Request and response DTOs: validates and returns (evidence: `backend/app/api/routes/orders.py`)
- App setup → Error handling: registers handlers (evidence: `backend/app/main.py`)
- App setup → Rate limiting: configures (evidence: `backend/app/main.py`)
- Auth routes → Rate limiting: limits requests (evidence: `backend/app/api/routes/auth.py`)
