# tfikler/home-assignment-datawave architecture

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

- Interactive diagram: https://gitdiagram.com/tfikler/home-assignment-datawave
- Repository: https://github.com/tfikler/home-assignment-datawave

## Overview

##### Main Components Identification
The system consists of these primary components:

A. Frontend Layer (React Application)
- Client-side routing and views
- State management (Redux)
- UI Components
- API integration

B. Backend Layer (NestJS Application)
- REST API endpoints
- Business logic
- Database interaction

C. Database Layer (MySQL)
- Data persistence
- Country records storage

**[Client Layer] → [Server Layer] → [Database Layer]**

##### Detailed Component Breakdown

A. Client Layer (Frontend) Components:
- Sub-components:
- Pages (Countries, WorldMap)
- Redux Store (countries-slice)
- Shared Components (CustomTable, EditDialog, Filter, SearchBar, Sidebar)
- API Service Layer

B. Server Layer (Backend) Components:
- Sub-components:
- Controllers (CountriesController)
- Services (CountriesService)
- Models (CountriesModel)
- Configuration (Sequelize Config)

C. Database Layer:
- Countries table schema

##### Connection and Data Flow Representation

- Frontend → Backend: HTTP requests (GET, PUT, DELETE)
- Backend → Database: Sequelize ORM operations
- Backend → Frontend: HTTP responses with country data

##### Specific Implementation Details

Frontend Section:
**React Frontend (Blue)**
- Redux Store
- Countries Slice
- Components
- CustomTable
- EditDialog
- Filter
- SearchBar
- Sidebar
- Pages
- Countries
- WorldMap

Backend Section:
**NestJS Backend (Green)**
- Countries Module
- Controller (API Endpoints)
- Service (Business Logic)
- Model (Data Structure)
- Configuration
- Sequelize Config

##### Additional Elements

- API Endpoints listing:
- GET /countries
- GET /countries?page=-1
- /countries/:id
- DELETE /countries/:id

- Data flow indicators:
- User interactions
- API calls
- Database operations

##### Technical Stack Callouts

- Frontend: React, TypeScript, Redux Toolkit, Material-UI
- Backend: NestJS, TypeScript
- Database: MySQL
- Communication: REST API

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Frontend Layer"]
        direction TB
        FE[React Frontend]:::frontend
        click FE "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/App.tsx"
        
        subgraph Store["State Management"]
            direction TB
            Redux["Redux Store"]:::frontend
            click Redux "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/store.ts"
            CountrySlice["Countries Slice"]:::frontend
            click CountrySlice "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/slices/countries-slice.ts"
        end

        subgraph Components["UI Components"]
            direction TB
            Table["Custom Table"]:::frontend
            click Table "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/components/CustomTable/CustomTable.tsx"
            Edit["Edit Dialog"]:::frontend
            click Edit "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/components/EditDialog/EditDialog.tsx"
            Filter["Filter"]:::frontend
            click Filter "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/components/Filter/Filter.tsx"
            Search["Search Bar"]:::frontend
            click Search "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/components/SearchBar/SearchBar.tsx"
            Sidebar["Sidebar"]:::frontend
            click Sidebar "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/components/Sidebar/Sidebar.tsx"
        end

        subgraph Pages["Pages"]
            direction TB
            Countries["Countries Page"]:::frontend
            click Countries "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/pages/Countries/Countries.tsx"
            WorldMap["World Map"]:::frontend
            click WorldMap "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/pages/WorldMap/WorldMap.tsx"
        end

        Layout["Layout Component"]:::frontend
        click Layout "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/Layout.tsx"
        Types["Data Types"]:::frontend
        click Types "https://github.com/tfikler/home-assignment-datawave/blob/main/frontend/src/types/country.interface.ts"
    end

    subgraph Server["Backend Layer"]
        direction TB
        BE[NestJS Backend]:::backend
        click BE "https://github.com/tfikler/home-assignment-datawave/blob/main/backend/src/main.ts"
        
        subgraph CountriesModule["Countries Module"]
            direction TB
            Controller["Countries Controller"]:::backend
            click Controller "https://github.com/tfikler/home-assignment-datawave/blob/main/backend/src/Countries/countries.controller.ts"
            Service["Countries Service"]:::backend
            click Service "https://github.com/tfikler/home-assignment-datawave/blob/main/backend/src/Countries/countries.service.ts"
            Model["Countries Model"]:::backend
            click Model "https://github.com/tfikler/home-assignment-datawave/blob/main/backend/src/Countries/countries.model.ts"
        end

        Config["Sequelize Config"]:::backend
        click Config "https://github.com/tfikler/home-assignment-datawave/blob/main/backend/src/config/sequelize.config.ts"
        AppModule["App Module"]:::backend
        click AppModule "https://github.com/tfikler/home-assignment-datawave/blob/main/backend/src/app.module.ts"
    end

    subgraph DB["Database Layer"]
        MySQL[(MySQL Database)]:::database
    end

    %% Connections
    FE --> Controller
    Controller --> Service
    Service --> Model
    Model --> MySQL

    %% Component Relationships
    Layout --> Pages
    Pages --> Components
    Components --> Store
    CountrySlice --> Redux

    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef database fill:#FFC107,stroke:#FFA000,color:black

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        Database["Database Component"]:::database
    end
```
