# vlad-rzaiev/goit-react-hw-08 architecture

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

- Interactive diagram: https://gitdiagram.com/vlad-rzaiev/goit-react-hw-08
- Repository: https://github.com/vlad-rzaiev/goit-react-hw-08

## Overview

##### Project type and purpose
- This is a single-page front-end application built with React and Vite.
- It provides user authentication (register/login), contact management (list, add, edit, delete), and search/filtering.
- It uses Redux for state management (auth, contacts, filters) and Thunks (“operations.js”) for async API calls.

##### File structure
- Top-level:
- public – static assets
- src – application code
- vite.config.js / package.json – build & dependency config
- vercel.json – deployment settings
- src/components – reusable UI pieces (forms, nav, lists, loaders, routes)
- src/pages – route targets (HomePage, LoginPage, RegisterPage, ContactsPage)
- src/redux – three slices (auth, contacts, filters) plus store.js
- src/main.jsx + index.html – SPA entry point
- CSS modules for scoped styling
- ESLint & Prettier configs for code quality

##### README
- Confirms React + Vite setup, HMR via plugin-react or plugin-react-swc.
- Suggests TypeScript/ESLint expansions for production (out of scope).

a. Main components
- Browser/Client
- React Component Tree (UI Layer)
- Router (React Router)
- State Management (Redux Store with authSlice, contactsSlice, filtersSlice)
- Async Layer (Redux Thunks invoking REST API)
- External REST API (Auth & Contacts endpoints)
- Build & Deployment (Vite Dev Server, Vite Bundler, Vercel)
b. Relationships & interactions
1. Browser loads index.html → main.jsx → renders App
2. App contains Routes → pages → nested components
3. UI dispatches Redux actions → reducers update state
4. Thunks (operations.js) call external API → on success dispatch further actions
5. UI subscribes to store (selectors.js) → re-renders with fresh data
6. Vite dev server bundles modules & serves via HMR; on build outputs static assets for Vercel
c. Architectural patterns & design principles
- Component-based UI (separation of concerns)
- Unidirectional data flow (Redux)
- Thunk middleware for side effects (API calls)
- CSS Modules for encapsulated styling
- Route guards (PrivateRoute, RestrictedRoute) for auth
d. Key technologies & frameworks
- React + React Router
- Redux Toolkit (createSlice, createAsyncThunk)
- Vite (bundler + dev server) + plugin-react
- CSS Modules
- ESLint / Prettier
- Vercel for deployment

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Entry Point"
    Browser["Browser/Client\n(index.html → main.jsx)"]:::entry
  end

  subgraph "UI Layer"
    App["App"]:::ui
    AppBar["AppBar"]:::ui
    Navigation["Navigation"]:::ui
    AuthNav["AuthNav"]:::ui
    UserMenu["UserMenu"]:::ui
    Container["Container"]:::ui
    Section["Section"]:::ui
  end

  subgraph "Routing Layer"
    Router["Router"]:::routing
    PrivateRoute["PrivateRoute"]:::routing
    RestrictedRoute["RestrictedRoute"]:::routing
  end

  subgraph "Pages"
    HomePage["HomePage"]:::page
    LoginPage["LoginPage"]:::page
    RegisterPage["RegisterPage"]:::page
    ContactsPage["ContactsPage"]:::page
  end

  subgraph "Components"
    LoginForm["LoginForm"]:::component
    RegisterForm["RegisterForm"]:::component
    ContactForm["ContactForm"]:::component
    EditForm["EditForm"]:::component
    ContactList["ContactList"]:::component
    ContactItem["Contact"]:::component
    SearchBox["SearchBox"]:::component
    ConfirmDelete["ConfirmDelete"]:::component
    Loader["Loader"]:::component
    ErrorMessage["ErrorMessage"]:::component
    NoContacts["NoContacts"]:::component
  end

  subgraph "State Management"
    Store["Redux Store"]:::state
    AuthSlice["authSlice"]:::state
    ContactsSlice["contactsSlice"]:::state
    FiltersSlice["filtersSlice"]:::state
  end

  subgraph "Async Layer"
    AuthOps["Auth Thunks\n(operations.js)"]:::data
    ContactsOps["Contacts Thunks\n(operations.js)"]:::data
  end

  subgraph "External Services"
    API["REST API\n(Auth & Contacts)"]:::external
  end

  subgraph "Build & Deployment"
    ViteDev["Vite Dev Server"]:::build
    ViteBuild["Vite Build"]:::build
    Vercel["Vercel Deploy"]:::build
    Package["package.json"]:::build
  end

  Browser --> App
  App --> Router
  Router --> PrivateRoute
  Router --> RestrictedRoute

  App --> AppBar
  App --> Navigation
  Navigation --> AuthNav
  Navigation --> UserMenu
  App --> Container
  Container --> Section

  Router --> HomePage
  Router --> LoginPage
  Router --> RegisterPage
  Router --> ContactsPage

  LoginPage --> LoginForm
  RegisterPage --> RegisterForm
  ContactsPage --> ContactForm
  ContactsPage --> EditForm
  ContactsPage --> ContactList
  ContactList --> ContactItem
  ContactsPage --> SearchBox
  ContactsPage --> ConfirmDelete
  ContactsPage --> Loader
  ContactsPage --> ErrorMessage
  ContactsPage --> NoContacts

  App --> Store
  Store --> AuthSlice
  Store --> ContactsSlice
  Store --> FiltersSlice

  AuthSlice --> AuthOps
  ContactsSlice --> ContactsOps
  AuthOps --> API
  ContactsOps --> API
  API --> AuthOps
  API --> ContactsOps
  AuthOps --> AuthSlice
  ContactsOps --> ContactsSlice

  Browser <-- ViteDev
  Package --> ViteDev
  Package --> ViteBuild
  ViteBuild --> Vercel

  classDef entry fill:#D6E9FF,stroke:#2C7BE5,color:#2C7BE5;
  classDef ui fill:#E3FCEF,stroke:#28A745,color:#155724;
  classDef routing fill:#FFF3CD,stroke:#FFC107,color:#856404;
  classDef page fill:#E8F0FE,stroke:#4267B2,color:#1F3A93;
  classDef component fill:#F7F7F9,stroke:#6C757D,color:#343A40;
  classDef state fill:#E2F0D9,stroke:#51A351,color:#285430;
  classDef data fill:#FFF4E5,stroke:#FFA940,color:#663C00;
  classDef external fill:#F0F0F0,stroke:#A9A9A9,color:#333333;
  classDef build fill:#F5E6FF,stroke:#A569BD,color:#512E5F;

  click Browser "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/main.jsx"
  click App "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/App/App.jsx"
  click PrivateRoute "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/PrivateRoute.jsx"
  click RestrictedRoute "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/RestrictedRoute.jsx"
  click HomePage "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/pages/HomePage/HomePage.jsx"
  click LoginPage "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/pages/LoginPage/LoginPage.jsx"
  click RegisterPage "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/pages/RegisterPage/RegisterPage.jsx"
  click ContactsPage "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/pages/ContactsPage/ContactsPage.jsx"
  click AppBar "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/AppBar/AppBar.jsx"
  click Navigation "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/Navigation/Navigation.jsx"
  click AuthNav "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/AuthNav/AuthNav.jsx"
  click UserMenu "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/UserMenu/UserMenu.jsx"
  click LoginForm "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/LoginForm/LoginForm.jsx"
  click RegisterForm "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/RegisterForm/RegisterForm.jsx"
  click ContactForm "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/ContactForm/ContactForm.jsx"
  click EditForm "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/EditForm/EditForm.jsx"
  click ContactList "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/ContactList/ContactList.jsx"
  click ContactItem "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/Contact/Contact.jsx"
  click SearchBox "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/SearchBox/SearchBox.jsx"
  click ConfirmDelete "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/ConfirmDelete/ConfirmDelete.jsx"
  click Loader "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/Loader/Loader.jsx"
  click ErrorMessage "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/ErrorMessage/ErrorMessage.jsx"
  click NoContacts "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/NoContacts/NoContacts.jsx"
  click Container "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/Container/Container.jsx"
  click Section "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/components/Section/Section.jsx"
  click Store "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/redux/store.js"
  click AuthSlice "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/redux/auth/slice.js"
  click AuthOps "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/redux/auth/operations.js"
  click ContactsSlice "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/redux/contacts/slice.js"
  click ContactsOps "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/redux/contacts/operations.js"
  click FiltersSlice "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/src/redux/filters/slice.js"
  click Package "https://github.com/vlad-rzaiev/goit-react-hw-08/blob/main/package.json"
```
