# nmzz209741/inkpandas architecture

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

- Interactive diagram: https://gitdiagram.com/nmzz209741/inkpandas
- Repository: https://github.com/nmzz209741/inkpandas

## Overview

##### Main System Components

a) Frontend Layer (React Application)
- React application container
- Modules:
- Components (pages, views, common)
- API Services
- Context Management (Auth)
- Routing
- Query Management

b) Backend Layer (Node.js Application)
- Express.js server container
- Modules:
- Controllers
- Routes
- Middleware
- Models
- Validators

c) Data Layer
- DynamoDB database
- Redis cache

d) Infrastructure Layer
- Nginx reverse proxy
- Docker containers
- ECS deployment

##### Component Relationships

a) Client-Server Communication
- Frontend → Nginx → Backend API
- RESTful API endpoints for:
- Articles management
- Authentication
- User management

b) Data Flow
- Backend → DynamoDB (primary storage)
- Backend → Redis (caching layer)
- Authentication flow with JWT tokens

##### Specific Implementation Details

Technical aspects:

a) Frontend Architecture:
**React App**
- Components (Layout, Pages, Views)
- Context (Auth state management)
- API Services
- Hooks (Custom hooks for articles and auth)

b) Backend Architecture:
**Express App**
- Routes
- Controllers
- Models
- Middlewares
- Validators

##### Infrastructure Details

Deployment architecture:

a) Docker Container Structure:
- Frontend container
- Backend container
- DynamoDB local (development)
- Redis container
- Nginx container

b) Production Deployment:
- ECS service
- Load balancing
- Container orchestration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Infrastructure
        NGINX["Nginx Reverse Proxy"]:::infra
        DOCKER["Docker Containers"]:::infra
        ECS["ECS Deployment"]:::infra
    end

    subgraph "Frontend Layer"
        REACT["React Application"]:::frontend
        subgraph "Frontend Components"
            COMP["Components"]:::frontend
            PAGES["Pages & Views"]:::frontend
            PROUTE["Protected Routes"]:::frontend
        end
        subgraph "Frontend Services"
            FAPI["API Services"]:::frontend
            QUERY["Query Management"]:::frontend
            ROUTER["Routing"]:::frontend
            AUTH_CTX["Auth Context"]:::frontend
        end
        subgraph "Frontend Hooks"
            AUTH_HOOK["Auth Hooks"]:::frontend
            ART_HOOK["Article Hooks"]:::frontend
        end
    end

    subgraph "Backend Layer"
        EXPRESS["Express.js Server"]:::backend
        subgraph "API Components"
            ROUTES["Routes"]:::backend
            CTRL["Controllers"]:::backend
            AUTH_CTRL["Auth Controller"]:::backend
            ART_CTRL["Articles Controller"]:::backend
        end
        subgraph "Backend Services"
            MID["Middleware"]:::backend
            VAL["Validators"]:::backend
            MODELS["Models"]:::backend
        end
    end

    subgraph "Data Layer"
        DB[(DynamoDB)]:::data
        REDIS[(Redis Cache)]:::data
    end

    %% Relationships
    NGINX --> EXPRESS
    REACT --> NGINX
    EXPRESS --> DB
    EXPRESS --> REDIS
    
    %% Frontend Relationships
    REACT --> COMP
    REACT --> FAPI
    REACT --> AUTH_CTX
    COMP --> PAGES
    COMP --> PROUTE
    AUTH_CTX --> AUTH_HOOK
    FAPI --> ART_HOOK
    
    %% Backend Relationships
    EXPRESS --> ROUTES
    ROUTES --> CTRL
    CTRL --> AUTH_CTRL
    CTRL --> ART_CTRL
    EXPRESS --> MID
    EXPRESS --> MODELS
    MODELS --> DB
    
    %% Click Events
    click COMP "https://github.com/nmzz209741/inkpandas/tree/main/frontend/src/components/"
    click FAPI "https://github.com/nmzz209741/inkpandas/tree/main/frontend/src/api/"
    click AUTH_CTX "https://github.com/nmzz209741/inkpandas/tree/main/frontend/src/contexts/"
    click ROUTER "https://github.com/nmzz209741/inkpandas/blob/main/frontend/src/configs/router.jsx"
    click QUERY "https://github.com/nmzz209741/inkpandas/blob/main/frontend/src/services/queryClient.js"
    click CTRL "https://github.com/nmzz209741/inkpandas/tree/main/backend/src/controllers/"
    click ROUTES "https://github.com/nmzz209741/inkpandas/tree/main/backend/src/routes/"
    click MID "https://github.com/nmzz209741/inkpandas/tree/main/backend/src/middlewares/"
    click MODELS "https://github.com/nmzz209741/inkpandas/tree/main/backend/src/models/"
    click VAL "https://github.com/nmzz209741/inkpandas/tree/main/backend/src/validators/"
    click DB "https://github.com/nmzz209741/inkpandas/blob/main/backend/src/lib/dynamo.js"
    click REDIS "https://github.com/nmzz209741/inkpandas/blob/main/backend/src/lib/redis.js"
    click NGINX "https://github.com/nmzz209741/inkpandas/blob/main/nginx.conf"
    click DOCKER "https://github.com/nmzz209741/inkpandas/blob/main/docker-compose.yml"
    click AUTH_CTRL "https://github.com/nmzz209741/inkpandas/blob/main/backend/src/controllers/authController.js"
    click ART_CTRL "https://github.com/nmzz209741/inkpandas/blob/main/backend/src/controllers/articlesController.js"
    click AUTH_HOOK "https://github.com/nmzz209741/inkpandas/blob/main/frontend/src/hooks/useAuth.js"
    click ART_HOOK "https://github.com/nmzz209741/inkpandas/blob/main/frontend/src/hooks/useArticles.js"
    click FAPI "https://github.com/nmzz209741/inkpandas/blob/main/frontend/src/services/api.js"
    click PROUTE "https://github.com/nmzz209741/inkpandas/blob/main/frontend/src/components/common/ProtectedRoute.jsx"

    %% Styles
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef data fill:#f1c40f,color:black
    classDef infra fill:#95a5a6,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        D[(Database)]:::data
        I[Infrastructure]:::infra
    end
```
