# thebyteflow/inker architecture

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

- Interactive diagram: https://gitdiagram.com/thebyteflow/inker
- Repository: https://github.com/thebyteflow/inker

## Overview

##### Project type and purpose
- This is a full-stack blog application (“INKER Blog”) implemented as a monorepo.
- Frontend: React + TypeScript + Vite, provides UI for users to read, create, edit posts, comment, follow, vote, manage profiles.
- Backend: Node.js + TypeScript (Express-style MVC with services & repositories), exposes RESTful JSON API, handles authentication (JWT + OTP), file uploads (Cloudinary), email, and interacts with MongoDB & Redis.
- Shared folder: contains common TypeScript types used by both frontend and backend for end-to-end type safety.

##### File structure
- Top-level directories
- /backend: API server
- /frontend: Single-page application
- /shared: Shared TypeScript definitions
- Backend layers conform to MVC + service + repository pattern:
- configs → external service and environment configurations (MongoDB, Redis, Mail, Cloudinary)
- routers → API endpoints
- controllers → request handling, input validation
- services → business logic
- repositories → data access abstractions over MongoDB
- models → Mongoose schema definitions
- middlewares → cross-cutting concerns (auth, rate limit, error handling)
- utils → low-level helpers (JWT, email, OTP, NanoID, error formatting)
- Frontend layers:
- src/router → route definitions (Protected/UnProtected)
- src/pages → top-level views
- src/components → reusable UI pieces (UI primitives, user/admin widgets)
- src/services → API call wrappers matching backend routes
- src/store (+ slices) → global state (Redux Toolkit or Zustand)
- shared types + env config + axios wrapper
- Deployment/config: Dockerfiles (backend), docker-compose.yaml for multi-container setup, Vercel config for frontend.

##### Extract architecture insights from README
- Uses Docker Compose to orchestrate services (backend, MongoDB, Redis).
- Follows SOLID & MVC principles.
- Environment variables drive service endpoints & credentials.
- Conventional commits and coding standards indicate clear modularity.

