# michniks2001/baby-app architecture

> Architecture diagram of the GitHub repository michniks2001/baby-app, 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/michniks2001/baby-app
- Repository: https://github.com/michniks2001/baby-app

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js (v13 App Router).

##### File structure
- Top-level “app” folder: defines routes via Next.js App Router.
- /app/page.js → Home page
- /app/game/page.js → Animal‐sound game
- “components” folder: reusable UI pieces (TextToSpeech, Button, Textarea).
- “lib” folder: utilities (utils.js/ts).
- “public” folder: static assets (animal_images, animal_sounds, shape_images).
- Configs: next.config.mjs, postcss.config.mjs, eslint.config.mjs.
- package.json, jsconfig.json, components.json: dependency & type settings.

##### README for additional insights
- Standard create-next-app boilerplate.
- No custom API routes; relies on static assets and client/server components.
- Uses next/font for font optimization.

a. Main components
- Client Browser (React in the browser)
- Next.js Server (Node.js runtime)
- File-based Router (App Router in “app/”)
- UI Components (in “components/”)
- Utility Layer (in “lib/”)
- Static Asset Store (images & sounds in “public/”)
b. Relationships & interactions
2. Next.js server resolves route via App Router, renders React Server/Client Components.
3. Components fetch static assets (images, sounds) directly from “public/”.
4. Client Components use TextToSpeech component which calls Web Speech API in browser.
5. Utils module provides shared logic (e.g., randomization, scoring).
c. Architectural patterns & design principles
- File-based routing (App Router)
- Component-based UI (React Server + Client components)
- Separation of concerns: Routes vs. Components vs. Utils vs. Static assets
- Progressive enhancement: Server-rendered pages with client interactivity
d. Key technologies & frameworks
- Next.js (App Router)
- React (Server and Client Components)
- Web Speech API (TextToSpeech)
- Node.js (server runtime)
- PostCSS, ESLint, TypeScript (optional)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Browser
    Browser["Client Browser"]:::frontend

    %% Next.js Server
    subgraph "Next.js Server (Node.js)"
        direction TB
        AppRouter["File-based Router (/app)"]:::server
        Layout["Global Layout & Styles"]:::server
        HomePage["Home Page"]:::server
        GamePage["Animal Sound Game"]:::server
        ShapesPage["Shape-matching Game"]:::server
        ReactComponents["React Components"]:::frontend
        TextToSpeech["TextToSpeech Component"]:::frontend
        Button["Button Component"]:::frontend
        Textarea["Textarea Component"]:::frontend
        Utils["Utils Module"]:::server
    end

    %% Static Assets
    subgraph "Static Assets (public/)" 
        direction TB
        AnimalImgs["Animal Images"]:::storage
        AnimalSounds["Animal Sounds"]:::storage
        ShapeImgs["Shape Images"]:::storage
    end

    %% External API
    WebSpeechAPI["Web Speech API"]:::external

    %% Connections
    Browser -->|"GET /, /game, /shapes-game"| AppRouter
    AppRouter -->|"uses layout & styles"| Layout
    AppRouter -->|"routes to"| HomePage
    AppRouter -->|"routes to"| GamePage
    AppRouter -->|"routes to"| ShapesPage
    AppRouter -->|"provides props to"| ReactComponents
    HomePage --> ReactComponents
    GamePage --> ReactComponents
    ShapesPage --> ReactComponents
    ReactComponents -->|"Hydrated JS bundle"| Browser
    ReactComponents -->|"Fetch assets"| AnimalImgs
    ReactComponents -->|"Fetch assets"| AnimalSounds
    ReactComponents -->|"Fetch assets"| ShapeImgs
    ReactComponents -->|"calls utils"| Utils
    ReactComponents --> TextToSpeech
    ReactComponents --> Button
    ReactComponents --> Textarea
    TextToSpeech -->|"synthesizeSpeech"| WebSpeechAPI

    %% Click Events
    click AppRouter "https://github.com/michniks2001/baby-app/tree/main//app"
    click HomePage "https://github.com/michniks2001/baby-app/blob/main//app/page.js"
    click GamePage "https://github.com/michniks2001/baby-app/blob/main//app/game/page.js"
    click ShapesPage "https://github.com/michniks2001/baby-app/blob/main//app/shapes-game/page.js"
    click Layout "https://github.com/michniks2001/baby-app/blob/main//app/layout.js"
    click TextToSpeech "https://github.com/michniks2001/baby-app/blob/main//components/TextToSpeech.js"
    click Button "https://github.com/michniks2001/baby-app/blob/main//components/ui/button.jsx"
    click Textarea "https://github.com/michniks2001/baby-app/blob/main//components/ui/textarea.tsx"
    click Utils "https://github.com/michniks2001/baby-app/blob/main//lib/utils.js"
    click AnimalImgs "https://github.com/michniks2001/baby-app/tree/main//public/animal_images"
    click AnimalSounds "https://github.com/michniks2001/baby-app/tree/main//public/animal_sounds"
    click ShapeImgs "https://github.com/michniks2001/baby-app/tree/main//public/shape_images"

    %% Styles
    classDef frontend fill:#9f6,stroke:#396,stroke-width:1px
    classDef server fill:#6cf,stroke:#069,stroke-width:1px
    classDef storage fill:#fc6,stroke:#f90,stroke-width:1px
    classDef external fill:#f96,stroke:#c30,stroke-width:1px
```
