# ujitkumar1/blogwave architecture

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

- Interactive diagram: https://gitdiagram.com/ujitkumar1/blogwave
- Repository: https://github.com/ujitkumar1/blogwave

## Overview

##### Project type and purpose
- BlogWave is a full-stack blogging platform.
- The backend is a Flask-based REST API server that handles user and post CRUD operations, background export tasks (via Celery + Redis), and persisting data in a SQLite database.
- The frontend is a Vue.js single-page application (SPA) that provides views for login, signup, dashboard, post management, user profile, and search.

##### File structure
- Top-level directories:
- backend/ – Flask app, Celery worker & beat config, static exports, Jinja2 templates, SQLite DB
- ui/ – Vue.js SPA with components, views, router, API wrapper
- database/ – holds the SQLite file for persistence
- Key files in backend/:
- app.py – Flask app + Celery initialization
- celery_system.py – Celery tasks definitions
- APIs.yaml – API spec
- requirements.txt – Python dependencies
- dump.rdb – Redis snapshot (if used)
- Key files in ui/:
- main.js, App.vue, router.js – app bootstrap and routing
- api.js – centralizes HTTP requests to Flask APIs
- components/ and views/ – UI building blocks
- package.json/package-lock.json, vue.config.js – build config
- Deployment/Dev indicators:
- Backend run commands (Flask dev server, Redis, Celery worker & beat)
- Frontend dev server (npm run serve)

##### README for additional insights
- Describes commands to run Flask, Vue.js, Redis, and Celery.
- Implies a development setup where the Vue.js dev server proxies API calls to the Flask server.

##### Components
a. User (Browser)
- Initiates HTTP(S) requests to frontend (Vue.js)
- Views rendered in browser, interacts via API calls
b. Frontend (Vue.js SPA)
- Serves static assets (or via webpack dev server)
- router.js handles view transitions
- api.js performs AJAX calls to Flask endpoints
c. Backend (Flask)
- app.py exposes RESTful endpoints (e.g., /posts, /users, /export)
- Business logic layer handles requests, validation, authentication
- Triggers Celery tasks for long-running jobs (static export of blogs)
d. Celery subsystem
- Redis acting as broker and result backend
- Celery worker processes tasks defined in celery_system.py
- Celery beat scheduler enqueues periodic jobs (e.g., cleanup or timed exports)
e. Database (SQLite)
- database/database.db holds application data (users, posts)
- Accessed via an ORM or raw SQL in Flask
f. Static artifacts store
- backend/static/exportJob – holds CSV exports of blog data
- Served by Flask’s static file handler
g. External Services (if any)
- Redis server (broker for Celery)
- Optional: Email service, if used (not shown but could be extended)

##### Relationships and Data Flows
- Browser → HTTP → Vue.js SPA
- Vue.js → AJAX → Flask API
- Flask → SQL queries → SQLite DB
- Flask → enqueue → Redis broker → Celery worker
- Celery worker → read/write → SQLite DB (if tasks update data)
- Celery worker → generate files → backend/static
- Browser → HTTP → download export files
- Celery beat → schedules tasks → enqueue in Redis

##### Architectural patterns and design principles
- Separation of concerns: UI (Vue) vs API (Flask) vs background tasks (Celery) vs storage (SQLite/Redis).
- Asynchronous processing: offload heavy or periodic jobs via Celery workers.
- SPA routing and component-based UI in Vue.js.
- RESTful API design in Flask with clear endpoints (as per APIs.yaml).

