# akshay0611/blogvista architecture

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

- Interactive diagram: https://gitdiagram.com/akshay0611/blogvista
- Repository: https://github.com/akshay0611/blogvista

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js App Router (indicated by the /app directory structure)
- UI Components (in /components directory)
- Client-side Theme Management
- Static Pages (about, contact, privacy, terms)
- Dynamic Blog Posts

b) Backend Layer:
- API Routes (in /pages/api)
- Database Connection Layer (in /lib/dbConnect.js)
- Data Models (in /models)

c) Database:
- MongoDB (as mentioned in README)

**┌─────────────────────────────────────────┐**
- Client                   │
- ┌─────────────┐ ┌────────────────────┐ │
- Static     │ │  Dynamic Pages     │ │
- Pages      │ │  (Blog Posts)      │ │
- ┘ └────────────────────┘ │
- ┌─────────────────────────────────────┐ │
- UI Components Layer          │ │
- (Header, Footer, FeaturedPosts)    │ │
- ┘ │
- ┬─────────────────────┘

**┌───────────────────▼─────────────────────┐**
- Next.js API Routes           │
- (/pages/api/blogs/*)            │
- ┬─────────────────────┘

**┌───────────────────▼─────────────────────┐**
- Database Connection Layer       │
- (lib/dbConnect.js)           │
- ┬─────────────────────┘

**┌───────────────────▼─────────────────────┐**
- MongoDB                    │
- (Blog Data Store)            │
- ┘

##### Component Relationships

Key interactions:
- Client-to-API communication for blog posts
- API-to-Database flow through dbConnect
- Theme provider's global state management
- Dynamic routing for blog posts ([id] pages)

##### Technical Details

Annotations for:
- TypeScript implementation
- MongoDB connection configuration
- API route handlers
- Component composition
- Theme switching mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        direction TB
        StaticPages["Static Pages"]
        DynamicPages["Dynamic Blog Posts"]
        UIComponents["UI Components Layer"]
        ThemeProvider["Theme Provider"]
        
        StaticPages --> UIComponents
        DynamicPages --> UIComponents
        ThemeProvider --> UIComponents
    end

    subgraph APILayer
        direction TB
        APIRoutes["API Routes"]
        DBConnect["Database Connection"]
    end

    subgraph Database
        direction TB
        MongoDB[(MongoDB)]
        DataModels["Data Models"]
        MongoDB --> DataModels
    end

    Client --> APIRoutes
    APIRoutes --> DBConnect
    DBConnect --> MongoDB

    %% Component Mappings
    click StaticPages "https://github.com/akshay0611/BlogVista/blob/main/app/about/page.tsx"
    click DynamicPages "https://github.com/akshay0611/BlogVista/blob/main/app/posts/[id]/page.tsx"
    click UIComponents "https://github.com/akshay0611/BlogVista/tree/main/components"
    click ThemeProvider "https://github.com/akshay0611/BlogVista/blob/main/components/theme-provider.tsx"
    click APIRoutes "https://github.com/akshay0611/BlogVista/tree/main/pages/api/blogs"
    click DBConnect "https://github.com/akshay0611/BlogVista/blob/main/lib/dbConnect.js"
    click DataModels "https://github.com/akshay0611/BlogVista/blob/main/models/Blog.js"

    %% Styling
    classDef client fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px
    classDef database fill:#FFE5B4,stroke:#333,stroke-width:2px

    class StaticPages,DynamicPages,UIComponents,ThemeProvider client
    class APIRoutes,DBConnect api
    class MongoDB,DataModels database

    %% Legend
    subgraph Legend
        direction TB
        ClientComp["Client Component"]:::client
        APIComp["API Component"]:::api
        DBComp["Database Component"]:::database
    end
```
