# olartbaraq/ra-nkan_backend architecture

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

- Interactive diagram: https://gitdiagram.com/olartbaraq/ra-nkan_backend
- Repository: https://github.com/olartbaraq/ra-nkan_backend

## Overview

SpectrumShelf is a Go/Gin ecommerce API. Clients call the registered auth, catalog, shop, product, and order endpoints; handlers validate requests and use generated SQL queries to work with PostgreSQL, returning API responses. Authentication supports password registration/login, token refresh/logout, and Google sign-in; product media can use Cloudinary. The tree and README establish the broader ecommerce domains, but most handler implementations were not sampled, so their detailed query wiring is not shown. Redis is initialized in server setup, but its runtime use is not established by the excerpts.

Main entry points: [`api/server.go`](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/server.go) (Gin server), [`api/oauth.go`](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/oauth.go) (Google sign-in), [`api/auth.go`](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/auth.go) (Auth API), [`db/sqlc`](https://github.com/olartbaraq/ra-nkan_backend/tree/main/db/sqlc) (SQL queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_server["Gin server<br/>[server.go]"]
end

subgraph group_identity["Identity"]
  node_user["User API<br/>[user.go]"]
  node_auth["Auth API<br/>[auth.go]"]
  node_oauth["Google sign-in<br/>[oauth.go]"]
  node_middleware["Auth middleware<br/>[middleware.go]"]
  node_tokens["JWT tokens<br/>[token.go]"]
end

subgraph group_commerce["Commerce domains"]
  node_category["Category API<br/>[category.go]"]
  node_subcategory["Subcategory API<br/>[sub_category.go]"]
  node_shop["Shop API<br/>[shop.go]"]
  node_product["Product API<br/>[product.go]"]
  node_order["Order API<br/>[order.go]"]
end

subgraph group_data["Data and integrations"]
  node_queries["SQL queries"]
  node_postgres[("PostgreSQL")]
  node_media["Media service<br/>[media_service.go]"]
  node_cloudinary["Cloudinary"]
  node_google["Google identity"]
  node_redis[("Redis client")]
end

node_client(("API client"))

node_client -->|"HTTP requests"| node_server
node_server -->|"register routes"| node_user
node_server -->|"register routes"| node_auth
node_server -->|"register routes"| node_oauth
node_server -->|"register routes"| node_category
node_server -->|"register routes"| node_subcategory
node_server -->|"register routes"| node_shop
node_server -->|"register routes"| node_product
node_server -->|"register routes"| node_order
node_server -->|"initializes client"| node_redis
node_auth -->|"user queries"| node_queries
node_oauth -->|"user queries"| node_queries
node_auth -->|"create and verify"| node_tokens
node_oauth -->|"create tokens"| node_tokens
node_middleware -->|"verify tokens"| node_tokens
node_oauth -->|"fetch token info"| node_google
node_queries -->|"SQL reads and writes"| node_postgres
node_media -->|"upload images"| node_cloudinary
node_product -.->|"media operations"| node_media

click node_server "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/server.go"
click node_user "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/user.go"
click node_auth "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/auth.go"
click node_oauth "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/oauth.go"
click node_middleware "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/middleware.go"
click node_tokens "https://github.com/olartbaraq/ra-nkan_backend/blob/main/utils/token.go"
click node_category "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/category.go"
click node_subcategory "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/sub_category.go"
click node_shop "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/shop.go"
click node_product "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/product.go"
click node_order "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/order.go"
click node_queries "https://github.com/olartbaraq/ra-nkan_backend/tree/main/db/sqlc"
click node_media "https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/media_service.go"

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_server,node_client toneBlue
class node_user,node_auth,node_oauth,node_middleware,node_tokens toneAmber
class node_category,node_subcategory,node_shop,node_product,node_order toneMint
class node_queries,node_postgres,node_media,node_cloudinary,node_google,node_redis toneRose
```

## Components

### API runtime

- [Gin server](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/server.go): `api/server.go`

### Identity

- [User API](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/user.go): `api/user.go`
- [Auth API](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/auth.go): `api/auth.go`
- [Google sign-in](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/oauth.go): `api/oauth.go`
- [Auth middleware](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/middleware.go): `api/middleware.go`
- [JWT tokens](https://github.com/olartbaraq/ra-nkan_backend/blob/main/utils/token.go): `utils/token.go`

### Commerce domains

- [Category API](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/category.go): `api/category.go`
- [Subcategory API](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/sub_category.go): `api/sub_category.go`
- [Shop API](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/shop.go): `api/shop.go`
- [Product API](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/product.go): `api/product.go`
- [Order API](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/order.go): `api/order.go`

### Data and integrations

- [SQL queries](https://github.com/olartbaraq/ra-nkan_backend/tree/main/db/sqlc): `db/sqlc`
- **PostgreSQL**
- [Media service](https://github.com/olartbaraq/ra-nkan_backend/blob/main/api/media_service.go): `api/media_service.go`
- **Cloudinary**
- **Google identity**
- **Redis client**

### Other components

- **API client**

## Connections

- API client → Gin server: HTTP requests
- Gin server → User API: register routes
- Gin server → Auth API: register routes
- Gin server → Google sign-in: register routes
- Gin server → Category API: register routes
- Gin server → Subcategory API: register routes
- Gin server → Shop API: register routes
- Gin server → Product API: register routes
- Gin server → Order API: register routes
- Gin server → Redis client: initializes client
- Auth API → SQL queries: user queries
- Google sign-in → SQL queries: user queries
- Auth API → JWT tokens: create and verify
- Google sign-in → JWT tokens: create tokens
- Auth middleware → JWT tokens: verify tokens
- Google sign-in → Google identity: fetch token info
- SQL queries → PostgreSQL: SQL reads and writes
- Media service → Cloudinary: upload images
- Product API → Media service: media operations
