# deepak20001/blog-app-microservice architecture

> Architecture diagram of the GitHub repository deepak20001/blog-app-microservice, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deepak20001/blog-app-microservice
- Repository: https://github.com/deepak20001/blog-app-microservice

## Overview

##### Project Type & Purpose
- This is a full-stack, cross-platform mobile blog application following a microservice architecture.
- The Flutter “blog_client” handles UI, state management (BLoC), navigation, HTTP (Dio) and local storage.
- Three backend microservices handle domain logic:
- User Service (Node.js/TypeScript, MongoDB, Mongoose, JWT, Redis, RabbitMQ)
- Blog Service (Node.js/TypeScript, PostgreSQL, Redis, RabbitMQ, Google GenAI)
- Media Service (Go/Fiber, Cloudinary, JWT)

##### File Structure & Architectural Patterns
- blog_client/ – Flutter UI organized by core (services, theming, routing) and features (auth, blogs, profile, search, etc.) using the BLoC pattern.
- services/user/ – Express controllers, routes, middleware, models, utils, workers.
- services/blog/ – Same structure but uses PostgreSQL and AI endpoints.
- services/media/ – Go app with handlers and config; exposes HTTP endpoints for file uploads.
- Shared infra: each service uses environment variables, Redis for caching, RabbitMQ for event/async jobs.

##### Key Insights from README
- There is no API gateway; the Flutter client calls each service directly.
- Common external systems:
- MongoDB for user data
- PostgreSQL for blogs
- Redis for caching
- RabbitMQ for messaging between services (e.g., cache invalidation)
- Cloudinary for media storage
- Auth via JWT, passed in HTTP headers to backend.

