# crawlear-com/crawlearroutes architecture

> Architecture diagram of the GitHub repository crawlear-com/crawlearroutes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crawlear-com/crawlearroutes
- Repository: https://github.com/crawlear-com/crawlearroutes

## Overview

##### Project Type and Purpose
- This is a full-stack, map-centric PWA built with Vite, React, Redux Toolkit, Supabase, and i18n.
- Its core use case is browsing and managing routes and events, with list views (generic item lists) at its heart.

a. Redux Store (itemListsSlice)
- Holds shared list state: `items[]`, `filterParams`, `paginationParams`, `query`.
- Exposes selectors and actions (e.g., `setFilter`, `setPage`, `setItems`).
b. ItemsList Container Component (`/src/components/ItemCardList/ItemCardList.tsx`)
- A generic list wrapper using render props.
- Connects to Redux selectors to read `items`, `filter`, `pagination`.
- Passes a render function (`renderItem`) to display each item.
c. ItemsListFilter Component (`ItemsListFilter.tsx`)
- UI for entering a filter string.
- Dispatches `setFilter(filterString)` on user input.
d. ItemsPaginator Component (`ItemsPaginator.tsx`)
- UI for page controls (prev/next, page numbers).
- Dispatches `setPage(pageNumber)` on navigation.
e. Individual Item Cards (custom card components)
- Rendered by `ItemCardList` via render props.
- Example: `RouteCard`, `EventCard`, etc.

##### Relationships and Data Flow
- UI Event (e.g., typing in filter or clicking page) → dispatch Redux action → store updates slice state.
- Store State Change → `ItemCardList` re-selects `items[]` and passes them down via render props.
- Render Props → individual Item Card components for each item.

##### Architectural Patterns and Principles
- Redux Toolkit slice per list to avoid prop drilling and preserve state across navigation.
- TypeScript Generics (`<T>`) in `ItemCardList` for reuse across data types.
- Render Props pattern in `ItemCardList` to inject custom card UI.
- Separation of concerns: UI components vs. hooks vs. Redux store.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Redux Store Slices"
        direction TB
        EventListsSlice["eventListsSlice"]:::reduxSlice
        RouteListsSlice["routeListsSlice"]:::reduxSlice
    end

    ItemCardList["ItemCardList<T>\n(renderItem: (item: T) => ReactNode)"]:::reactComp

    subgraph "List Controls"
        direction TB
        ItemsListFilter["ItemsListFilter"]:::reactComp
        ItemsPaginator["ItemsPaginator"]:::reactComp
    end

    subgraph "Hooks"
        direction TB
        useFilter["useItemsListFilter"]:::hook
        usePaginator["useItemsPaginator"]:::hook
    end

    subgraph "Item Cards"
        direction TB
        RouteCard["RouteCard"]:::reactComp
        EventCard["RouteEventCard"]:::reactComp
    end

    EventListsSlice -->|"select: items[], filter, page"| ItemCardList
    RouteListsSlice -->|"select: items[], filter, page"| ItemCardList

    ItemsListFilter -->|"dispatch setFilter()"| EventListsSlice
    ItemsListFilter -->|"dispatch setFilter()"| RouteListsSlice

    ItemsPaginator -->|"dispatch setPage()"| EventListsSlice
    ItemsPaginator -->|"dispatch setPage()"| RouteListsSlice

    ItemCardList -->|"renderItem(item)"| RouteCard
    ItemCardList -->|"renderItem(item)"| EventCard

    ItemsListFilter --> useFilter
    ItemsPaginator --> usePaginator

    click EventListsSlice "https://github.com/crawlear-com/crawlearroutes/blob/main/src/features/events/store/slices/eventListsSlice.ts"
    click RouteListsSlice "https://github.com/crawlear-com/crawlearroutes/blob/main/src/features/routes/store/slices/routeListsSlice.ts"
    click ItemCardList "https://github.com/crawlear-com/crawlearroutes/blob/main/src/components/ItemCardList/ItemCardList.tsx"
    click ItemsListFilter "https://github.com/crawlear-com/crawlearroutes/blob/main/src/components/ItemCardList/ItemsListFilter.tsx"
    click ItemsPaginator "https://github.com/crawlear-com/crawlearroutes/blob/main/src/components/ItemCardList/ItemsPaginator.tsx"
    click useFilter "https://github.com/crawlear-com/crawlearroutes/blob/main/src/components/ItemCardList/hooks/useItemsListFilter.ts"
    click usePaginator "https://github.com/crawlear-com/crawlearroutes/blob/main/src/components/ItemCardList/hooks/useItemsPaginator.tsx"
    click RouteCard "https://github.com/crawlear-com/crawlearroutes/blob/main/src/features/routes/RouteCard/RouteCard.tsx"
    click EventCard "https://github.com/crawlear-com/crawlearroutes/blob/main/src/features/events/RouteEventCard/RouteEventCard.tsx"

    classDef reactComp fill:#D6EAF8,stroke:#1F618D,stroke-width:1px
    classDef reduxSlice fill:#D5F5E3,stroke:#196F3D,stroke-width:1px
    classDef hook fill:#F2F3F4,stroke:#7D6608,stroke-width:1px

    linkStyle 0 stroke:#0000FF,stroke-width:2px
    linkStyle 1 stroke:#0000FF,stroke-width:2px
    linkStyle 2 stroke:#FFA500,stroke-width:2px
    linkStyle 3 stroke:#FFA500,stroke-width:2px
    linkStyle 4 stroke:#FFA500,stroke-width:2px
    linkStyle 5 stroke:#FFA500,stroke-width:2px
    linkStyle 6 stroke:#0000FF,stroke-width:2px
    linkStyle 7 stroke:#0000FF,stroke-width:2px
    linkStyle 8 stroke:#808080,stroke-dasharray: 2,2
    linkStyle 9 stroke:#808080,stroke-dasharray: 2,2
```
