# amineelouadi/wordwise-dictionary architecture

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

- Interactive diagram: https://gitdiagram.com/amineelouadi/wordwise-dictionary
- Repository: https://github.com/amineelouadi/wordwise-dictionary

## Overview

##### Project type and purpose
- This is a full-stack web application (“WordWise”) consisting of a React+TypeScript frontend and an Express.js backend.
- Purpose: Provide dictionary lookups by querying the Free Dictionary API, track search history in memory, and enable theme toggling.

##### File structure
- Top-level directories:
- client/ – React app (components, pages, hooks, UI library wrappers)
- server/ – Express server (entry point, API routes, in-memory storage)
- shared/ – Common schema definitions for request/response validation
- Configuration files: tsconfig.json, tailwind.config.ts, drizzle.config.ts, vite.config.ts, postcss.config.js
- Build & dev scripts: package.json, vite integration in server/vite.ts

##### README for additional insights
- Confirms tech stack: React + TailwindCSS + shadcn/ui, Express/Node, React Query
- Describes features: word search, detailed info display, audio pronunciation, search history, dark/light theme
- No external database – uses in-memory storage on the server

a. Main components:
- User’s Web Browser (client) running the React app
- Static Asset Server / Vite Dev Server (serves HTML/CSS/JS)
- React Application Layers:
– UI Components (shadcn/ui, TailwindCSS)
– State Management (React Query via queryClient.ts)
- Backend Express Server (API routes)
- In-Memory Storage Module (server/storage.ts)
- Shared Schema Layer (shared/schema.ts) for type safety & validation
- External Free Dictionary API (https://api.dictionaryapi.dev/)
b. Relationships & data flow:
1. Browser → (HTTP GET) → Static Asset Server → serves index.html & bundle.js
2. React App → (REST/Fetch via React Query) → Express API endpoint (/lookup/:word)
3. Express Route Handler → (calls) → In-Memory Storage to log/retrieve search history
4. Express Route Handler → (HTTP request) → External Dictionary API → receives word data
5. Express → (JSON response) → React Query → UI renders results (meanings, phonetics, audio)
c. Architectural patterns & design principles:
- Layered architecture: separation of presentation (UI), application logic (React Query + Express routes), and data (in-memory storage + external API).
- DRY & reusability: UI primitives (client/src/components/ui) abstract common design patterns.
- Configuration-driven build: Vite handles dev vs. production, integrated into the Express server.
d. Key technologies & libraries:
- Frontend: React, TypeScript, TailwindCSS, shadcn/ui, React Query
- Backend: Node.js, Express.js, Vite (dev), in-memory storage
- Shared: Zod or a similar schema library (in shared/schema.ts) for validation
- Tooling: Drizzle (drizzle.config.ts) if/when migrating to a persistence layer

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Frontend Layer"
    Browser["User Browser"]:::client
    ViteDev["Vite Dev Server"]:::client
    Main["Main Entry (main.tsx)"]:::client
    ReactEntry["App.tsx"]:::client
    Pages["Pages\nHome.tsx\nnot-found.tsx"]:::client
    UIComp["UI Components\nshadcn/ui + Tailwind"]:::client
    CustomUI["Custom UI Components"]:::client
    QueryClient["React Query Client"]:::client
    Utils["Utility Functions"]:::client
    UseDict["useDictionary Hook"]:::client
    UseMobile["use-mobile Hook"]:::client
    UseToast["use-toast Hook"]:::client
    GlobalCSS["Global Stylesheet\nindex.css"]:::client
  end

  Browser -->|"HTTP GET HTML/JS/CSS"| ViteDev
  ViteDev --> Main
  Main --> ReactEntry
  ReactEntry --> UIComp
  ReactEntry --> Pages
  ReactEntry --> QueryClient
  ReactEntry --> Utils
  ReactEntry --> UseDict
  ReactEntry --> GlobalCSS
  ReactEntry --> CustomUI
  ReactEntry --> UseMobile
  ReactEntry --> UseToast

  subgraph "Backend Layer"
    ViteIntegration["Vite Integration\n(vite.ts)"]:::server
    ExpressEntry["Express Server\n(index.ts)"]:::server
    Routes["API Route\n/lookup/:word"]:::server
    Storage["In-Memory Storage\n(storage.ts)"]:::server
    Schema["Shared Schema\n(schema.ts)"]:::server
  end

  UseDict -->|"fetch /lookup/:word"| Routes
  ViteIntegration --> ExpressEntry
  ExpressEntry --> Routes
  Routes --> Schema
  Routes --> Storage
  Routes --> ExternalAPI
  Storage --> Routes
  ExternalAPI --> Routes
  Routes --> UseDict

  ExternalAPI["Free Dictionary API\n(api.dictionaryapi.dev)"]:::external

  subgraph "Configuration"
    Tailwind["tailwind.config.ts"]:::config
    PostCSS["postcss.config.js"]:::config
    Drizzle["drizzle.config.ts"]:::config
    TSConfig["tsconfig.json"]:::config
    ViteConfig["vite.config.ts"]:::config
    PackageJSON["package.json"]:::config
  end

  classDef client fill:#d4f1be,stroke:#333,stroke-width:1px
  classDef server fill:#bee3f8,stroke:#333,stroke-width:1px
  classDef external fill:#fed7aa,stroke:#333,stroke-width:1px
  classDef config fill:#e2e8f0,stroke:#333,stroke-width:1px

  click ReactEntry "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/App.tsx"
  click Pages "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/pages/Home.tsx"
  click Pages "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/pages/not-found.tsx"
  click UIComp "https://github.com/amineelouadi/wordwise-dictionary/tree/master/client/src/components/ui/"
  click CustomUI "https://github.com/amineelouadi/wordwise-dictionary/tree/master/client/src/components/"
  click QueryClient "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/lib/queryClient.ts"
  click Utils "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/lib/utils.ts"
  click UseDict "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/hooks/useDictionary.ts"
  click UseMobile "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/hooks/use-mobile.tsx"
  click UseToast "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/hooks/use-toast.ts"
  click GlobalCSS "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/index.css"
  click Main "https://github.com/amineelouadi/wordwise-dictionary/blob/master/client/src/main.tsx"
  click ViteIntegration "https://github.com/amineelouadi/wordwise-dictionary/blob/master/server/vite.ts"
  click ExpressEntry "https://github.com/amineelouadi/wordwise-dictionary/blob/master/server/index.ts"
  click Routes "https://github.com/amineelouadi/wordwise-dictionary/blob/master/server/routes.ts"
  click Storage "https://github.com/amineelouadi/wordwise-dictionary/blob/master/server/storage.ts"
  click Schema "https://github.com/amineelouadi/wordwise-dictionary/blob/master/shared/schema.ts"
  click Tailwind "https://github.com/amineelouadi/wordwise-dictionary/blob/master/tailwind.config.ts"
  click PostCSS "https://github.com/amineelouadi/wordwise-dictionary/blob/master/postcss.config.js"
  click Drizzle "https://github.com/amineelouadi/wordwise-dictionary/blob/master/drizzle.config.ts"
  click TSConfig "https://github.com/amineelouadi/wordwise-dictionary/blob/master/tsconfig.json"
  click ViteConfig "https://github.com/amineelouadi/wordwise-dictionary/blob/master/vite.config.ts"
  click PackageJSON "https://github.com/amineelouadi/wordwise-dictionary/blob/master/package.json"
```
