# done-0/jank architecture

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

- Interactive diagram: https://gitdiagram.com/done-0/jank
- Repository: https://github.com/done-0/jank

## Overview

##### Project type and purpose
- This is a full-stack, modular blog system called “Jank”
- Backend: Go + Echo framework
- Frontend: React + TypeScript + Vite + TailwindCSS
- Purpose: provide a lightweight, extensible, JWT-secured blog with posts, categories, comments, accounts, plus caching, OpenAPI docs, containerized deployment.

##### File structure
- Top-level:
- Dockerfile / docker-compose.yml / nginx.conf → containerization & reverse proxy
- configs/ → runtime & hot-reload (Air) settings
- cmd/ & main.go → server bootstrap
- internal/ → core backend modules (low-level, non-exported)
- db (database connection, migrations)
- redis (cache layer)
- logger, error, global → foundational services
- middleware → CORS, JWT auth, logging, recover, CSRF, XSS, Swagger
- model → ORM entities for account, post, comment, category, associations
- utils → reusable helpers (JWT utils, markdown renderer, email, validation)
- pkg/serve/ → high-level HTTP handlers
- controller (DTOs + request handling)
- service (business logic)
- mapper (convert model→VO)
- pkg/router/ → Echo routing setup & grouping
- vo/ → view objects (response payloads)

