# Login flow notes

How the app and the API exchange messages when a user signs in with an email address and password. Click a diagram to edit its definition.

## Input and output

| Item | Details | Notes |
| --- | --- | --- |
| Input | Email address, password | Not sent if a field is empty |
| On success | Save the session and open Home | Expires after 30 days |
| On failure | Show an error and return to the form | Wait 15 minutes after 5 failures |

## Flow (PlantUML)

```plantuml
@startuml
actor User
participant App
participant API
User -> App : Enter email and password
App -> API : Request authentication
alt Authentication succeeds
  API --> App : Session
  App --> User : Show Home
else Authentication fails
  API --> App : Error
  App --> User : Show error
end
@enduml
```

## Screens (Mermaid)

```mermaid
flowchart LR
  A[Sign-in screen] -->|Success| B[Home]
  A -->|Failure| C[Error]
  C --> A
```

## Data (PlantUML)

```plantuml
@startuml
left to right direction
class User {
  email
  displayName
}
class Session {
  token
  expiresAt
}
User "1" -- "0..*" Session
@enduml
```