##### Summary of elements
- Clear component labels
- Brief notes on deployment (e.g., “npm run serve → Vue dev server on localhost:8080”, “python app.py → Flask on port 5000”, “redis-server”, “celery worker & beat”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["User (Browser)"]:::compute

    %% Frontend Layer
    subgraph "Frontend (Vue.js SPA)"
        direction TB
        MainJS["main.js"]:::compute
        AppVue["App.vue"]:::compute
        RouterJS["router.js"]:::compute
        APIJS["api.js"]:::compute
        Components["components/"]:::compute
        Views["views/"]:::compute
        PackageJSON["package.json"]:::compute
        VueConfig["vue.config.js"]:::compute
    end

    %% Backend Layer
    subgraph "Backend (Flask API Server)"
        direction TB
        AppPy["app.py"]:::compute
        APIsYAML["APIs.yaml"]:::compute
        Requirements["requirements.txt"]:::compute
        Templates["templates/"]:::compute
        StaticBackend["static/"]:::compute
    end

    %% Celery Subsystem
    subgraph "Celery Subsystem"
        direction TB
        CeleryTasks["celery_system.py"]:::compute
        BeatSchedule["celerybeat-schedule.db"]:::datastore
        RedisSnapshot["dump.rdb"]:::datastore
        Redis["Redis (Broker/Backend)"]:::datastore
    end

    %% Data Stores
    SQLiteDB["database.db"]:::datastore

    %% Static Artifacts
    ExportCSV["blogs.csv"]:::doc

    %% Relationships
    Browser -->|"HTTP GET/SPA Load"| MainJS
    Browser -->|"HTTP GET/SPA Load"| AppVue
    MainJS -->|"imports"| RouterJS
    MainJS -->|"imports"| APIJS
    AppVue --> Components
    RouterJS --> Views
    APIJS -->|"AJAX HTTP"| AppPy
    AppPy -->|"SQL queries"| SQLiteDB
    AppPy -->|"enqueue Celery task"| Redis
    Redis -->|"dispatch task"| CeleryTasks
    CeleryTasks -->|"SQL update/read"| SQLiteDB
    CeleryTasks -->|"generate CSV"| ExportCSV
    Browser -->|"HTTP Download"| ExportCSV

    %% Click Events Frontend
    click MainJS "https://github.com/ujitkumar1/blogwave/blob/main/ui/src/main.js"
    click AppVue "https://github.com/ujitkumar1/blogwave/blob/main/ui/src/App.vue"
    click RouterJS "https://github.com/ujitkumar1/blogwave/blob/main/ui/src/router.js"
    click APIJS "https://github.com/ujitkumar1/blogwave/blob/main/ui/src/api.js"
    click Components "https://github.com/ujitkumar1/blogwave/tree/main/ui/src/components/"
    click Views "https://github.com/ujitkumar1/blogwave/tree/main/ui/src/views/"
    click PackageJSON "https://github.com/ujitkumar1/blogwave/blob/main/ui/package.json"
    click VueConfig "https://github.com/ujitkumar1/blogwave/blob/main/ui/vue.config.js"

    %% Click Events Backend
    click AppPy "https://github.com/ujitkumar1/blogwave/blob/main/backend/app.py"
    click APIsYAML "https://github.com/ujitkumar1/blogwave/blob/main/backend/APIs.yaml"
    click Requirements "https://github.com/ujitkumar1/blogwave/blob/main/backend/requirements.txt"
    click Templates "https://github.com/ujitkumar1/blogwave/tree/main/backend/templates/"
    click StaticBackend "https://github.com/ujitkumar1/blogwave/tree/main/backend/static/"

    %% Click Events Celery
    click CeleryTasks "https://github.com/ujitkumar1/blogwave/blob/main/backend/celery_system.py"
    click BeatSchedule "https://github.com/ujitkumar1/blogwave/blob/main/backend/celerybeat-schedule.db"
    click RedisSnapshot "https://github.com/ujitkumar1/blogwave/blob/main/backend/dump.rdb"

    %% Click Events Data Stores
    click SQLiteDB "https://github.com/ujitkumar1/blogwave/blob/main/database/database.db"

    %% Click Events Static Artifacts
    click ExportCSV "https://github.com/ujitkumar1/blogwave/blob/main/backend/static/exportJob/blogs.csv"

    %% Styles
    classDef compute fill:#A3D5FF,stroke:#0366D6,color:#000;
    classDef datastore fill:#C2F5A7,stroke:#2C662D,color:#000;
    classDef doc fill:#FFD47F,stroke:#D97812,color:#000;
```
