# cankutayucar/api-mvc architecture

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

- Interactive diagram: https://gitdiagram.com/cankutayucar/api-mvc
- Repository: https://github.com/cankutayucar/api-mvc

## Overview

This repository is a product-and-category API backed by a SQL Server data layer, with a separate, small MVC web application. The main workflow is an API request through a controller and product service, into repositories and the unit of work, with results mapped into response DTOs; product reads also use in-memory caching. Category and validation capabilities are represented from the tree and registration, though their source was not sampled. The README provides no further product detail.

Main entry points: [`Architecture.Caching/ProductServiceWithCaching.cs`](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Caching/ProductServiceWithCaching.cs) (Cached product service), [`Architecture.Repository/AppDbContext.cs`](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/AppDbContext.cs) (EF database context), [`Architecture.API/Controllers/ProductsController.cs`](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Controllers/ProductsController.cs) (Products controller), [`Architecture.Repository/Concrete/UnitOfWork/UnitOfWork.cs`](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/UnitOfWork/UnitOfWork.cs) (Unit of work)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and validation"]
  node_products["Products controller"]
  node_categories["Categories controller"]
  node_response["Response formatting"]
  node_validation["Request validation"]
  node_exception["Exception handling"]
end

subgraph group_services["Application services"]
  node_product_service["Cached product service"]
  node_category_service["Category service<br/>[CategoryService.cs]"]
  node_generic_service["Generic service<br/>[Service.cs]"]
  node_mapping["DTO mapping<br/>[MapProfile.cs]"]
  node_product_validator["Product validator"]
end

subgraph group_data["Persistence"]
  node_product_repo["Product repository"]
  node_category_repo["Category repository"]
  node_generic_repo["Generic repository"]
  node_uow["Unit of work<br/>[UnitOfWork.cs]"]
  node_dbcontext["EF database context<br/>[AppDbContext.cs]"]
end

subgraph group_web["MVC web"]
  node_home["Home controller<br/>[HomeController.cs]"]
end

node_client(("API client"))
node_database[("SQL Server")]
node_web_user(("Web visitor"))

node_client -->|"requests"| node_products
node_products -->|"calls"| node_product_service
node_products -->|"maps DTOs"| node_mapping
node_products -->|"formats result"| node_response
node_client -->|"requests"| node_categories
node_categories -->|"calls"| node_category_service
node_categories -->|"formats result"| node_response
node_validation -->|"validates with"| node_product_validator
node_product_service -->|"queries and writes"| node_product_repo
node_product_service -->|"commits"| node_uow
node_product_service -->|"maps results"| node_mapping
node_product_service -.->|"queries related data"| node_category_repo
node_category_service -->|"uses"| node_category_repo
node_category_service -->|"commits"| node_uow
node_generic_service -->|"uses"| node_generic_repo
node_generic_service -->|"commits"| node_uow
node_product_repo -->|"uses"| node_dbcontext
node_category_repo -->|"uses"| node_dbcontext
node_generic_repo -->|"queries and changes"| node_dbcontext
node_uow -->|"commits"| node_dbcontext
node_dbcontext -->|"persists data"| node_database
node_exception -->|"returns error"| node_client
node_web_user -->|"requests pages"| node_home

