# yukionishi1129/shop-review architecture

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

- Interactive diagram: https://gitdiagram.com/yukionishi1129/shop-review
- Repository: https://github.com/yukionishi1129/shop-review

## Overview

##### Project type and purpose
- This is a full-stack, cross-platform mobile application.
- Frontend: a React Native (Expo) app located under `shop-review-app`.
- Backend: Firebase services plus a set of Cloud Functions under `shop-review-firebase`.
- Purpose: allow users to browse shops, search reviews, authenticate, and submit reviews. Uses Firestore as the primary data store and Algolia for performant search.

##### File structure
- Top-level folders:
- assets – sample images for demo.
- shop-review-app – React Native client.
- shop-review-firebase – Firebase project with Cloud Functions and seed data.
- Client layers:
- src/components – UI components (Button, StarInput, ReviewItem, etc.).
- src/screens – screen components (AuthScreen, HomeScreen, SearchScreen, etc.).
- src/navigation – React Navigation stacks & tabs.
- src/contexts – React Contexts for user & reviews state.
- src/lib – wrappers for Firebase SDK, Algolia search client, image picker.
- Backend layers:
- functions/src/index.ts – Cloud Functions entry points (e.g., Firestore triggers).
- functions/src/scripts/importShops.ts – one-off script to seed Firestore.
- seed/shops.json – initial shop data.
- Config / infra files:
- firebase.json & .firebaserc – Firebase project config.
- app.json, babel.config.js, tsconfig.json, package.json – client build/deploy config.

##### Extract insights from README
- Project demo for a Udemy course: “React Native と Firebase で作る iOS/Android アプリ：お店レビューアプリ”
- Data model: shops in Firestore, each with name, place, imageUrl, score.
- Cloud Functions likely index Firestore data into Algolia for search.

##### Main components
a. Mobile Client (Expo/React Native)
- UI Layer (components & screens)
- Navigation Layer (AppNavigator → HomeStack, MainTab)
- State Management (UserContext, ReviewsContext)
- Service Layer (Firebase & Algolia wrappers)
b. Firebase Backend
- Authentication Service (email/password auth via Firebase Auth)
- Firestore Database (collections: shops, reviews, users)
- Firebase Cloud Functions
- HTTP triggers or callable functions (if any)
- Firestore triggers to sync data to Algolia
- Data-import script for initial seeding
c. External Services
- Algolia Search Index (for fast search queries)
d. Optional: Storage (if images are stored in Firebase Storage) – in this repo images are pre-hosted.

##### Relationships and interactions
- Mobile Client → Firebase Auth: sign-in/up → returns JWT
- Mobile Client → Firestore directly (via Firebase SDK) to read/write shops & reviews
- Mobile Client → Algolia (directly via REST/SDK) for search (wrapped in `src/lib/algolia.ts`)
- Firestore write triggers Cloud Functions → update Algolia index
- Seed script → Firestore bulk import shops

##### Architectural patterns & design principles
- Separation of concerns: UI / navigation / context / service wrappers
- Event-driven backend: Firestore triggers sync to search index
- Single repository monorepo: client & backend share TS types
- Use of Context API for global state (user, reviews)
- Modular services: each external integration has its own lib file

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile App (Expo/React Native)"
        direction TB
        App["React Native App"]:::client
        subgraph UI_Layer
            direction TB
            Components["UI Components"]:::client
            Screens["Screens"]:::client
        end
        Navigation["Navigation Layer"]:::client
        Context["State Management (Contexts)"]:::client
        subgraph "Service Layer"
            direction TB
            FirebaseWrapper["Firebase SDK wrapper"]:::client
            AlgoliaWrapper["Algolia client wrapper"]:::client
            ImagePicker["Image Picker wrapper"]:::client
        end
        Config["Client Config\napp.json, babel.config.js,\ntsconfig.json, package.json"]:::client
    end

    subgraph "Firebase Cloud"
        direction TB
        Auth["Firebase Auth"]:::cloud
        Firestore["Firestore\n(shops, reviews, users)"]:::cloud
        subgraph "Cloud Functions"
            direction TB
            CFIndex["Functions Entry Point\nindex.ts"]:::functions
            CFSync["Firestore Triggers\n(sync to Algolia)"]:::functions
            ImportScript["Import Script\nimportShops.ts"]:::functions
            Types["Type Definitions"]:::functions
        end
        ConfigFB["Firebase Config\nfirebase.json, .firebaserc"]:::cloud
    end

    subgraph "External Services"
        direction TB
        Algolia["Algolia Search API"]:::external
    end

    App -->|Authenticate| Auth
    App -->|Read/Write Data| Firestore
    App -->|Search Queries| Algolia
    Firestore -->|onWrite Triggers| CFSync
    CFSync -->|Update Index| Algolia
    ImportScript -->|Seed Data| Firestore
    CFIndex -.-> Types

    click App "https://github.com/yukionishi1129/shop-review/tree/master/shop-review-app/"
    click Components "https://github.com/yukionishi1129/shop-review/tree/master/shop-review-app/src/components/"
    click Screens "https://github.com/yukionishi1129/shop-review/tree/master/shop-review-app/src/screens/"
    click Navigation "https://github.com/yukionishi1129/shop-review/tree/master/shop-review-app/src/navigation/"
    click Context "https://github.com/yukionishi1129/shop-review/tree/master/shop-review-app/src/contexts/"
    click FirebaseWrapper "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-app/src/lib/firebase.ts"
    click AlgoliaWrapper "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-app/src/lib/algolia.ts"
    click ImagePicker "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-app/src/lib/image-picker.ts"
    click Config "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-app/app.json"
    click CFIndex "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-firebase/functions/src/index.ts"
    click CFSync "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-firebase/functions/src/index.ts"
    click ImportScript "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-firebase/functions/src/scripts/importShops.ts"
    click Types "https://github.com/yukionishi1129/shop-review/tree/master/shop-review-firebase/functions/src/types/"
    click ConfigFB "https://github.com/yukionishi1129/shop-review/blob/master/shop-review-firebase/firebase.json"

    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef cloud fill:#FFA500,stroke:#333,stroke-width:1px
    classDef functions fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:1px
```
