# mikansc/connectlab architecture

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

- Interactive diagram: https://gitdiagram.com/mikansc/connectlab
- Repository: https://github.com/mikansc/connectlab

## Overview

##### Project type and purpose
- This is a single-page, front-end React application (built with Vite) that serves as the UI for the “DEVInHouse ConnectLab” platform.
- Purpose: allow users to log in, view devices, add/update devices and users, fetch weather info, and look up addresses by CEP.
- It integrates with an external back-end API (Node) and third-party services (Weather API, ViaCEP).

##### File structure
- Top-level:
- Dockerfile / docker-compose.yml / netlify.toml – containerization and deployment configs
- public/index.html – app shell
- src/ – application source
- src/App.jsx + src/main.jsx & src/routes – entry point + router
- src/components – atomic design layers (atoms → molecules → organisms → templates → pages)
- src/contexts – React Contexts for auth, devices, app state
- src/hooks – custom hooks for fetching data & controlling UI state
- src/services/http – HTTP service layer with Axios factories, adapters, and service functions (authService, deviceHttpService, weatherHttpService, etc.)
- src/services/local – local storage abstractions
- src/i18n – localization with translation JSONs
- src/themes – global styles and theme definitions
- src/validations – input validation schemas

##### README for additional insights
- Describes environment variables for API endpoints and keys
- Documents local and Docker-based setup
- Mentions a separate Node back-end repo

##### Final advice
- Interactions (authentication flow, data fetch/update).
- Essential architectural elements without over-splitting trivial files—focus on functional groupings.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Front-end Browser
    subgraph "Client Browser" 
        direction TB
        Browser["Browser"]:::external
    end

    %% React Front-end App
    subgraph "React Front-end App" 
        direction TB

        subgraph "Entry Points" 
            direction TB
            MainJS["main.jsx"]:::ui
            AppJS["App.jsx"]:::ui
        end

        subgraph "UI Components (Atomic Design)"
            direction TB
            Atoms["Atoms"]:::ui
            Molecules["Molecules"]:::ui
            Organisms["Organisms"]:::ui
            Templates["Templates"]:::ui
            Pages["Pages"]:::ui
        end

        subgraph "Routing Layer"
            direction TB
            Router["Router.jsx"]:::ui
            PrivateRoutes["PrivateRoutes.jsx"]:::ui
            DashboardRoutes["DashboardRoutes.jsx"]:::ui
            RoutesIndex["index.js"]:::ui
        end

        subgraph "State Management"
            direction TB
            Contexts["React Contexts"]:::state
            Hooks["Custom Hooks"]:::state
        end

        subgraph "HTTP Service Layer"
            direction TB
            AxiosFactory["axiosInstanceFactory.js"]:::svc
            HTTPCore["httpService.js"]:::svc
            Adapters["Adapters"]:::svc
            Services["Services"]:::svc
        end

        subgraph "Local Storage Service"
            direction TB
            LocalStorage["storageService.js"]:::storage
        end

        subgraph "i18n Module"
            direction TB
            I18nIndex["i18n/index.js"]:::state
        end

        subgraph "Theming & Global Styles"
            direction TB
            GlobalStyle["GlobalStyle.js"]:::ui
            DefaultTheme["default.js"]:::ui
        end

        subgraph "Validations"
            direction TB
            Validations["Validation Schemas"]:::state
        end

    end

    %% External Back-end API
    subgraph "External Back-end API" 
        direction TB
        BackEnd["ConnectLab Server"]:::external
    end

    %% Third-party Services
    subgraph "Third-party Services"
        direction TB
        ViaCEP["ViaCEP"]:::external
        WeatherAPI["Weather API"]:::external
    end

    %% Deployment
    subgraph "Deployment & CI/CD"
        direction TB
        Docker["Docker"]:::infra
        Netlify["Netlify"]:::infra
    end

    %% Connections
    Browser -->|"loads index.html"| MainJS
    MainJS -->|renders| AppJS
    AppJS -->|renders| Atoms
    AppJS -->|renders| Molecules
    AppJS -->|renders| Organisms
    AppJS -->|renders| Templates
    AppJS -->|renders| Pages

    AppJS -->|uses| Router
    Router -->|uses| PrivateRoutes
    Router -->|uses| DashboardRoutes
    Router -->|imports| RoutesIndex

    Pages -->|dispatch actions| Contexts
    Pages -->|use hooks| Hooks

    Hooks -->|call| AxiosFactory
    AxiosFactory -->|creates instance| HTTPCore
    HTTPCore -->|uses| Adapters
    HTTPCore -->|calls| Services
    Services -->|HTTP| BackEnd
    Services -->|normalizes| Adapters

    BackEnd -->|calls| ViaCEP
    BackEnd -->|calls| WeatherAPI

    Services -->|persist tokens| LocalStorage
    Pages -->|i18n| I18nIndex
    GlobalStyle -->|applied| UI

    Pages -->|validate input| Validations

    AppJS -->|deployed in| Docker
    AppJS -->|hosted on| Netlify

    %% Click Events
    click MainJS "https://github.com/mikansc/connectlab/blob/main/src/main.jsx"
    click AppJS "https://github.com/mikansc/connectlab/blob/main/src/App.jsx"
    click Atoms "https://github.com/mikansc/connectlab/tree/main/src/components/atoms"
    click Molecules "https://github.com/mikansc/connectlab/tree/main/src/components/molecules"
    click Organisms "https://github.com/mikansc/connectlab/tree/main/src/components/organisms"
    click Templates "https://github.com/mikansc/connectlab/tree/main/src/components/templates"
    click Pages "https://github.com/mikansc/connectlab/tree/main/src/components/pages"
    click Router "https://github.com/mikansc/connectlab/blob/main/src/routes/Router.jsx"
    click PrivateRoutes "https://github.com/mikansc/connectlab/blob/main/src/routes/PrivateRoutes.jsx"
    click DashboardRoutes "https://github.com/mikansc/connectlab/blob/main/src/routes/DashboardRoutes.jsx"
    click RoutesIndex "https://github.com/mikansc/connectlab/blob/main/src/routes/index.js"
    click Contexts "https://github.com/mikansc/connectlab/blob/main/src/contexts/index.js"
    click Hooks "https://github.com/mikansc/connectlab/tree/main/src/hooks"
    click AxiosFactory "https://github.com/mikansc/connectlab/blob/main/src/services/http/factories/axiosInstanceFactory.js"
    click HTTPCore "https://github.com/mikansc/connectlab/blob/main/src/services/http/httpService.js"
    click Adapters "https://github.com/mikansc/connectlab/tree/main/src/services/http/adapters"
    click Services "https://github.com/mikansc/connectlab/tree/main/src/services/http"
    click LocalStorage "https://github.com/mikansc/connectlab/blob/main/src/services/local/storageService.js"
    click I18nIndex "https://github.com/mikansc/connectlab/blob/main/src/i18n/index.js"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366d6,color:#0366d6
    classDef state fill:#E6FFEA,stroke:#29A745,color:#1B6B2D
    classDef svc fill:#FFF4E5,stroke:#D97706,color:#B45309
    classDef storage fill:#F3E8FF,stroke:#8B5CF6,color:#6D28D9
    classDef external fill:#E5E7EB,stroke:#6B7280,color:#374151,stroke-dasharray: 5 5
    classDef infra fill:#FFE4E6,stroke:#DB2777,color:#9D174D
```
