# harjuniya/authservice architecture

> Architecture diagram of the GitHub repository harjuniya/authservice, 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/harjuniya/authservice
- Repository: https://github.com/harjuniya/authservice

## Overview

This repository contains three ASP.NET services for user authentication, product inventory, and order management. The main user workflow is registering or logging in to obtain a JWT, then using it to access product and order APIs; administrators also manage products, while users create, view, and cancel orders. The sampled order logic persists orders but does not call the registered inventory client, so no order-to-inventory runtime link is asserted.

Main entry points: [`InventoryService/Controllers/ProductController.cs`](https://github.com/harjuniya/authservice/blob/master/InventoryService/Controllers/ProductController.cs) (Product API), [`AuthService/Services/AuthService.cs`](https://github.com/harjuniya/authservice/blob/master/AuthService/Services/AuthService.cs) (Auth logic), [`OrderService/Controllers/OrderController.cs`](https://github.com/harjuniya/authservice/blob/master/OrderService/Controllers/OrderController.cs) (Order API), [`AuthService/Controllers/AuthController.cs`](https://github.com/harjuniya/authservice/blob/master/AuthService/Controllers/AuthController.cs) (Auth API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Authentication"]
  node_auth_api["Auth API<br/>[AuthController.cs]"]
  node_auth_logic["Auth logic<br/>[AuthService.cs]"]
  node_user_repository["User repository<br/>[UserRepository.cs]"]
  node_auth_db[("Auth database<br/>[AuthDbContext.cs]")]
  node_jwt["JWT token"]
end

subgraph group_inventory["Inventory"]
  node_product_api["Product API"]
  node_product_logic["Product service<br/>[ProductService.cs]"]
  node_product_repository["Product repository"]
  node_inventory_db[("Inventory database")]
end

subgraph group_orders["Orders"]
  node_order_api["Order API<br/>[OrderController.cs]"]
  node_order_logic["Order service<br/>[OrderService.cs]"]
  node_order_repository["Order repository<br/>[OrderRepository.cs]"]
  node_order_db[("Order database<br/>[OrderDbContext.cs]")]
end

node_user(("User"))
node_admin(("Administrator"))

node_user -->|"registers or logs in"| node_auth_api
node_auth_api -->|"calls"| node_auth_logic
node_auth_logic -->|"reads and saves users"| node_user_repository
node_user_repository -->|"queries and writes"| node_auth_db
node_auth_logic -->|"issues token"| node_jwt
node_user -->|"requests products"| node_product_api
node_admin -->|"manages products"| node_product_api
node_product_api -->|"calls"| node_product_logic
node_product_logic -->|"loads and changes products"| node_product_repository
node_product_repository -->|"queries and writes"| node_inventory_db
node_user -->|"requests orders"| node_order_api
node_order_api -->|"calls"| node_order_logic
node_order_logic -->|"loads and saves orders"| node_order_repository
node_order_repository -->|"queries and writes"| node_order_db
node_jwt -->|"authorizes requests"| node_product_api
node_jwt -->|"authorizes requests"| node_order_api

click node_auth_api "https://github.com/harjuniya/authservice/blob/master/AuthService/Controllers/AuthController.cs"
click node_auth_logic "https://github.com/harjuniya/authservice/blob/master/AuthService/Services/AuthService.cs"
click node_user_repository "https://github.com/harjuniya/authservice/blob/master/AuthService/Repositories/UserRepository.cs"
click node_auth_db "https://github.com/harjuniya/authservice/blob/master/AuthService/Data/AuthDbContext.cs"
click node_product_api "https://github.com/harjuniya/authservice/blob/master/InventoryService/Controllers/ProductController.cs"
click node_product_logic "https://github.com/harjuniya/authservice/blob/master/InventoryService/Services/ProductService.cs"
click node_product_repository "https://github.com/harjuniya/authservice/blob/master/InventoryService/Repositories/ProductRepository.cs"
click node_inventory_db "https://github.com/harjuniya/authservice/blob/master/InventoryService/Data/InventoryDbContext.cs"
click node_order_api "https://github.com/harjuniya/authservice/blob/master/OrderService/Controllers/OrderController.cs"
click node_order_logic "https://github.com/harjuniya/authservice/blob/master/OrderService/Services/OrderService.cs"
click node_order_repository "https://github.com/harjuniya/authservice/blob/master/OrderService/Repositories/OrderRepository.cs"
click node_order_db "https://github.com/harjuniya/authservice/blob/master/OrderService/Data/OrderDbContext.cs"

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_auth_api,node_auth_logic,node_user_repository,node_auth_db,node_jwt,node_user toneBlue
class node_product_api,node_product_logic,node_product_repository,node_inventory_db toneAmber
class node_order_api,node_order_logic,node_order_repository,node_order_db toneMint
class node_admin toneIndigo
```

## Components

### Authentication

- [Auth API](https://github.com/harjuniya/authservice/blob/master/AuthService/Controllers/AuthController.cs): `AuthService/Controllers/AuthController.cs`
- [Auth logic](https://github.com/harjuniya/authservice/blob/master/AuthService/Services/AuthService.cs): `AuthService/Services/AuthService.cs`
- [User repository](https://github.com/harjuniya/authservice/blob/master/AuthService/Repositories/UserRepository.cs): `AuthService/Repositories/UserRepository.cs`
- [Auth database](https://github.com/harjuniya/authservice/blob/master/AuthService/Data/AuthDbContext.cs): `AuthService/Data/AuthDbContext.cs`
- **JWT token**

### Inventory

- [Product API](https://github.com/harjuniya/authservice/blob/master/InventoryService/Controllers/ProductController.cs): `InventoryService/Controllers/ProductController.cs`
- [Product service](https://github.com/harjuniya/authservice/blob/master/InventoryService/Services/ProductService.cs): `InventoryService/Services/ProductService.cs`
- [Product repository](https://github.com/harjuniya/authservice/blob/master/InventoryService/Repositories/ProductRepository.cs): `InventoryService/Repositories/ProductRepository.cs`
- [Inventory database](https://github.com/harjuniya/authservice/blob/master/InventoryService/Data/InventoryDbContext.cs): `InventoryService/Data/InventoryDbContext.cs`

### Orders

- [Order API](https://github.com/harjuniya/authservice/blob/master/OrderService/Controllers/OrderController.cs): `OrderService/Controllers/OrderController.cs`
- [Order service](https://github.com/harjuniya/authservice/blob/master/OrderService/Services/OrderService.cs): `OrderService/Services/OrderService.cs`
- [Order repository](https://github.com/harjuniya/authservice/blob/master/OrderService/Repositories/OrderRepository.cs): `OrderService/Repositories/OrderRepository.cs`
- [Order database](https://github.com/harjuniya/authservice/blob/master/OrderService/Data/OrderDbContext.cs): `OrderService/Data/OrderDbContext.cs`

### Other components

- **User**
- **Administrator**

## Connections

- User → Auth API: registers or logs in
- Auth API → Auth logic: calls
- Auth logic → User repository: reads and saves users
- User repository → Auth database: queries and writes
- Auth logic → JWT token: issues token
- User → Product API: requests products
- Administrator → Product API: manages products
- Product API → Product service: calls
- Product service → Product repository: loads and changes products
- Product repository → Inventory database: queries and writes
- User → Order API: requests orders
- Order API → Order service: calls
- Order service → Order repository: loads and saves orders
- Order repository → Order database: queries and writes
- JWT token → Product API: authorizes requests
- JWT token → Order API: authorizes requests
