Sequence diagram

SMS one-time code login sequence diagram template

An SMS one-time code login sequence diagram: rate limit, store the code, send, verify and issue a token, with a branch for a wrong or expired code. Adapt it to your design, then export PNG, SVG, Word or PowerPoint free.

SMS gatewayCacheAuth serviceAppSMS gatewayCacheAuth serviceAppalt[Code is correct][Code is wrong or expired]UserEnter phone number and request codeRequest one-time codeCheck send rateWithin limitStore code for 5 minutesSend SMSCode arrivesCode sentEnter code and sign inSubmit phone number and codeRead and compare codeDelete codeReturn session tokenOpen home screenReturn error and count the attemptAsk to try againUser
Previewed in the “Light” theme; you can switch themes in the editor

When to use it

Use it to design a login module, document the API, or produce the login sequence diagram for a course or capstone project. It includes three details that are easy to miss and that reviewers ask about: checking the send rate first, giving the code an expiry, and deleting it as soon as it is used.

Make it yours

  • If the first sign-in creates an account, add "Create account if none exists" in the correct-code branch.
  • With a CAPTCHA step, insert its messages before the code request.
  • Set the expiry and rate limits from your own security policy.

Mermaid code

sms-login-sequence.mmd
sequenceDiagram
    actor U as User
    participant C as App
    participant A as Auth service
    participant R as Cache
    participant S as SMS gateway
    U->>C: Enter phone number and request code
    C->>A: Request one-time code
    A->>R: Check send rate
    R-->>A: Within limit
    A->>R: Store code for 5 minutes
    A->>S: Send SMS
    S-->>U: Code arrives
    A-->>C: Code sent
    U->>C: Enter code and sign in
    C->>A: Submit phone number and code
    A->>R: Read and compare code
    alt Code is correct
        A->>R: Delete code
        A-->>C: Return session token
        C-->>U: Open home screen
    else Code is wrong or expired
        A-->>C: Return error and count the attempt
        C-->>U: Ask to try again
    end

Ask an AI for one with this structure

Send the prompt below to ChatGPT or Claude, then paste the whole reply into the editor; the code inside is detected automatically.

prompt.txt
Draw an SMS one-time code login sequence diagram with Mermaid sequenceDiagram syntax. Participants are User, App, Auth service, Cache and SMS gateway. First the code request: the auth service checks the send rate, stores the code with an expiry and calls the SMS gateway. Then sign-in: the app submits the phone number and code, and the auth service reads and compares. Use alt for two cases: a correct code is deleted and a session token is returned; a wrong or expired code returns an error and counts the attempt. Output only the mermaid code block.

FAQ

What do alt and else mean?

alt starts alternative cases, else begins the next case and end closes the block. It is drawn as a labeled frame with one compartment per case.

Should the database be on the diagram?

Add a "User store" participant if looking up or creating the user matters. More participants make the diagram wider, so include only what a reviewer needs.

How long should the code be and how long should it last?

That is a security policy decision based on your risk and applicable guidance. The 5 minutes here is only an example.

More in this category

All templates

Updated 2026-11-11