click node_products "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Controllers/ProductsController.cs"
click node_categories "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Controllers/CategoriesController.cs"
click node_response "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Controllers/CustomBaseController.cs"
click node_validation "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Filters/ValidateFilterAttribute.cs"
click node_exception "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Middlewares/UseCustomExceptionHandler.cs"
click node_product_service "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Caching/ProductServiceWithCaching.cs"
click node_category_service "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Abstract/Services/CategoryService.cs"
click node_generic_service "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Abstract/Services/Service.cs"
click node_mapping "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Mapper/MapProfile.cs"
click node_product_validator "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Validators/ProductDtoValidator.cs"
click node_product_repo "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/Repositories/ProductRepository.cs"
click node_category_repo "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/Repositories/CategoryRepository.cs"
click node_generic_repo "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/Repositories/GenericRepository.cs"
click node_uow "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/UnitOfWork/UnitOfWork.cs"
click node_dbcontext "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/AppDbContext.cs"
click node_home "https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Web/Controllers/HomeController.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_products,node_categories,node_response,node_validation,node_exception,node_client toneBlue
class node_product_service,node_category_service,node_generic_service,node_mapping,node_product_validator,node_database toneAmber
class node_product_repo,node_category_repo,node_generic_repo,node_uow,node_dbcontext toneMint
class node_home toneRose
class node_web_user toneIndigo
```

## Components

### API and validation

- [Products controller](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Controllers/ProductsController.cs): `Architecture.API/Controllers/ProductsController.cs`
- [Categories controller](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Controllers/CategoriesController.cs): `Architecture.API/Controllers/CategoriesController.cs`
- [Response formatting](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Controllers/CustomBaseController.cs): `Architecture.API/Controllers/CustomBaseController.cs`
- [Request validation](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Filters/ValidateFilterAttribute.cs): `Architecture.API/Filters/ValidateFilterAttribute.cs`
- [Exception handling](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.API/Middlewares/UseCustomExceptionHandler.cs): `Architecture.API/Middlewares/UseCustomExceptionHandler.cs`

### Application services

- [Cached product service](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Caching/ProductServiceWithCaching.cs): `Architecture.Caching/ProductServiceWithCaching.cs`
- [Category service](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Abstract/Services/CategoryService.cs): `Architecture.Service/Abstract/Services/CategoryService.cs`
- [Generic service](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Abstract/Services/Service.cs): `Architecture.Service/Abstract/Services/Service.cs`
- [DTO mapping](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Mapper/MapProfile.cs): `Architecture.Service/Mapper/MapProfile.cs`
- [Product validator](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Service/Validators/ProductDtoValidator.cs): `Architecture.Service/Validators/ProductDtoValidator.cs`

### Persistence

- [Product repository](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/Repositories/ProductRepository.cs): `Architecture.Repository/Concrete/Repositories/ProductRepository.cs`
- [Category repository](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/Repositories/CategoryRepository.cs): `Architecture.Repository/Concrete/Repositories/CategoryRepository.cs`
- [Generic repository](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/Repositories/GenericRepository.cs): `Architecture.Repository/Concrete/Repositories/GenericRepository.cs`
- [Unit of work](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/Concrete/UnitOfWork/UnitOfWork.cs): `Architecture.Repository/Concrete/UnitOfWork/UnitOfWork.cs`
- [EF database context](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Repository/AppDbContext.cs): `Architecture.Repository/AppDbContext.cs`

### MVC web

- [Home controller](https://github.com/cankutayucar/api-mvc/blob/main/Architecture.Web/Controllers/HomeController.cs): `Architecture.Web/Controllers/HomeController.cs`

### Other components

- **API client**
- **SQL Server**
- **Web visitor**

## Connections

- API client → Products controller: requests
- Products controller → Cached product service: calls
- Products controller → DTO mapping: maps DTOs
- Products controller → Response formatting: formats result
- API client → Categories controller: requests
- Categories controller → Category service: calls
- Categories controller → Response formatting: formats result
- Request validation → Product validator: validates with
- Cached product service → Product repository: queries and writes
- Cached product service → Unit of work: commits
- Cached product service → DTO mapping: maps results
- Cached product service → Category repository: queries related data
- Category service → Category repository: uses
- Category service → Unit of work: commits
- Generic service → Generic repository: uses
- Generic service → Unit of work: commits
- Product repository → EF database context: uses
- Category repository → EF database context: uses
- Generic repository → EF database context: queries and changes
- Unit of work → EF database context: commits
- EF database context → SQL Server: persists data
- Exception handling → API client: returns error
- Web visitor → Home controller: requests pages