##### Final recommendation
- Drill down within the API block to show its layered modules.
- Link frontend pages/services to specific backend routers/endpoints.
- Keep it readable: avoid overcrowding; split into two views (overview + backend detail) if necessary.
- Review with team to confirm you captured all integration points (e.g., OTP service, rate-limiter, file upload pipeline).

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Top-level entities
  Browser["Browser (React SPA)"]:::frontend
  API["API Server (Express-style Node.js)"]:::backend
  MongoDB[(MongoDB)]:::db
  Redis[(Redis)]:::db
  Cloudinary["Cloudinary"]:::external
  SMTP["SMTP / Email Provider"]:::external
  OAuth["OAuth Provider (Google)"]:::external
  SharedTypes["Shared Types"]:::shared

  %% Frontend Subgraph
  subgraph "Frontend Application" 
    direction TB
    MainEntry["UI Entry (main.tsx & index.html)"]:::frontend
    Router["Route Definitions"]:::frontend
    Pages["Top-level Pages"]:::frontend
    Components["Reusable Components"]:::frontend
    APIServices["API Service Wrappers"]:::frontend
    Store["Global State Store"]:::frontend
  end

  %% Backend Subgraph
  subgraph "Backend Application"
    direction TB
    Entry["Server Entry Point"]:::backend
    Configs["Config Layer"]:::backend
    Routers["Routers (API Endpoints)"]:::backend
    Controllers["Controllers (Validation & Handling)"]:::backend
    Schemas["Request Schemas (Zod)"]:::backend
    Services["Services (Business Logic)"]:::backend
    Repositories["Repositories (Data Access)"]:::backend
    Models["Models (Mongoose Schemas)"]:::backend
    Middlewares["Middlewares"]:::backend
    Utils["Utilities"]:::backend
  end

  %% Connections - High Level
  Browser -->|uses SPA| MainEntry
  MainEntry --> Router
  Router --> Pages
  Router --> Components
  Pages --> APIServices
  Components --> APIServices
  APIServices -->|REST API| API
  APIServices --> SharedTypes
  Store --> SharedTypes

  API --> Routers
  Routers --> Controllers
  Controllers --> Schemas
  Controllers --> Services
  Services --> Repositories
  Repositories --> Models
  Repositories --> MongoDB
  API --> Redis
  API --> Cloudinary
  API --> SMTP
  API --> OAuth
  API --> Configs
  API --> Middlewares
  API --> Utils
  Configs --> MongoDB
  Configs --> Redis
  Utils --> SMTP
  Utils --> Cloudinary

  SharedTypes -.-> Pages
  SharedTypes -.-> Components
  SharedTypes -.-> APIServices
  SharedTypes -.-> Controllers

  %% Click Events - Frontend
  click MainEntry "https://github.com/thebyteflow/inker/blob/main/frontend/src/main.tsx"
  click MainEntry "https://github.com/thebyteflow/inker/blob/main/frontend/index.html"
  click Router "https://github.com/thebyteflow/inker/blob/main/frontend/src/router/AppRoutes.tsx"
  click Router "https://github.com/thebyteflow/inker/blob/main/frontend/src/router/ProtectedRoutes.tsx"
  click Router "https://github.com/thebyteflow/inker/blob/main/frontend/src/router/UnProtectedRoutes.tsx"
  click Pages "https://github.com/thebyteflow/inker/tree/main/frontend/src/pages/"
  click Components "https://github.com/thebyteflow/inker/tree/main/frontend/src/components/"
  click APIServices "https://github.com/thebyteflow/inker/tree/main/frontend/src/services/"
  click Store "https://github.com/thebyteflow/inker/tree/main/frontend/src/store/"
  click SharedTypes "https://github.com/thebyteflow/inker/blob/main/shared/types/index.ts"

  %% Click Events - Backend
  click Entry "https://github.com/thebyteflow/inker/blob/main/backend/src/index.ts"
  click Entry "https://github.com/thebyteflow/inker/tree/main/backend/Dockerfile"
  click Configs "https://github.com/thebyteflow/inker/tree/main/backend/src/configs/"
  click Routers "https://github.com/thebyteflow/inker/tree/main/backend/src/routers/"
  click Controllers "https://github.com/thebyteflow/inker/tree/main/backend/src/controllers/implementation/"
  click Controllers "https://github.com/thebyteflow/inker/tree/main/backend/src/controllers/interface/"
  click Services "https://github.com/thebyteflow/inker/tree/main/backend/src/services/implementation/"
  click Services "https://github.com/thebyteflow/inker/tree/main/backend/src/services/interface/"
  click Repositories "https://github.com/thebyteflow/inker/tree/main/backend/src/repositories/implementation/"
  click Repositories "https://github.com/thebyteflow/inker/tree/main/backend/src/repositories/interface/"
  click Repositories "https://github.com/thebyteflow/inker/blob/main/backend/src/repositories/base.repository.ts"
  click Models "https://github.com/thebyteflow/inker/tree/main/backend/src/models/implementation/"
  click Middlewares "https://github.com/thebyteflow/inker/tree/main/backend/src/middlewares/"
  click Schemas "https://github.com/thebyteflow/inker/tree/main/backend/src/schema/"
  click Utils "https://github.com/thebyteflow/inker/tree/main/backend/src/utils/"
  click docker-compose.yaml "https://github.com/thebyteflow/inker/blob/main/docker-compose.yaml"
  click Vercel "https://github.com/thebyteflow/inker/blob/main/frontend/vercel.json"

  %% Styles
  classDef frontend fill:#cce5ff,stroke:#0066cc,color:#003366;
  classDef backend fill:#d4edda,stroke:#218838,color:#155724;
  classDef db fill:#fff3cd,stroke:#856404,color:#856404,shape:cylinder;
  classDef external fill:#e2e3e5,stroke:#6c757d,color:#495057,shape:cloud;
  classDef shared fill:#f5c6cb,stroke:#721c24,color:#721c24;
```
