# ujjwalgoyal19/oggy architecture

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

- Interactive diagram: https://gitdiagram.com/ujjwalgoyal19/oggy
- Repository: https://github.com/ujjwalgoyal19/oggy

## Overview

##### Project Type and Purpose
- This is a single‐page web application (“oggy-web v1”) housed in an Nx monorepo.
- It’s built with React + TypeScript, uses Redux for state management, Cypress for e2e tests, Jest for unit tests, Storybook for component previews, and integrates Firebase for external auth.
- Its domain revolves around restaurant discovery/search (autocomplete, filters, restaurant and locality services).

##### File Structure
- Top‐level config: Nx workspace (nx.json, workspace.json), TypeScript base configs (tsconfig.base.json), Jest, ESLint, Babel, Storybook, Prettier.
- apps/oggy-web/oggy-v1: the core React app.
- src/app/components: UI organized via atomic design (atoms, molecules, organisms, templates).
- src/app/pages & routes.tsx: page‐level routing.
- src/app/service: API wrappers for restaurant, search, filters, locality, autocomplete.
- src/app/store: Redux slices for filter, search, restaurant.
- src/app/external-login: Firebase‐based auth flows (components, pages, services).
- apps/oggy-web/oggy-v1-e2e: Cypress project for end‐to‐end testing.
- .storybook: Storybook config for component development.
- libs: reserved for shared libraries (currently empty).

a. Main Components
- Browser / Client
- React SPA (UI layer)
- Redux Store (State layer)
- Service Layer (API adapters)
- External REST APIs (restaurant data provider, geolocation API)
- Firebase Auth (Identity provider)
- Dev & Test Tools (Storybook, Jest, Cypress)
b. Relationships & Interactions
1. User interacts with UI → React components dispatch Redux actions.
2. Redux middleware calls Service Layer.
3. Service Layer communicates with external REST endpoints (e.g., restaurant API, geo API).
4. Firebase Auth service handles sign‑in/up flows (via firebaseConfig).
5. API responses update Redux store → UI re‑renders.
6. Storybook subscribes to component library for isolated component development.
7. Jest runs unit tests against components, hooks, slices.
8. Cypress executes e2e tests against the deployed SPA.
c. Architectural Patterns & Principles
- Atomic design in UI (atoms → molecules → organisms → templates → pages).
- Unidirectional data flow (React → Redux → Services → API → Redux → React).
- Monorepo structure with Nx for project orchestration and shared libs.
- Separation of concerns: UI, state management, side‑effect handling, and external services.
d. Key Technologies
- React + TypeScript
- Redux Toolkit slices
- React Router (routes.tsx)
- Axios or fetch (in service modules)
- Firebase SDK
- Storybook, Jest, Cypress
- Nx build/test orchestration

