# rohitprasain99/djangodrfinterview architecture

> Architecture diagram of the GitHub repository rohitprasain99/djangodrfinterview, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohitprasain99/djangodrfinterview
- Repository: https://github.com/rohitprasain99/djangodrfinterview

## Overview

##### Project type and purpose
- This is a monolithic Django REST Framework (DRF) backend service whose sole purpose is user management and authentication.
- Key features: user registration, login/logout with JWT, token refresh, OTP-based password reset, password change, and CRUD operations on a user profile.

##### File structure
- Top-level files:
- manage.py – Django CLI entry point
- djangoDrfInterview/ – core settings, URL routing, ASGI/WSGI
- api/ – central “include” URL conf for all API endpoints
- authentication/, users/, otp/, user_details/ – four Django apps, each with models.py, serializers.py, views.py, tests.py, migrations
- utils/otp.py – standalone OTP generator/email helper
- db.sqlite3 – local database (swap for Postgres/MySQL in prod)
- requirements.txt, .env.local – dependency list and environment variables
- Architectural hints: apps are highly cohesive, each encapsulates one domain (authentication flow, profile data, etc.). DRF’s MVT (Model-View-Template) pattern is in use (though templates aren’t needed for an API).

##### Extract insights from README
- All API endpoints live under /api/…
- Uses JWT for stateless auth, with refresh and blacklist logic
- OTPs are emailed for password reset and live for 5 minutes
- Profiles are first-class resources (CRUD)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    C[Client<br/>Postman/Browser/Mobile]:::external

    %% Django Server
    subgraph "Django Server"
        %% API Layer
        subgraph "API Layer"
            RouterAPI["URL Router<br/>(api/urls.py)"]:::api
            RouterCore["Core Router<br/>(djangoDrfInterview/urls.py)"]:::api
            Settings["Settings<br/>(settings.py)"]:::api
        end

        %% Apps
        subgraph "Authentication App"
            AuthViews["Views<br/>(authentication/views.py)"]:::view
            AuthSerializers["Serializers<br/>(authentication/serializers.py)"]:::business
            AuthModels["Models<br/>(authentication/models.py)"]:::data
        end

        subgraph "OTP App"
            OTPViews["Views<br/>(otp/views.py)"]:::view
            OTPSerializers["Serializers<br/>(otp/serializers.py)"]:::business
            OTPModels["Models<br/>(otp/models.py)"]:::data
        end

        subgraph "Users App"
            UserViews["Views<br/>(users/views.py)"]:::view
            UserSerializers["Serializers<br/>(users/serializers.py)"]:::business
            UserModels["Models<br/>(users/models.py)"]:::data
        end

        subgraph "User Details App"
            UDViews["Views<br/>(user_details/views.py)"]:::view
            UDSerializers["Serializers<br/>(user_details/serializers.py)"]:::business
            UDModels["Models<br/>(user_details/models.py)"]:::data
        end

        %% Business Logic
        BusinessLogic["OTP Utility<br/>(utils/otp.py)"]:::business

        %% JWT Blacklist Store
        BlacklistStore["JWT Blacklist Store<br/>(DB/Redis)"]:::data
    end

    %% Data Stores & External Services
    Database["Database<br/>(db.sqlite3 / Postgres)"]:::data
    EmailService["SMTP Email Service"]:::external

    %% Request Flow
    C -->|HTTP JSON Request| RouterAPI
    RouterAPI --> RouterCore

    RouterCore --> AuthViews
    RouterCore --> OTPViews
    RouterCore --> UserViews
    RouterCore --> UDViews

    %% Auth App Flow
    AuthViews --> AuthSerializers --> AuthModels --> Database
    AuthViews -->|JWT Issue/Verify| BlacklistStore

    %% OTP Flow
    OTPViews --> OTPSerializers --> OTPModels --> Database
    OTPViews --> BusinessLogic --> EmailService

    %% Users App Flow
    UserViews --> UserSerializers --> UserModels --> Database

    %% User Details App Flow
    UDViews --> UDSerializers --> UDModels --> Database

    %% Click Events
    click RouterAPI "https://github.com/rohitprasain99/djangodrfinterview/blob/main/api/urls.py"
    click RouterCore "https://github.com/rohitprasain99/djangodrfinterview/blob/main/djangoDrfInterview/urls.py"
    click Settings "https://github.com/rohitprasain99/djangodrfinterview/blob/main/djangoDrfInterview/settings.py"
    click AuthViews "https://github.com/rohitprasain99/djangodrfinterview/blob/main/authentication/views.py"
    click AuthSerializers "https://github.com/rohitprasain99/djangodrfinterview/blob/main/authentication/serializers.py"
    click AuthModels "https://github.com/rohitprasain99/djangodrfinterview/blob/main/authentication/models.py"
    click OTPViews "https://github.com/rohitprasain99/djangodrfinterview/blob/main/otp/views.py"
    click OTPSerializers "https://github.com/rohitprasain99/djangodrfinterview/blob/main/otp/serializers.py"
    click OTPModels "https://github.com/rohitprasain99/djangodrfinterview/blob/main/otp/models.py"
    click UserViews "https://github.com/rohitprasain99/djangodrfinterview/blob/main/users/views.py"
    click UserSerializers "https://github.com/rohitprasain99/djangodrfinterview/blob/main/users/serializers.py"
    click UserModels "https://github.com/rohitprasain99/djangodrfinterview/blob/main/users/models.py"
    click UDViews "https://github.com/rohitprasain99/djangodrfinterview/blob/main/user_details/views.py"
    click UDSerializers "https://github.com/rohitprasain99/djangodrfinterview/blob/main/user_details/serializers.py"
    click UDModels "https://github.com/rohitprasain99/djangodrfinterview/blob/main/user_details/models.py"
    click BusinessLogic "https://github.com/rohitprasain99/djangodrfinterview/blob/main/utils/otp.py"
    click Database "https://github.com/rohitprasain99/djangodrfinterview/blob/main/db.sqlite3"

    %% Styles
    classDef api fill:#BBDEFB,stroke:#333,stroke-width:1px
    classDef view fill:#90CAF9,stroke:#333,stroke-width:1px
    classDef business fill:#A5D6A7,stroke:#333,stroke-width:1px
    classDef data fill:#FFF59D,stroke:#333,stroke-width:1px
    classDef external fill:#FFCC80,stroke:#333,stroke-width:1px
```
