# botirbakhtiyarov/ai-research-analyzer architecture

> Architecture diagram of the GitHub repository botirbakhtiyarov/ai-research-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/botirbakhtiyarov/ai-research-analyzer
- Repository: https://github.com/botirbakhtiyarov/ai-research-analyzer

## Overview

##### Project type and purpose
- This is a full-stack Django web application (“Research Analyzer”) for uploading, analyzing, AI-detecting, and summarizing PDF research papers.
- Key features (from README): user authentication, PDF upload, RoBERTa-based AI content detection, DeepSeek API summarization/translation, dashboard management.

##### File structure
- Top level:
- manage.py (Django entry point)
- research_analyzer/ (project settings: asgi.py, wsgi.py, settings.py, urls.py)
- core/ (Django app: models.py, views.py, urls.py, admin.py, tests.py, migrations/)
- templates/core/ (HTML templates for login, register, dashboard, upload, summary)
- media/ (uploaded PDFs)
- models/ (instruction.txt – project notes)
- requirements.txt
- Patterns: standard Django MVC:
- Models ↔ database (SQLite by default)
- Views (controllers) handle HTTP → call services (PDF extraction, AI model, external API) → render Templates
- Config/build: settings.py, .env for API key, requirements.txt, migrations/ manage DB schema.

##### README for additional insights
- Tech stack: Python 3.8+, Django 5.1.7, pdfplumber, transformers, openai, python-dotenv.
- AI model: `roberta-base-openai-detector` (local or auto-download).
- External service: DeepSeek API (HTTP, streaming responses).
- Workflow described: upload PDF → AI detection → metadata extraction → streamed summary → optional translation.

1. Client (Web Browser)
2. Reverse Proxy / Web Server (optional: Nginx/Gunicorn or Django dev server)
3. Django Application
- URL Router
- Core App
– Authentication Module
– Upload/Storage Module (media directory)
– AI Detection Service (local RoBERTa model)
– PDF Extraction (pdfplumber)
– Summarization Service (DeepSeek API client)
– Translation Service (DeepSeek API client)
- Templates (HTML)
- Static Files (CSS/JS if any)
4. Database (SQLite / configured RDBMS)
5. File Storage (media folder on disk or cloud)
6. External Services
- Hugging Face Model Hub (if auto-download)
- DeepSeek API
- Browser → HTTP → Django URL Router
- Router → View Functions in Core App
- Views → Authentication Module (login/register) ↔ Database
- Views → Upload Module → save PDF to media folder → Database (metadata record)
- Views → PDF Extraction (pdfplumber)
- Views → AI Detection Service (local RoBERTa)
- Views → Summarization Service (DeepSeek API call over HTTPS → streaming JSON) → back to View
- Views → render summary template → return to Browser
- Views → Translation Service (DeepSeek API) in–page call
c. Architectural patterns & principles:
- MVC (Model-View-Template)
- Single codebase monolith (one Django project with one core app)
- Service abstraction: AI detection and summarization broken out into service functions
- Streaming responses for real-time summary rendering
- Environment-based configuration (.env) for secrets
d. Key technologies/frameworks:
- Django 5.1.7 (URL routing, ORM, templates)
- pdfplumber (PDF text extraction)
- transformers (Hugging Face for local AI model)
- openai / DeepSeek API client (HTTP streaming)
- python-dotenv (environment variables)
- SQLite (default) or PostgreSQL (optional)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        Browser["Web Browser"]:::frontend
    end

    %% Web Server Layer
    subgraph "Web Server" 
        direction TB
        WebServer["Nginx / Gunicorn"]:::app
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB

        subgraph "Django Project"
            direction TB
            Manage["manage.py"]:::app
            Settings["Project Settings"]:::app
            ProjectURLs["URL Router (Project)"]:::app
            ASGI["ASGI Entry Point"]:::app
            WSGI["WSGI Entry Point"]:::app
        end

        subgraph "Core App" 
            direction TB
            CoreDir["Core App Module"]:::app
            CoreURLs["Core App URLs"]:::app
            Views["Authentication & View Logic"]:::app
            Models["Data Models (ORM)"]:::app
            Admin["Admin Registration"]:::app
            Tests["Core App Tests"]:::app
            Migrations["Database Migrations"]:::app
            AuthModule["Authentication Module"]:::app
            UploadModule["Upload/Storage Module"]:::app
            PDFExtraction["PDF Extraction Service"]:::app
            AIDetect["AI Detection Service (RoBERTa)"]:::app
            Summarize["Summarization Service"]:::app
            Translate["Translation Service"]:::app
            Templates["HTML Templates"]:::frontend
            Static["Static Files"]:::frontend
        end

        Database["Database (SQLite/PostgreSQL)"]:::database
        Storage["File Storage (media/)"]:::storage
        HFDl["Hugging Face Model Hub"]:::external
        DeepSeek["DeepSeek API"]:::external
    end

    %% Connections
    Browser -->|"HTTP/HTTPS"| WebServer
    WebServer -->|"WSGI/ASGI"| ASGI
    ASGI --> ProjectURLs
    WSGI --> ProjectURLs
    ProjectURLs --> CoreURLs
    CoreURLs --> Views

    Views -->|"authenticate"| AuthModule
    AuthModule -->|"ORM"| Models
    Models -->|"SQL"| Database

    Views -->|"upload PDF"| UploadModule
    UploadModule -->|"save file"| Storage
    UploadModule -->|"record metadata"| Models

    Views -->|"extract text"| PDFExtraction
    PDFExtraction --> Storage

    Views -->|"detect AI content"| AIDetect
    AIDetect --> HFDl

    Views -->|"stream summary"| Summarize
    Summarize -->|HTTPS| DeepSeek

    Views -->|"translate summary"| Translate
    Translate -->|HTTPS| DeepSeek

    Views -->|"render"| Templates
    Templates --> Browser
    Static --> Browser

    %% Click Events
    click Settings "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/research_analyzer/settings.py"
    click ProjectURLs "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/research_analyzer/urls.py"
    click ASGI "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/research_analyzer/asgi.py"
    click WSGI "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/research_analyzer/wsgi.py"
    click Manage "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/manage.py"
    click CoreDir "https://github.com/botirbakhtiyarov/ai-research-analyzer/tree/main/core/"
    click CoreURLs "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/core/urls.py"
    click Views "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/core/views.py"
    click Models "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/core/models.py"
    click Admin "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/core/admin.py"
    click Tests "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/core/tests.py"
    click Migrations "https://github.com/botirbakhtiyarov/ai-research-analyzer/tree/main/core/migrations/"
    click Templates "https://github.com/botirbakhtiyarov/ai-research-analyzer/tree/main/templates/core/"
    click Storage "https://github.com/botirbakhtiyarov/ai-research-analyzer/tree/main/media/"
    click Static "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/requirements.txt"
    click HFDl "https://github.com/botirbakhtiyarov/ai-research-analyzer/blob/main/models/instruction.txt"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef app fill:#DFFFE0,stroke:#28A745,color:#155724
    classDef database fill:#FFF5E5,stroke:#FF8C00,color:#663C00
    classDef storage fill:#F0F0F0,stroke:#6A737D,color:#24292E
    classDef external fill:#E8E8E8,stroke:#586069,color:#24292E
```
