# andrianavalonaango-dev/vote_api architecture

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

- Interactive diagram: https://gitdiagram.com/andrianavalonaango-dev/vote_api
- Repository: https://github.com/andrianavalonaango-dev/vote_api

## Overview

Vote API is a NestJS REST service for user, poll, option, and vote management. Its central workflow creates polls for users, adds poll options, accepts one valid vote per user per poll, and exposes calculated results; scheduled processing closes expired polls. Controllers route requests to domain services, which use TypeORM entities for persistence. The README documents MySQL, validation, and the scheduled closure capability. Relationships among the sampled controllers and services are evidenced in source; some unsampled wiring and the precise database configuration are not shown.

Main entry points: [`src/votes/votes.service.ts`](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/votes.service.ts) (Vote Operations), [`src/polls/polls.controller.ts`](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/polls/polls.controller.ts) (Poll Routes), [`src/options/options.service.ts`](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/options.service.ts) (Option Operations), [`src/users/users.service.ts`](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/users.service.ts) (User Operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_polls_controller["Poll Routes"]
  node_options_controller["Option Routes"]
  node_votes_controller["Vote Routes"]
  node_users_controller["User Routes"]
end

subgraph group_polls["Poll Management"]
  node_polls_service["Poll Operations<br/>[polls.service.ts]"]
  node_poll_model["Poll Model<br/>[poll.entity.ts]"]
  node_poll_dtos["Poll DTOs"]
  node_options_service["Option Operations<br/>[options.service.ts]"]
  node_option_model["Option Model<br/>[option.entity.ts]"]
  node_option_dto["Option DTO"]
end

subgraph group_participation["Voting"]
  node_votes_service["Vote Operations<br/>[votes.service.ts]"]
  node_vote_model["Vote Model<br/>[vote.entity.ts]"]
  node_vote_dto["Vote DTO<br/>[create-vote.dto.ts]"]
end

subgraph group_identity["Users and Persistence"]
  node_users_service["User Operations<br/>[users.service.ts]"]
  node_user_model["User Model<br/>[user.entity.ts]"]
  node_user_dto["User DTO<br/>[create-user.dto.ts]"]
  node_mysql[("MySQL")]
end

node_client(("API Client"))

node_client -->|"requests"| node_polls_controller
node_client -->|"requests"| node_options_controller
node_client -->|"requests"| node_votes_controller
node_client -->|"requests"| node_users_controller
node_polls_controller -->|"dispatches"| node_polls_service
node_polls_controller -->|"looks up user"| node_users_service
node_polls_controller -->|"accepts"| node_poll_dtos
node_options_controller -->|"dispatches"| node_options_service
node_options_controller -->|"accepts"| node_option_dto
node_votes_controller -->|"dispatches"| node_votes_service
node_votes_controller -->|"accepts"| node_vote_dto
node_users_controller -->|"dispatches"| node_users_service
node_users_controller -->|"accepts"| node_user_dto
node_polls_service -->|"persists and queries"| node_poll_model
node_options_service -->|"persists and queries"| node_option_model
node_options_service -->|"checks poll"| node_poll_model
node_votes_service -->|"persists and queries"| node_vote_model
node_votes_service -->|"checks user"| node_user_model
node_votes_service -->|"checks poll"| node_poll_model
node_votes_service -->|"checks option"| node_option_model
node_users_service -->|"persists and queries"| node_user_model
node_polls_service -.->|"stores poll data"| node_mysql
node_options_service -.->|"stores option data"| node_mysql
node_votes_service -.->|"stores vote data"| node_mysql
node_users_service -.->|"stores user data"| node_mysql

click node_polls_controller "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/polls/polls.controller.ts"
click node_options_controller "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/options.controller.ts"
click node_votes_controller "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/votes.controller.ts"
click node_users_controller "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/users.controller.ts"
click node_polls_service "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/polls/polls.service.ts"
click node_poll_model "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/polls/entities/poll.entity.ts"
click node_poll_dtos "https://github.com/andrianavalonaango-dev/vote_api/tree/main/src/polls/dto"
click node_options_service "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/options.service.ts"
click node_option_model "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/entities/option.entity.ts"
click node_option_dto "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/dto/create-option.dto.ts"
click node_votes_service "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/votes.service.ts"
click node_vote_model "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/entities/vote.entity.ts"
click node_vote_dto "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/dto/create-vote.dto.ts"
click node_users_service "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/users.service.ts"
click node_user_model "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/entities/user.entity.ts"
click node_user_dto "https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/dto/create-user.dto.ts"

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_polls_controller,node_options_controller,node_votes_controller,node_users_controller,node_client toneBlue
class node_polls_service,node_poll_model,node_poll_dtos,node_options_service,node_option_model,node_option_dto toneAmber
class node_votes_service,node_vote_model,node_vote_dto toneMint
class node_users_service,node_user_model,node_user_dto,node_mysql toneRose
```

## Components

### REST API

- [Poll Routes](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/polls/polls.controller.ts): `src/polls/polls.controller.ts`
- [Option Routes](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/options.controller.ts): `src/options/options.controller.ts`
- [Vote Routes](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/votes.controller.ts): `src/votes/votes.controller.ts`
- [User Routes](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/users.controller.ts): `src/users/users.controller.ts`

### Poll Management

- [Poll Operations](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/polls/polls.service.ts): `src/polls/polls.service.ts`
- [Poll Model](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/polls/entities/poll.entity.ts): `src/polls/entities/poll.entity.ts`
- [Poll DTOs](https://github.com/andrianavalonaango-dev/vote_api/tree/main/src/polls/dto): `src/polls/dto`
- [Option Operations](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/options.service.ts): `src/options/options.service.ts`
- [Option Model](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/entities/option.entity.ts): `src/options/entities/option.entity.ts`
- [Option DTO](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/options/dto/create-option.dto.ts): `src/options/dto/create-option.dto.ts`

### Voting

- [Vote Operations](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/votes.service.ts): `src/votes/votes.service.ts`
- [Vote Model](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/entities/vote.entity.ts): `src/votes/entities/vote.entity.ts`
- [Vote DTO](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/votes/dto/create-vote.dto.ts): `src/votes/dto/create-vote.dto.ts`

### Users and Persistence

- [User Operations](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- [User Model](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/entities/user.entity.ts): `src/users/entities/user.entity.ts`
- [User DTO](https://github.com/andrianavalonaango-dev/vote_api/blob/main/src/users/dto/create-user.dto.ts): `src/users/dto/create-user.dto.ts`
- **MySQL**

### Other components

- **API Client**

## Connections

- API Client → Poll Routes: requests (evidence: `README.md`)
- API Client → Option Routes: requests (evidence: `README.md`)
- API Client → Vote Routes: requests (evidence: `README.md`)
- API Client → User Routes: requests (evidence: `README.md`)
- Poll Routes → Poll Operations: dispatches (evidence: `src/polls/polls.controller.ts`)
- Poll Routes → User Operations: looks up user (evidence: `src/polls/polls.controller.ts`)
- Poll Routes → Poll DTOs: accepts (evidence: `src/polls/polls.controller.ts`)
- Option Routes → Option Operations: dispatches (evidence: `src/options/options.controller.ts`)
- Option Routes → Option DTO: accepts (evidence: `src/options/options.controller.ts`)
- Vote Routes → Vote Operations: dispatches (evidence: `src/votes/votes.controller.ts`)
- Vote Routes → Vote DTO: accepts (evidence: `src/votes/votes.controller.ts`)
- User Routes → User Operations: dispatches (evidence: `src/users/users.controller.ts`)
- User Routes → User DTO: accepts (evidence: `src/users/users.controller.ts`)
- Poll Operations → Poll Model: persists and queries (evidence: `src/polls/polls.service.ts`)
- Option Operations → Option Model: persists and queries (evidence: `src/options/options.service.ts`)
- Option Operations → Poll Model: checks poll (evidence: `src/options/options.service.ts`)
- Vote Operations → Vote Model: persists and queries (evidence: `src/votes/votes.service.ts`)
- Vote Operations → User Model: checks user (evidence: `src/votes/votes.service.ts`)
- Vote Operations → Poll Model: checks poll (evidence: `src/votes/votes.service.ts`)
- Vote Operations → Option Model: checks option (evidence: `src/votes/votes.service.ts`)
- User Operations → User Model: persists and queries (evidence: `src/users/users.service.ts`)
- Poll Operations → MySQL: stores poll data (evidence: `README.md`)
- Option Operations → MySQL: stores option data (evidence: `README.md`)
- Vote Operations → MySQL: stores vote data (evidence: `README.md`)
- User Operations → MySQL: stores user data (evidence: `README.md`)
