# hussienahmed653/serveybasket architecture

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

- Interactive diagram: https://gitdiagram.com/hussienahmed653/serveybasket
- Repository: https://github.com/hussienahmed653/serveybasket

## Overview

Survey Basket is an ASP.NET Core API for managing surveys, identity, voting, and results. A typical workflow is to create and publish a poll, add questions and answers, accept votes, then query aggregated results. The graph also preserves registration and token flows, role-based access management, and the documented background-notification capability. Sampled services show EF Core persistence; question availability also uses HybridCache. Source excerpts and the index support the cited relationships; other documented capabilities are included without asserting unsampled wiring.

Main entry points: [`ServeyBasket.Api/Persistense/ServeyBasketDbContext.cs`](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Persistense/ServeyBasketDbContext.cs) (Application database), [`ServeyBasket.Api/Services/Authentications/AuthServices.cs`](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Authentications/AuthServices.cs) (Authentication flows), [`ServeyBasket.Api/Services/Roles/RoleService.cs`](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Roles/RoleService.cs) (Role management), [`ServeyBasket.Api/Services/Polls/PollServices.cs`](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Polls/PollServices.cs) (Poll operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_survey["Survey and voting"]
  node_poll_api["Poll endpoints<br/>[PollsController.cs]"]
  node_poll_service["Poll operations<br/>[PollServices.cs]"]
  node_question_api["Question endpoints"]
  node_question_service["Question operations"]
  node_vote_api["Voting endpoints<br/>[VotesController.cs]"]
  node_vote_service["Vote operations<br/>[VoteServices.cs]"]
  node_answer_service["Answer operations<br/>[AnswerServices.cs]"]
  node_results_api["Results endpoints"]
  node_results_service["Results aggregation<br/>[ResultServices.cs]"]
end

subgraph group_identity["Identity and access"]
  node_auth_api["Authentication endpoints<br/>[AuthController.cs]"]
  node_auth_service["Authentication flows<br/>[AuthServices.cs]"]
  node_jwt["JWT provider<br/>[JwtProvider.cs]"]
  node_roles_api["Role endpoints<br/>[RolesController.cs]"]
  node_role_service["Role management<br/>[RoleService.cs]"]
  node_users_api["User endpoints<br/>[UsersController.cs]"]
  node_user_service["User management<br/>[UserService.cs]"]
  node_permission_auth["Permission authorization"]
end

subgraph group_platform["Persistence and platform"]
  node_db[("Application database")]
  node_notification["Poll notifications"]
end

node_user(("API client"))
node_email["Email sender"]
node_cache[("Hybrid cache")]

node_user -->|"requests polls"| node_poll_api
node_poll_api -->|"calls"| node_poll_service
node_poll_service -->|"reads and writes"| node_db
node_user -->|"requests questions"| node_question_api
node_question_api -->|"calls"| node_question_service
node_question_service -->|"reads and writes"| node_db
node_question_service -->|"gets and invalidates"| node_cache
node_user -.->|"submits votes"| node_vote_api
node_vote_api -.->|"dispatches"| node_vote_service
node_vote_service -->|"reads and writes"| node_db
node_user -.->|"requests results"| node_results_api
node_results_api -.->|"dispatches"| node_results_service
node_results_service -->|"reads votes"| node_db
node_user -->|"authenticates"| node_auth_api
node_auth_api -->|"calls"| node_auth_service
node_auth_service -->|"uses context"| node_db
node_auth_service -->|"generates tokens"| node_jwt
node_user -.->|"manages roles"| node_roles_api
node_roles_api -.->|"dispatches"| node_role_service
node_role_service -->|"reads and writes"| node_db
node_user -->|"manages users"| node_users_api
node_users_api -->|"calls"| node_user_service
node_user_service -->|"checks allowed roles"| node_role_service
node_user_service -->|"reads and writes"| node_db
node_permission_auth -.->|"enforces claims"| node_role_service
node_poll_service -->|"queues notifications"| node_notification
node_notification -->|"reads recipients"| node_db
node_notification -.->|"sends email"| node_email
node_auth_service -->|"queues account email"| node_email

click node_poll_api "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/PollsController.cs"
click node_poll_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Polls/PollServices.cs"
click node_question_api "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/QuestionsController.cs"
click node_question_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Questions/QuestionServices.cs"
click node_vote_api "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/VotesController.cs"
click node_vote_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Votes/VoteServices.cs"
click node_answer_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Answers/AnswerServices.cs"
click node_results_api "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/ResultsController.cs"
click node_results_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Results/ResultServices.cs"
click node_auth_api "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/AuthController.cs"
click node_auth_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Authentications/AuthServices.cs"
click node_jwt "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Authentication/JwtProvider.cs"
click node_roles_api "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/RolesController.cs"
click node_role_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Roles/RoleService.cs"
click node_users_api "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/UsersController.cs"
click node_user_service "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Users/UserService.cs"
click node_permission_auth "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Authentication/Filters/PermissionAuthorizationHandler.cs"
click node_db "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Persistense/ServeyBasketDbContext.cs"
click node_notification "https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/BackgroundJobNotification/NotificationService.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_poll_api,node_poll_service,node_question_api,node_question_service,node_vote_api,node_vote_service,node_answer_service,node_results_api,node_results_service,node_user toneBlue
class node_auth_api,node_auth_service,node_jwt,node_roles_api,node_role_service,node_users_api,node_user_service,node_permission_auth,node_cache toneAmber
class node_db,node_notification toneMint
class node_email toneIndigo
```

## Components

### Survey and voting

- [Poll endpoints](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/PollsController.cs): `ServeyBasket.Api/Controllers/PollsController.cs`
- [Poll operations](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Polls/PollServices.cs): `ServeyBasket.Api/Services/Polls/PollServices.cs`
- [Question endpoints](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/QuestionsController.cs): `ServeyBasket.Api/Controllers/QuestionsController.cs`
- [Question operations](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Questions/QuestionServices.cs): `ServeyBasket.Api/Services/Questions/QuestionServices.cs`
- [Voting endpoints](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/VotesController.cs): `ServeyBasket.Api/Controllers/VotesController.cs`
- [Vote operations](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Votes/VoteServices.cs): `ServeyBasket.Api/Services/Votes/VoteServices.cs`
- [Answer operations](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Answers/AnswerServices.cs): `ServeyBasket.Api/Services/Answers/AnswerServices.cs`
- [Results endpoints](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/ResultsController.cs): `ServeyBasket.Api/Controllers/ResultsController.cs`
- [Results aggregation](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Results/ResultServices.cs): `ServeyBasket.Api/Services/Results/ResultServices.cs`

### Identity and access

- [Authentication endpoints](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/AuthController.cs): `ServeyBasket.Api/Controllers/AuthController.cs`
- [Authentication flows](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Authentications/AuthServices.cs): `ServeyBasket.Api/Services/Authentications/AuthServices.cs`
- [JWT provider](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Authentication/JwtProvider.cs): `ServeyBasket.Api/Authentication/JwtProvider.cs`
- [Role endpoints](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/RolesController.cs): `ServeyBasket.Api/Controllers/RolesController.cs`
- [Role management](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Roles/RoleService.cs): `ServeyBasket.Api/Services/Roles/RoleService.cs`
- [User endpoints](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Controllers/UsersController.cs): `ServeyBasket.Api/Controllers/UsersController.cs`
- [User management](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/Users/UserService.cs): `ServeyBasket.Api/Services/Users/UserService.cs`
- [Permission authorization](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Authentication/Filters/PermissionAuthorizationHandler.cs): `ServeyBasket.Api/Authentication/Filters/PermissionAuthorizationHandler.cs`

### Persistence and platform

- [Application database](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Persistense/ServeyBasketDbContext.cs): `ServeyBasket.Api/Persistense/ServeyBasketDbContext.cs`
- [Poll notifications](https://github.com/hussienahmed653/serveybasket/blob/main/ServeyBasket.Api/Services/BackgroundJobNotification/NotificationService.cs): `ServeyBasket.Api/Services/BackgroundJobNotification/NotificationService.cs`

### Other components

- **API client**
- **Email sender**
- **Hybrid cache**

## Connections

- API client → Poll endpoints: requests polls (evidence: `ServeyBasket.Api/Controllers/PollsController.cs`)
- Poll endpoints → Poll operations: calls (evidence: `ServeyBasket.Api/Controllers/PollsController.cs`)
- Poll operations → Application database: reads and writes (evidence: `ServeyBasket.Api/Services/Polls/PollServices.cs`)
- API client → Question endpoints: requests questions (evidence: `ServeyBasket.Api/Controllers/QuestionsController.cs`)
- Question endpoints → Question operations: calls (evidence: `ServeyBasket.Api/Controllers/QuestionsController.cs`)
- Question operations → Application database: reads and writes (evidence: `ServeyBasket.Api/Services/Questions/QuestionServices.cs`)
- Question operations → Hybrid cache: gets and invalidates (evidence: `ServeyBasket.Api/Services/Questions/QuestionServices.cs`)
- API client → Voting endpoints: submits votes
- Voting endpoints → Vote operations: dispatches
- Vote operations → Application database: reads and writes (evidence: `ServeyBasket.Api/Services/Votes/VoteServices.cs`)
- API client → Results endpoints: requests results
- Results endpoints → Results aggregation: dispatches
- Results aggregation → Application database: reads votes (evidence: `ServeyBasket.Api/Services/Results/ResultServices.cs`)
- API client → Authentication endpoints: authenticates (evidence: `ServeyBasket.Api/Controllers/AuthController.cs`)
- Authentication endpoints → Authentication flows: calls (evidence: `ServeyBasket.Api/Controllers/AuthController.cs`)
- Authentication flows → Application database: uses context (evidence: `ServeyBasket.Api/Services/Authentications/AuthServices.cs`)
- Authentication flows → JWT provider: generates tokens (evidence: `ServeyBasket.Api/Services/Authentications/AuthServices.cs`)
- API client → Role endpoints: manages roles
- Role endpoints → Role management: dispatches
- Role management → Application database: reads and writes (evidence: `ServeyBasket.Api/Services/Roles/RoleService.cs`)
- API client → User endpoints: manages users (evidence: `ServeyBasket.Api/Controllers/UsersController.cs`)
- User endpoints → User management: calls (evidence: `ServeyBasket.Api/Controllers/UsersController.cs`)
- User management → Role management: checks allowed roles (evidence: `ServeyBasket.Api/Services/Users/UserService.cs`)
- User management → Application database: reads and writes (evidence: `ServeyBasket.Api/Services/Users/UserService.cs`)
- Permission authorization → Role management: enforces claims
- Poll operations → Poll notifications: queues notifications (evidence: `ServeyBasket.Api/Services/Polls/PollServices.cs`)
- Poll notifications → Application database: reads recipients (evidence: `ServeyBasket.Api/Services/BackgroundJobNotification/NotificationService.cs`)
- Poll notifications → Email sender: sends email
- Authentication flows → Email sender: queues account email (evidence: `ServeyBasket.Api/Services/Authentications/AuthServices.cs`)