##### Essential Details to Capture
- The atomic decomposition of the UI.
- The Redux slices and how they map to service calls.
- The external authentication boundary (Firebase).
- The distinction between unit testing (Jest), component previews (Storybook), and e2e testing (Cypress).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Browser / Client"]:::external
        React["React SPA"]:::ui
        AtomicGroup["Atomic Components"]:::ui
        Atoms["Atoms"]:::ui
        Molecules["Molecules"]:::ui
        Organisms["Organisms"]:::ui
        Templates["Templates"]:::ui
        Routes["Page Routing"]:::ui
        Pages["Page Components"]:::ui
    end

    %% State Management Layer
    subgraph "State Management Layer"
        direction TB
        Store["Redux Store"]:::state
        FilterSlice["Filter Slice"]:::state
        SearchSlice["Search Slice"]:::state
        RestaurantSlice["Restaurant Slice"]:::state
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        AutocompleteService["Autocomplete Service"]:::service
        FiltersService["Filters Service"]:::service
        LocalityService["Locality Service"]:::service
        RestaurantService["Restaurant Service"]:::service
        SearchService["Search Service"]:::service
    end

    %% External Services
    subgraph "External Services"
        direction TB
        RestAPIs["Restaurant & Geo APIs"]:::external
        FirebaseAuth["Firebase Auth"]:::external
    end

    %% Dev & Test Tools
    subgraph "Dev & Test Tools"
        direction TB
        Nx["Nx Monorepo"]:::dev
        Storybook["Storybook"]:::dev
        Jest["Jest Tests"]:::dev
        Cypress["Cypress E2E"]:::dev
    end

    %% Presentation connections
    Browser -->|"loads"| React
    React -->|"uses atoms/molecules"| AtomicGroup
    AtomicGroup --> Atoms
    AtomicGroup --> Molecules
    AtomicGroup --> Organisms
    AtomicGroup --> Templates
    React -->|"routes via React Router"| Routes
    Routes --> Pages

    %% UI to State
    React -->|"dispatch action"| Store
    Store --> FilterSlice
    Store --> SearchSlice
    Store --> RestaurantSlice

    %% State to Service
    FilterSlice -->|"calls"| FiltersService
    SearchSlice -->|"calls"| SearchService
    RestaurantSlice -->|"calls"| RestaurantService

    %% Service to External APIs
    AutocompleteService -->|"HTTP GET /autocomplete"| RestAPIs
    FiltersService -->|"HTTP GET /filters"| RestAPIs
    LocalityService -->|"HTTP GET /locality"| RestAPIs
    RestaurantService -->|"HTTP GET /restaurants"| RestAPIs
    SearchService -->|"HTTP GET /search"| RestAPIs

    %% Firebase Auth flows
    React -->|"sign-in flow"| FirebaseAuth
    FirebaseAuth -->|"auth SDK"| FirebaseAuth

    %% Dev Tools interactions
    AtomicGroup -->|"stories"| Storybook
    FilterSlice -->|"unit tests"| Jest
    SearchSlice -->|"unit tests"| Jest
    RestaurantSlice -->|"unit tests"| Jest
    React -->|"unit tests"| Jest
    Browser -->|"e2e tests"| Cypress
    Nx --> Storybook
    Nx --> Jest
    Nx --> Cypress

    %% Service slice extra
    AutocompleteService --> Store
    RestAPIs --> Store
    FirebaseAuth --> Store

    %% Click Events
    click React "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/app.tsx"
    click Atoms "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1/src/app/components/atoms"
    click Molecules "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1/src/app/components/molecules"
    click Organisms "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1/src/app/components/organisms"
    click Templates "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1/src/app/components/templates"
    click Routes "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/routes.tsx"
    click Pages "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1/src/app/pages"
    click Store "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/store/index.ts"
    click FilterSlice "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/store/filter/index.slice.ts"
    click SearchSlice "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/store/search/index.slice.ts"
    click RestaurantSlice "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/store/restaurant/index.slice.ts"
    click AutocompleteService "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/service/autocomplete.service.ts"
    click FiltersService "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/service/filters.service.ts"
    click LocalityService "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/service/locality.service.ts"
    click RestaurantService "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/service/restaurant.service.ts"
    click SearchService "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/service/search.service.ts"
    click AuthComponents "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1/src/app/external-login/components"
    click AuthPages "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1/src/app/external-login/pages"
    click FirebaseService "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/external-login/service/firebase.service.js"
    click FirebaseConfig "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/src/app/external-login/service/firebaseConfig.js"
    click E2E "https://github.com/ujjwalgoyal19/oggy/tree/main/apps/oggy-web/oggy-v1-e2e/src/e2e"
    click JestAppConfig "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/jest.config.ts"
    click JestRootConfig "https://github.com/ujjwalgoyal19/oggy/blob/main/jest.config.ts"
    click StorybookMain "https://github.com/ujjwalgoyal19/oggy/blob/main/.storybook/main.js"
    click StorybookTS "https://github.com/ujjwalgoyal19/oggy/blob/main/.storybook/tsconfig.json"
    click NxConfig1 "https://github.com/ujjwalgoyal19/oggy/blob/main/nx.json"
    click NxConfig2 "https://github.com/ujjwalgoyal19/oggy/blob/main/workspace.json"
    click ProjectApp "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1/project.json"
    click ProjectE2E "https://github.com/ujjwalgoyal19/oggy/blob/main/apps/oggy-web/oggy-v1-e2e/project.json"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#2B6CB0,color:#2B6CB0;
    classDef state fill:#E6FFFA,stroke:#2C7A7B,color:#2C7A7B;
    classDef service fill:#F0FFF4,stroke:#276749,color:#276749;
    classDef external fill:#FFFAF0,stroke:#DD6B20,color:#DD6B20;
    classDef dev fill:#EDF2F7,stroke:#4A5568,color:#4A5568
```
