# DEB-317: Implement Backend Authentication APIs (Google OAuth & Username/Password)

> **Jira:** [DEB-317](https://divami.atlassian.net/browse/DEB-317)  
> **Source Report:** [20260315.md](../../reports/jira/20260315.md)

- **Status:** Start
- **Assignee:** Manisha Gundapuneedi
- **Priority:** Medium
- **Created:** 2026-03-13T15:19:43.216+0530
- **Updated:** 2026-03-13T16:19:46.150+0530

**Description:**

Develop Backend APIs for Google OAuth and Username/Password Authentication

**Architecture Diagram:**

```mermaid
sequenceDiagram
    participant UI as Login UI
    participant API as Backend Auth API
    participant Google as Google OAuth
    participant DB as User DB
    participant JWT as JWT Service

    alt Google OAuth Flow
        UI->>Google: Redirect to Google consent screen
        Google-->>UI: Authorization code
        UI->>API: POST /auth/google (code)
        API->>Google: Exchange code for tokens
        Google-->>API: id_token + access_token
        API->>DB: Upsert user record
        API->>JWT: Issue session JWT
        JWT-->>API: Signed token
        API-->>UI: JWT + user info
    else Username / Password Flow
        UI->>API: POST /auth/login (email, password)
        API->>DB: Lookup user, verify bcrypt hash
        DB-->>API: User record
        API->>JWT: Issue session JWT
        JWT-->>API: Signed token
        API-->>UI: JWT + user info
    end
```
