# danielsrs/slaps_and_kisses architecture

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

- Interactive diagram: https://gitdiagram.com/danielsrs/slaps_and_kisses
- Repository: https://github.com/danielsrs/slaps_and_kisses

## Overview

##### Project type and purpose
- This is a full-stack, multi-package monorepo (managed via Yarn workspaces) for an electric-car charging application.
- apps/car: A React-based client (likely React Native or React Web) that provides pages for user registration, station reservation, charging sessions, and recommendations.
- apps/server: A TypeScript/Node.js HTTP API (Express-style router) that handles car and station registration, session start/end, reservations, payments, and station suggestions using an in-memory data store and schema validation.
- apps/shared: A library of shared React components, utility functions, API-client code, storage adapters, and a TCP/MQTT helper that’s consumed by apps/car.
- docker-compose.yml + mosquitto/: Defines a local MQTT broker (Mosquitto) and server container for real-time messaging around charging events.

##### File structure
- Top-level folders:
- apps/car – client UI code (Pages/, components/, navigation, Redux-style store).
- apps/server – backend code (routes/, schemas/, utils/, server entrypoints, Dockerfile).
- apps/shared – shared UI components, API client, storage and TCP/MQTT libs, TS configs.
- Configuration and orchestration:
- docker-compose.yml – brings up the server and Mosquitto broker.
- tsconfig.* and package.json workspaces – unify build and type checking across all packages.
- scripts/ – lint, format, and type-check workflows.

##### Extract additional insights from the README
- The README is minimal (“slaps_and_kisses”) but the CONTRIBUTING.md explains TypeScript setup across the monorepo.

##### Essential elements
- Don’t overcomplicate with every single file—focus on the three logical modules (car, server, shared) plus the MQTT broker.
- Data persistence layers or storage only if they’re external; here the backend uses in-memory data and the client uses local file storage.
- Both synchronous (HTTP) and asynchronous (MQTT) flows.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Monorepo and Developer Context
    subgraph "Developer Machine" 
        direction TB
        DevTools["Monorepo Workspace"]:::monorepo
        DevTools -->|"yarn build/test/lint"| CarApp
        DevTools -->|"yarn build/test/lint"| SharedLib
        DevTools -->|"yarn build/test/lint"| ServerAPI
    end

    %% Main Packages
    subgraph "Monorepo Workspace"
        direction TB

        subgraph "Client App (apps/car)" 
            direction TB
            CarApp["Car App (React)"]:::client
            subgraph "Features"
                direction TB
                Pages["Pages"]:::client
                Nav["Navigation"]:::client
                Store["Store"]:::client
                Utils["Utilities"]:::client
                Routes["Routes"]:::client
            end
            CarApp --> Pages
            CarApp --> Nav
            CarApp --> Store
            CarApp --> Utils
            CarApp --> Routes
        end

        subgraph "Shared Library (apps/shared)" 
            direction TB
            SharedLib["Shared Library"]:::shared
            subgraph "Shared Modules"
                direction TB
                APIClient["API Client"]:::shared
                UIComp["UI Components"]:::shared
                Storage["Storage Adapters"]:::shared
                TCP["TCP/MQTT Helper"]:::shared
            end
            SharedLib --> APIClient
            SharedLib --> UIComp
            SharedLib --> Storage
            SharedLib --> TCP
        end

        subgraph "Backend API (apps/server)" 
            direction TB
            ServerAPI["Backend API (Node/Express)"]:::server
            subgraph "Server Modules"
                direction TB
                BRoutes["Routes"]:::server
                Schemas["Schemas"]:::server
                DataStore["In-Memory Data Store"]:::server
                UtilsBE["Utilities"]:::server
                Entry["Entry Points"]:::server
            end
            ServerAPI --> BRoutes
            ServerAPI --> Schemas
            ServerAPI --> DataStore
            ServerAPI --> UtilsBE
            ServerAPI --> Entry
        end
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        DockerCompose["Docker Compose"]:::infra
        MQTTBroker["MQTT Broker (Mosquitto)"]:::infra
    end

    %% Runtime Interactions
    UserDevice["User Device"]:::client
    UserDevice -->|"HTTP REST"| CarApp
    UserDevice -->|"MQTT SUBSCRIBE 'charging/+/status'"| MQTTBroker

    CarApp -->|"uses Shared Library"| SharedLib
    CarApp -->|"POST /reserve, /startCharging"| ServerAPI
    ServerAPI -->|"MQTT PUBLISH events"| MQTTBroker

    %% Click Events
    click CarApp "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/car"
    click Pages "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/car/src/Pages"
    click Nav "https://github.com/danielsrs/slaps_and_kisses/blob/main/apps/car/src/tab-navigation.tsx"
    click Store "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/car/src/store"
    click Utils "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/car/src/utils"
    click Routes "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/car/src/routes"
    click SharedLib "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/shared"
    click APIClient "https://github.com/danielsrs/slaps_and_kisses/blob/main/apps/shared/src/api/client.ts"
    click UIComp "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/shared/src/components"
    click Storage "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/shared/src/libs/storage"
    click TCP "https://github.com/danielsrs/slaps_and_kisses/blob/main/apps/shared/src/tcp/tcp.ts"
    click ServerAPI "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/server"
    click BRoutes "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/server/src/routes"
    click Schemas "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/server/src/schemas"
    click DataStore "https://github.com/danielsrs/slaps_and_kisses/blob/main/apps/server/src/data/data.ts"
    click UtilsBE "https://github.com/danielsrs/slaps_and_kisses/tree/main/apps/server/src/utils"
    click Entry "https://github.com/danielsrs/slaps_and_kisses/blob/main/apps/server/src/server.ts"
    click MQTTBroker "https://github.com/danielsrs/slaps_and_kisses/blob/main/mosquitto/config/mosquitto.conf"
    click DockerCompose "https://github.com/danielsrs/slaps_and_kisses/blob/main/docker-compose.yml"
    click DevTools "https://github.com/danielsrs/slaps_and_kisses/tree/main/scripts/"

    %% Styles
    classDef client fill:#c1f0c1,stroke:#2e7d32,stroke-width:2px
    classDef shared fill:#fff3c2,stroke:#f9a825,stroke-width:2px
    classDef server fill:#c2e9ff,stroke:#0277bd,stroke-width:2px
    classDef infra fill:#e0e0e0,stroke:#616161,stroke-width:2px
    classDef monorepo fill:#f3e5f5,stroke:#6a1b9a,stroke-width:2px
```
