# arghajit-saha/blogdown architecture

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

- Interactive diagram: https://gitdiagram.com/arghajit-saha/blogdown
- Repository: https://github.com/arghajit-saha/blogdown

## Overview

##### Project type and purpose
- This is a full-stack, monolithic web application built with Django (an MVT framework) that provides a Markdown-powered blogging platform plus a contact form.

##### File structure
- Top-level components:
- blogdown/ (project settings: ASGI, WSGI, settings.py, urls.py)
- blog/ (core “app” holding models, views, URLs, migrations, tests)
- static/ (CSS, fonts, JS assets such as marked.js for Markdown parsing and live preview)
- templates/ (HTML templates for pages: base, content, create, contact, about, etc.)
- db.sqlite3 & manage.py & requirements.txt

##### Key architecture details from README
- Uses Django ORM and views to handle requests
- Stores posts in Markdown format, converts at render time via JavaScript (live preview) and server-side rendering into HTML
- Contact form posts data back to the server, persists in the database, possibly sends email or stores submissions

##### Main components
a. Client / Browser
- UI layer (HTML templates, CSS, JS—including marked.js)
- Sends HTTP GET/POST to server
- Live Markdown preview via JS (client-side)
b. Web Server (Django app)
- URL Router (blogdown/urls.py + blog/urls.py)
- Views (blog/views.py):
- And detail views for posts
- Create/edit view (accepts Markdown, saves model)
- Contact view (form handling)
- Templates (server-side rendering)
- Models (blog/models.py): `Post`, `ContactMessage`
- Migrations & ORM layer (persistence logic)
c. Database (SQLite)
- blog_post table, contact_message table
d. External / Third-party libraries
- marked.js (client-side Markdown→HTML)
- Django, Python standard libs

##### Relationships and interactions
1. User opens browser → HTTP GET “/” → Django URL Router → Index View → ORM fetch posts → Templates render HTML → Response
2. User clicks “Create” → GET “/create/” → Django returns form template
3. User writes Markdown → JS marked.js shows live preview in browser
4. User submits form (POST “/create/”) → Django View parses form → ORM saves `Post` (Markdown + metadata) → Redirect/list view
5. User visits a post → GET “/post/<slug>/” → View retrieves Markdown content → Server side can render to HTML (or pass raw Markdown to template which runs marked.js) → Response
6. Contact form flow: GET contact page → user submits → POST → View validates → ORM saves `ContactMessage` → Optionally send email → Response

##### Architectural patterns & principles
- Django MVT (Model–View–Template) separation
- Single-process, monolithic architecture
- Client-side vs server-side rendering (hybrid approach)
- REST-style URL design for CRUD operations
- ORM for DB abstraction

##### Essential elements
- Component labels (e.g., “Django URL Router”, “Post Model”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client / Browser"
        direction TB
        Templates["HTML Templates"]:::static
        CSS["CSS (style.css)"]:::static
        Fonts["Fonts"]:::static
        JS["marked.js (Markdown Preview)"]:::static
        Browser["User Browser"]:::frontend
    end

    %% Django Application Layer
    subgraph "Django App" 
        direction TB
        subgraph "Project Configuration"
            Settings["settings.py"]:::backend
            ASGI["asgi.py"]:::infra
            WSGI["wsgi.py"]:::infra
            Manage["manage.py"]:::infra
        end
        subgraph "URL Routing"
            RouterProject["blogdown/urls.py"]:::backend
            RouterApp["blog/urls.py"]:::backend
        end
        Views["blog/views.py\n(Views)"]:::backend
        Models["blog/models.py\n(ORM Models)"]:::backend
        Migrations["blog/migrations/"]:::backend
    end

    %% Database Layer
    DB[(SQLite Database)]:::db

    %% Interactions
    Browser -->|"HTTP GET /"| RouterProject
    RouterProject --> RouterApp
    RouterApp --> Views
    Views -->|"ORM Query"| Models
    Models --> DB
    DB --> Models
    Views --> Templates
    Templates --> Browser
    Browser -->|"Includes CSS/Fonts/JS"| CSS
    Browser --> Fonts
    Browser --> JS
    Browser -->|"Live Markdown Preview"| JS
    Browser -->|"POST /create or /contact"| RouterProject
    RouterProject --> RouterApp
    RouterApp --> Views
    Views --> Models
    Views --> Templates
    Views --> Browser

    %% Click Events
    click Templates "https://github.com/arghajit-saha/blogdown/tree/main/templates/"
    click CSS "https://github.com/arghajit-saha/blogdown/blob/main/static/css/style.css"
    click Fonts "https://github.com/arghajit-saha/blogdown/tree/main/static/fonts/"
    click JS "https://github.com/arghajit-saha/blogdown/tree/main/static/js/"
    click RouterProject "https://github.com/arghajit-saha/blogdown/blob/main/blogdown/urls.py"
    click RouterApp "https://github.com/arghajit-saha/blogdown/blob/main/blog/urls.py"
    click Views "https://github.com/arghajit-saha/blogdown/blob/main/blog/views.py"
    click Models "https://github.com/arghajit-saha/blogdown/blob/main/blog/models.py"
    click Migrations "https://github.com/arghajit-saha/blogdown/tree/main/blog/migrations/"
    click Settings "https://github.com/arghajit-saha/blogdown/blob/main/blogdown/settings.py"
    click ASGI "https://github.com/arghajit-saha/blogdown/blob/main/blogdown/asgi.py"
    click WSGI "https://github.com/arghajit-saha/blogdown/blob/main/blogdown/wsgi.py"
    click Manage "https://github.com/arghajit-saha/blogdown/blob/main/manage.py"
    click DB "https://github.com/arghajit-saha/blogdown/blob/main/db.sqlite3"
    click Req "https://github.com/arghajit-saha/blogdown/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#D6EFFF,stroke:#1E90FF,color:#000
    classDef backend fill:#C4F0D6,stroke:#228B22,color:#000
    classDef db fill:#F5D0A9,stroke:#CD5C5C,color:#000
    classDef static fill:#F0F0F0,stroke:#696969,color:#000
    classDef infra fill:#E0E0E0,stroke:#A9A9A9,color:#000
```
