# ankalago/multiplo-test architecture

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

- Interactive diagram: https://gitdiagram.com/ankalago/multiplo-test
- Repository: https://github.com/ankalago/multiplo-test

## Overview

##### Main Components Identification

The system should be represented as two main sections:

Frontend (React Application):
- Present as a layered architecture with:
- Presentation Layer (Components)
- State Management Layer (Redux)
- Services Layer
- Utils/Hooks Layer

Backend (Hexagonal Architecture):
- Core hexagon containing:
- Application Layer (Use Cases)
- Domain Layer
- Ports (Interfaces)
- Adapters Ring containing:
- Controllers
- Repositories
- Infrastructure components

**┌─ Frontend Container ──────────────────────┐**
- ┌─ Components ─────┐ ┌─ Store ────────┐  │
- Pages         │ │ - Redux Store   │  │
- Layout        │ │ - State Slices  │  │
- UI Components │ └────────────────┘  │
- ┘                     │
- ┌─ Services ──────┐ ┌─ Utils/Hooks ──┐  │
- API Services  │ │ - Custom Hooks  │  │
- Axios Config  │ │ - Utilities     │  │
- ┘ └────────────────┘  │
- ┘

**┌─ Backend Hexagon ──────────────────────────┐**
- ┌─ Application Core ─────────────────┐   │
- ┌─ Domain ─────┐ ┌─ Use Cases ──┐ │   │
- Post Entity│ │ - Create Post │ │   │
- Interfaces │ │ - Get Posts   │ │   │
- ┘ │ - Update Post │ │   │
- ┘ │   │
- ┘   │

- ┌─ Adapters ──────────────────────────┐ │
- Controllers                       │ │
- Repositories                      │ │
- ┘
- ┌─ Infrastructure ───────────────────┐   │
- Prisma DB                        │   │
- SQLite Database                  │   │
- ┘
- ┘

##### Connection and Data Flow

- Frontend-Backend communication via REST API
- Internal frontend data flow (Components → Redux → Services)
- Internal backend flow (Controller → Use Cases → Repository → Database)

##### Additional Elements

Include:
- API endpoints (/api/v1/post)
- Testing coverage indicators
- External services (Vercel, Railway)
- Database schema representation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        direction TB
        Components["Components Layer"]
        Pages["Pages"]:::component
        Layout["Layout"]:::component
        UIComponents["UI Components"]:::component
        Components --> Pages
        Components --> Layout
        Components --> UIComponents

        StateManagement["State Management"]
        Store["Redux Store"]:::store
        Slices["State Slices"]:::store
        StateManagement --> Store
        StateManagement --> Slices

        Services["Services Layer"]
        APIServices["API Services"]:::service
        ServiceHooks["Service Hooks"]:::service
        Services --> APIServices
        Services --> ServiceHooks

        Utils["Utils/Hooks Layer"]
        Utilities["Utils"]:::util
        CustomHooks["Custom Hooks"]:::util
        Utils --> Utilities
        Utils --> CustomHooks

        Components <--> StateManagement
        StateManagement <--> Services
        Services <--> Utils
    end

    subgraph Backend
        direction TB
        subgraph Core
            Domain["Domain Layer"]
            Entities["Entities"]:::domain
            Interfaces["Interfaces"]:::domain
            Domain --> Entities
            Domain --> Interfaces

            UseCases["Use Cases"]
            CreatePost["Create Post"]:::usecase
            GetPosts["Get Posts"]:::usecase
            UpdatePost["Update Post"]:::usecase
            UseCases --> CreatePost
            UseCases --> GetPosts
            UseCases --> UpdatePost
        end

        subgraph Adapters
            Controllers["Controllers"]:::adapter
            Repositories["Repositories"]:::adapter
            Mappers["Mappers"]:::adapter
        end

        subgraph Infrastructure
            Database["Database"]:::infra
            Schema["Schema"]:::infra
            Migrations["Migrations"]:::infra
        end

        Routes["Routes"]:::router
        Controllers <--> Routes
        Routes <--> UseCases
        UseCases <--> Domain
        UseCases <--> Repositories
        Repositories <--> Database
    end

    APIServices <--> Routes

    %% Component Mappings
    click Pages "https://github.com/ankalago/multiplo-test/tree/main/frontend/src/components/Pages"
    click Layout "https://github.com/ankalago/multiplo-test/tree/main/frontend/src/components/Layout"
    click UIComponents "https://github.com/ankalago/multiplo-test/tree/main/frontend/src/components/Card"
    click Store "https://github.com/ankalago/multiplo-test/blob/main/frontend/src/store/store.ts"
    click Slices "https://github.com/ankalago/multiplo-test/blob/main/frontend/src/store/states/multigram.ts"
    click APIServices "https://github.com/ankalago/multiplo-test/blob/main/frontend/src/lib/axiosServices.ts"
    click ServiceHooks "https://github.com/ankalago/multiplo-test/blob/main/frontend/src/services/useServiceFetch.ts"
    click Utilities "https://github.com/ankalago/multiplo-test/blob/main/frontend/src/utils/utils.ts"
    click CustomHooks "https://github.com/ankalago/multiplo-test/blob/main/frontend/src/hooks/useTimeAgo.ts"
    click Entities "https://github.com/ankalago/multiplo-test/blob/main/backend/src/application/Post/domain/Post.ts"
    click Interfaces "https://github.com/ankalago/multiplo-test/blob/main/backend/src/application/Post/domain/IPost.ts"
    click CreatePost "https://github.com/ankalago/multiplo-test/blob/main/backend/src/application/Post/usecases/createPost.ts"
    click GetPosts "https://github.com/ankalago/multiplo-test/blob/main/backend/src/application/Post/usecases/getPosts.ts"
    click UpdatePost "https://github.com/ankalago/multiplo-test/blob/main/backend/src/application/Post/usecases/updatePost.ts"
    click Controllers "https://github.com/ankalago/multiplo-test/blob/main/backend/src/adapter/Post/PostController.ts"
    click Repositories "https://github.com/ankalago/multiplo-test/blob/main/backend/src/adapter/Post/PostRepository.ts"
    click Mappers "https://github.com/ankalago/multiplo-test/blob/main/backend/src/adapter/mappers/PostMapper.ts"
    click Database "https://github.com/ankalago/multiplo-test/blob/main/backend/src/infrastructure/db/db.ts"
    click Schema "https://github.com/ankalago/multiplo-test/blob/main/backend/src/infrastructure/db/schema.prisma"
    click Migrations "https://github.com/ankalago/multiplo-test/tree/main/backend/src/infrastructure/db/migrations"
    click Routes "https://github.com/ankalago/multiplo-test/blob/main/backend/src/routers/post/post.route.ts"

    %% Styling
    classDef component fill:#a8d5ff
    classDef store fill:#ffb3b3
    classDef service fill:#b3ffb3
    classDef util fill:#ffffb3
    classDef domain fill:#c6b3ff
    classDef usecase fill:#ffccff
    classDef adapter fill:#ffd9b3
    classDef infra fill:#d9d9d9
    classDef router fill:#ff9999
```