##### Final Checklist
- External integration: Media Service → Cloudinary.
- JWT token flow from client to services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Flutter Client"
        direction TB
        Client["Flutter Client"]:::frontend
        subgraph "Core Modules"
            direction TB
            Core["Core (network, local db, routing, theming)"]:::frontend
        end
        subgraph "Features (BLoC)"
            direction TB
            Features["Features (auth, blogs, profile, search)"]:::frontend
        end
        Injection["Dependency Injection Container"]:::frontend
    end

    %% Services Layer
    subgraph "User Service"
        direction TB
        UserSvc["User Service (Node.js/Express)"]:::service
        subgraph "Controllers / Routes / Middleware"
            direction TB
            Controllers["Controllers"]:::service
            Routes["Routes"]:::service
            Middleware["Middleware"]:::service
        end
        subgraph "Models / Utils / Workers"
            direction TB
            Models["Mongoose Models"]:::service
            DBUtil["DB Utils"]:::service
            CacheUtil["Cache Utils"]:::service
            RabbitUtil["RabbitMQ Utils"]:::service
            JWTUtil["JWT Utils"]:::service
            Workers["Background Workers"]:::service
        end
    end

    subgraph "Blog Service"
        direction TB
        BlogSvc["Blog Service (Node.js/Express)"]:::service
        subgraph "Controllers / Routes / Middleware"
            direction TB
            BlogControllers["Controllers"]:::service
            BlogRoutes["Routes"]:::service
            BlogMiddleware["Middleware"]:::service
        end
        subgraph "Models / Utils / Workers"
            direction TB
            BlogDBUtil["DB Utils"]:::service
            BlogCacheUtil["Cache Utils"]:::service
            BlogRabbitUtil["RabbitMQ Utils"]:::service
            BlogJWTUtil["JWT Utils"]:::service
            BlogWorkers["Background Workers"]:::service
        end
    end

    subgraph "Media Service"
        direction TB
        MediaSvc["Media Service (Go/Fiber)"]:::service
        Main["Main Entry Point"]:::service
        Handlers["HTTP Handlers"]:::service
        AppConfig["Cloudinary & App Config"]:::service
        Helper["Helper Utilities"]:::service
    end

    %% Infrastructure
    MongoDB["MongoDB"]:::datastore
    Postgres["PostgreSQL"]:::datastore
    Redis["Redis Cache"]:::datastore
    RabbitMQ["RabbitMQ Broker"]:::message
    Cloudinary["Cloudinary Storage"]:::external

    %% Client to Services HTTP & JWT
    Client -->|HTTP POST/Login/Register| UserSvc
    Client -->|HTTP| BlogSvc
    Client -->|HTTP Upload| MediaSvc
    Client -->|JWT in Header| UserSvc
    Client -->|JWT in Header| BlogSvc
    Client -->|JWT in Header| MediaSvc

    %% Service to Datastores
    UserSvc -->|CRUD| MongoDB
    BlogSvc -->|CRUD| Postgres
    MediaSvc -->|Store File| Cloudinary

    %% Cache Layer
    UserSvc <-->|Cache Aside| Redis
    BlogSvc <-->|Cache Aside| Redis

    %% Messaging Layer
    UserSvc -->|Publish Event| RabbitMQ
    BlogSvc -->|Publish Event| RabbitMQ
    RabbitMQ -->|Consume| Workers
    RabbitMQ -->|Consume| BlogWorkers

    %% Click Events
    click Client "https://github.com/deepak20001/blog-app-microservice/tree/main/blog_client/"
    click Core "https://github.com/deepak20001/blog-app-microservice/tree/main/blog_client/lib/core/"
    click Features "https://github.com/deepak20001/blog-app-microservice/tree/main/blog_client/lib/features/"
    click Injection "https://github.com/deepak20001/blog-app-microservice/blob/main/blog_client/lib/injection_container.dart"
    click UserSvc "https://github.com/deepak20001/blog-app-microservice/tree/main/services/user/"
    click Controllers "https://github.com/deepak20001/blog-app-microservice/tree/main/services/user/src/controllers/"
    click Routes "https://github.com/deepak20001/blog-app-microservice/tree/main/services/user/src/routes/"
    click Middleware "https://github.com/deepak20001/blog-app-microservice/tree/main/services/user/src/middleware/"
    click Models "https://github.com/deepak20001/blog-app-microservice/tree/main/services/user/src/model/"
    click DBUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/user/src/utils/db.ts"
    click CacheUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/user/src/utils/cache.ts"
    click RabbitUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/user/src/utils/rabbitmq.ts"
    click JWTUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/user/src/utils/get_token.ts"
    click Workers "https://github.com/deepak20001/blog-app-microservice/tree/main/services/user/src/workers/"
    click BlogSvc "https://github.com/deepak20001/blog-app-microservice/tree/main/services/blog/"
    click BlogControllers "https://github.com/deepak20001/blog-app-microservice/tree/main/services/blog/src/controllers/"
    click BlogRoutes "https://github.com/deepak20001/blog-app-microservice/tree/main/services/blog/src/routes/"
    click BlogMiddleware "https://github.com/deepak20001/blog-app-microservice/tree/main/services/blog/src/middleware/"
    click BlogDBUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/blog/src/utils/db.ts"
    click BlogCacheUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/blog/src/utils/cache.ts"
    click BlogRabbitUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/blog/src/utils/rabbitmq.ts"
    click BlogJWTUtil "https://github.com/deepak20001/blog-app-microservice/blob/main/services/blog/src/utils/get_token.ts"
    click BlogWorkers "https://github.com/deepak20001/blog-app-microservice/tree/main/services/blog/src/workers/"
    click MediaSvc "https://github.com/deepak20001/blog-app-microservice/tree/main/services/media/"
    click Main "https://github.com/deepak20001/blog-app-microservice/blob/main/services/media/main.go"
    click Handlers "https://github.com/deepak20001/blog-app-microservice/blob/main/services/media/internal/handlers.go"
    click AppConfig "https://github.com/deepak20001/blog-app-microservice/blob/main/services/media/config/appConfig.go"
    click Helper "https://github.com/deepak20001/blog-app-microservice/blob/main/services/media/internal/helper.go"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef service fill:#DFFFD6,stroke:#22863a,color:#22863a;
    classDef datastore fill:#FFE4B3,stroke:#bf8700,color:#bf8700;
    classDef message fill:#ECD6FF,stroke:#6f42c1,color:#6f42c1;
    classDef external fill:#F0F0F0,stroke:#666,color:#666;
```
