# akhil0033/otp-service architecture

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

- Interactive diagram: https://gitdiagram.com/akhil0033/otp-service
- Repository: https://github.com/akhil0033/otp-service

## Overview

This Spring Boot application provides phone-based OTP generation and verification. An HTTP client requests generation or verification through the authentication controller; the controller delegates to the OTP service, which normalizes the phone number and handles OTP creation, persistence, expiry checks, and verification. Generation also sends the code through Twilio. The OTP repository uses JPA for persistence. The User entity appears separate from this flow. Edges reflect the supplied source excerpts and source index; the database is represented as the persistence target of the JPA repository.

Main entry points: [`src/main/java/com/practice/DemoService.java`](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/DemoService.java) (OTP Service), [`src/main/java/com/practice/OtpRepository.java`](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpRepository.java) (OTP Repository), [`src/main/java/com/practice/DemoController.java`](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/DemoController.java) (Authentication Controller), [`src/main/java/com/practice/OtpService.java`](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpService.java) (OTP Service Contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_controller["Authentication Controller"]
  node_application["Spring Boot Application"]
end

subgraph group_otp["OTP Workflow"]
  node_otp_service["OTP Service<br/>[DemoService.java]"]
  node_otp_interface["OTP Service Contract<br/>[OtpService.java]"]
  node_twilio["Twilio SMS"]
end

subgraph group_persistence["Persistence"]
  node_repository["OTP Repository<br/>[OtpRepository.java]"]
  node_otp_entity["OTP Record<br/>[OtpEntity.java]"]
  node_database[("Database")]
  node_user_entity["User Entity<br/>[User.java]"]
end

node_client(("HTTP Client"))

node_client -->|"requests OTP"| node_controller
node_controller -->|"delegates"| node_otp_service
node_otp_service -->|"reads and writes"| node_repository
node_otp_service -->|"sends SMS"| node_twilio
node_repository -->|"persists records"| node_database
node_repository -->|"uses entity"| node_otp_entity
node_otp_service -->|"implements"| node_otp_interface

click node_controller "https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/DemoController.java"
click node_application "https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/PracticeApplication.java"
click node_otp_service "https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/DemoService.java"
click node_otp_interface "https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpService.java"
click node_repository "https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpRepository.java"
click node_otp_entity "https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpEntity.java"
click node_user_entity "https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/User.java"

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_controller,node_application,node_client toneBlue
class node_otp_service,node_otp_interface,node_twilio toneAmber
class node_repository,node_otp_entity,node_database,node_user_entity toneMint
```

## Components

### HTTP API

- [Authentication Controller](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/DemoController.java): `src/main/java/com/practice/DemoController.java`
- [Spring Boot Application](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/PracticeApplication.java): `src/main/java/com/practice/PracticeApplication.java`

### OTP Workflow

- [OTP Service](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/DemoService.java): `src/main/java/com/practice/DemoService.java`
- [OTP Service Contract](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpService.java): `src/main/java/com/practice/OtpService.java`
- **Twilio SMS**

### Persistence

- [OTP Repository](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpRepository.java): `src/main/java/com/practice/OtpRepository.java`
- [OTP Record](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/OtpEntity.java): `src/main/java/com/practice/OtpEntity.java`
- **Database**
- [User Entity](https://github.com/akhil0033/otp-service/blob/main/src/main/java/com/practice/User.java): `src/main/java/com/practice/User.java`

### Other components

- **HTTP Client**

## Connections

- HTTP Client → Authentication Controller: requests OTP (evidence: `src/main/java/com/practice/DemoController.java`)
- Authentication Controller → OTP Service: delegates (evidence: `src/main/java/com/practice/DemoController.java`)
- OTP Service → OTP Repository: reads and writes (evidence: `src/main/java/com/practice/DemoService.java`)
- OTP Service → Twilio SMS: sends SMS (evidence: `src/main/java/com/practice/DemoService.java`)
- OTP Repository → Database: persists records (evidence: `src/main/java/com/practice/OtpRepository.java`)
- OTP Repository → OTP Record: uses entity (evidence: `src/main/java/com/practice/OtpRepository.java`)
- OTP Service → OTP Service Contract: implements (evidence: `src/main/java/com/practice/DemoService.java`)