##### README for additional insights
- Confirms layered design (router → controller → service → data layer)
- Lists external services: SMTP email, object storage (MinIO), Redis cache
- Mentions security: JWT auth, CSRF, XSS protection, CORS
- Highlights extensibility (plugin system forthcoming)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Tier
    Browser["Browser<br/>(React SPA)"]:::compute
    %% Infrastructure
    subgraph "Infrastructure" 
        direction TB
        Dockerfile["Dockerfile"]:::infra
        DockerCompose["docker-compose.yml"]:::infra
        NGINX["NGINX<br/>(reverse proxy)"]:::infra
    end

    %% Configuration
    subgraph "Configs" 
        direction TB
        AirConfig[".air.toml"]:::infra
        AppConfig["config.yml & config.go"]:::infra
    end

    %% API/Web Tier
    subgraph "Go/Echo Server" 
        direction TB
        EntryProd["cmd/jank_blog_server.go"]:::compute
        EntryDev["main.go"]:::compute

        subgraph "Router & Middleware"
            direction TB
            Router["Echo Router"]:::compute
            MiddlewareLoader["Middleware Loader"]:::compute
            JWTAuth["JWT Auth"]:::compute
            CORS["CORS"]:::compute
            CSRF["CSRF Protection"]:::compute
            XSS["XSS Protection"]:::compute
            ReqLogger["Request Logger"]:::compute
            Recover["Panic Recovery"]:::compute
            ErrorHandler["Error Handler"]:::compute
            SwaggerMW["Swagger UI"]:::compute
        end

        subgraph "Controllers"
            direction TB
            AccountCtrl["Account Controller"]:::compute
            CategoryCtrl["Category Controller"]:::compute
            CommentCtrl["Comment Controller"]:::compute
            PostCtrl["Post Controller"]:::compute
            VerificationCtrl["Verification Controller"]:::compute
        end

        subgraph "Services"
            direction TB
            AccountSvc["Account Service"]:::compute
            CategorySvc["Category Service"]:::compute
            CommentSvc["Comment Service"]:::compute
            PostSvc["Post Service"]:::compute
        end

        Mapper["Model→VO Mapper"]:::compute
    end

    %% Data & External Tier
    subgraph "Data Stores"
        direction TB
        DB["Relational DB"]:::db
        Redis["Redis Cache"]:::db
    end

    subgraph "External Services"
        direction TB
        SMTP["SMTP Provider"]:::ext
        OSS["Object Storage (MinIO)"]:::ext
    end

    %% Documentation
    SwaggerUI["Swagger JSON/YAML"]:::infra

    %% Flows
    Browser -->|HTTP/JSON| NGINX
    NGINX -->|proxy| Router
    Router -->|route| MiddlewareLoader
    MiddlewareLoader --> JWTAuth --> CORS --> CSRF --> XSS --> ReqLogger --> Recover --> ErrorHandler --> SwaggerMW
    SwaggerMW -->|serve docs| SwaggerUI
    MiddlewareLoader --> Controllers
    Controllers --> Services
    Services --> DB
    Services --> Redis
    Services --> SMTP
    Services --> OSS
    DB -->|queries| Services
    Redis -->|cache ops| Services
    Services --> Controllers
    Controllers -->|JSON| Router
    Router -->|response| NGINX
    NGINX -->|HTTP/JSON| Browser

    %% Click Events
    click Dockerfile "https://github.com/done-0/jank/tree/main/Dockerfile"
    click DockerCompose "https://github.com/done-0/jank/blob/main/docker-compose.yml"
    click NGINX "https://github.com/done-0/jank/blob/main/configs/nginx.conf"
    click AirConfig "https://github.com/done-0/jank/blob/main/configs/.air.toml"
    click AppConfig "https://github.com/done-0/jank/blob/main/configs/config.yml"
    click AppConfig "https://github.com/done-0/jank/blob/main/configs/config.go"
    click EntryProd "https://github.com/done-0/jank/blob/main/cmd/jank_blog_server.go"
    click EntryDev "https://github.com/done-0/jank/blob/main/main.go"
    click Router "https://github.com/done-0/jank/blob/main/pkg/router/router.go"
    click MiddlewareLoader "https://github.com/done-0/jank/blob/main/internal/middleware/middleware.go"
    click JWTAuth "https://github.com/done-0/jank/blob/main/internal/middleware/auth/jwt_authentication.go"
    click CORS "https://github.com/done-0/jank/blob/main/internal/middleware/cors/cors.go"
    click CSRF "https://github.com/done-0/jank/blob/main/internal/middleware/secure/csrf.go"
    click XSS "https://github.com/done-0/jank/blob/main/internal/middleware/secure/xss.go"
    click ReqLogger "https://github.com/done-0/jank/blob/main/internal/middleware/logger/logger.go"
    click Recover "https://github.com/done-0/jank/blob/main/internal/middleware/recover/recover.go"
    click ErrorHandler "https://github.com/done-0/jank/blob/main/internal/middleware/error/error_handler.go"
    click SwaggerMW "https://github.com/done-0/jank/blob/main/internal/middleware/swagger/swagger.go"
    click AccountCtrl "https://github.com/done-0/jank/blob/main/pkg/serve/controller/account/account.go"
    click CategoryCtrl "https://github.com/done-0/jank/blob/main/pkg/serve/controller/category/category.go"
    click CommentCtrl "https://github.com/done-0/jank/blob/main/pkg/serve/controller/comment/comment.go"
    click PostCtrl "https://github.com/done-0/jank/blob/main/pkg/serve/controller/post/post.go"
    click VerificationCtrl "https://github.com/done-0/jank/blob/main/pkg/serve/controller/verification/verification.go"
    click AccountSvc "https://github.com/done-0/jank/blob/main/pkg/serve/service/account/account.go"
    click CategorySvc "https://github.com/done-0/jank/blob/main/pkg/serve/service/category/category.go"
    click CommentSvc "https://github.com/done-0/jank/blob/main/pkg/serve/service/comment/comment.go"
    click PostSvc "https://github.com/done-0/jank/blob/main/pkg/serve/service/post/post.go"
    click Mapper "https://github.com/done-0/jank/tree/main/pkg/serve/mapper/"
    click DB "https://github.com/done-0/jank/blob/main/internal/db/conn.go"
    click DB "https://github.com/done-0/jank/blob/main/internal/db/auto_migrate.go"
    click Redis "https://github.com/done-0/jank/blob/main/internal/redis/redis.go"
    click SMTP "https://github.com/done-0/jank/blob/main/internal/utils/email.go"
    click OSS "https://github.com/done-0/jank/blob/main/internal/utils/object_storage.go"
    click SwaggerUI "https://github.com/done-0/jank/blob/main/docs/swagger.json"

    %% Styles
    classDef compute fill:#E3F2FD,stroke:#2196F3,stroke-width:2px
    classDef db fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px
    classDef ext fill:#FFF3E0,stroke:#FF9800,stroke-width:2px
    classDef infra fill:#F5F5F5,stroke:#9E9E9E,stroke-width:2px
```
