# youssef-emad347/cs303-project architecture

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

- Interactive diagram: https://gitdiagram.com/youssef-emad347/cs303-project
- Repository: https://github.com/youssef-emad347/cs303-project

## Overview

##### Project Type and Purpose
- BooXtore is a full-stack, cross-platform (iOS, Android, Web) bookstore application built with Expo/React Native (using the new file-based routing in `/app`) and backed by Firebase services.
- Its goal is to allow end‐users to browse, search, and purchase books, while administrators can manage inventory, orders, and customers—all through the same codebase.

##### File-Structure Analysis
- Top-Level Configuration
- `.expo/`, `app.json`, `eas.json`: Expo project and build settings.
- `tsconfig.json`, `package.json`, `global.d.ts`: TypeScript and dependency config.
- Frontend Code (`app/`, `components/`, `assets/`)
- `app/`: Expo Router pages (tabs, layouts, auth, screens, dynamic routes for books/authors).
- `components/`: Reusable UI blocks (cards, lists, buttons, header, map, search bar).
- `assets/`: Fonts, images for UI.
- Service Layer (`services/`)
- Abstractions for calls: `authServices.ts`, `bookService.ts`, `cartServices.ts`, `wishlistServices.ts`.
- Firebase Integration (`firebase/`)
- Configuration (`firebaseConfig.js`), initialization (`firebase.js`, `firebaseBooks.js`), custom logic (`creditService.ts`).
- Data-Seeding Scripts (`src/`)
- Node scripts using `axios.js` to fetch or seed authors & books into Firebase—used offline for initial data population.
- Utilities (`utils/`)
- Shared constants, TypeScript models, types.

##### README Insights
- Core features: user browsing, detailed book pages, cart & checkout, wishlist, user profiles, admin panel.
- Tech stack: Expo/React Native, Firebase (Auth + Firestore), TypeScript.

##### Detailed Capture of Architectural Elements
- Include:
- File-based routing structure (tab navigator, stack screens)
- Reusable component blocks & their dependencies on services
- Auth flow: login/signup screens → `authServices.ts` → Firebase Auth
- Book data flow: home/categories → `bookService.ts` → Firestore (books)
- Cart & wishlist flows via `cartServices.ts` and `wishlistServices.ts`
- Payment/credit logic in `creditService.ts` (if actual gateway integrated)
- Data seeding scripts as a separate pipeline
- Build pipeline: EAS → app store/web

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer (UI)
    subgraph "Presentation Layer"
        direction TB
        Client["Expo/React Native Client"]:::ui
        subgraph "File-based Routing (app/)"
            direction TB
            TabsLayout["_layout.tsx (Tabs Navigator)"]:::ui
            Login["Login Screen"]:::ui
            Signup["Signup Screen"]:::ui
            ForgetPwd["ForgetPassword Screen"]:::ui
            BookDetail["Book Detail Screen"]:::ui
            AuthorDetail["Author Detail Screen"]:::ui
            AdminPanel["Admin Panel Screen"]:::ui
            SearchScreen["Search Screen"]:::ui
            CartTab["Cart Tab Screen"]:::ui
            Checkout["Checkout Screen"]:::ui
            Wishlist["Wishlist Screen"]:::ui
            MapsScreen["Maps Screen"]:::ui
            ChatScreen["Chat Screen"]:::ui
        end
        subgraph "Reusable UI Components (components/)"
            direction TB
            BookCard["BookCard"]:::ui
            AuthorCard["AuthorCard"]:::ui
            SearchBar["SearchBar"]:::ui
            MapComponent["Map Component"]:::ui
        end
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        AuthService["authServices.ts"]:::service
        BookService["bookService.ts"]:::service
        CartService["cartServices.ts"]:::service
        WishlistService["wishlistServices.ts"]:::service
    end

    %% Backend/Data Layer
    subgraph "Firebase Backend"
        direction TB
        FirebaseAuth["Firebase Auth"]:::db
        Firestore["Cloud Firestore"]:::db
        CreditService["creditService.ts"]:::service
    end

    %% External Services
    subgraph "External Services"
        direction TB
        GoogleMaps["Google Maps API"]:::external
        PaymentGateway["Payment Gateway"]:::external
    end

    %% Data Seeding Pipeline
    subgraph "Data Seeding Pipeline (src/)"
        direction TB
        Axios["axios.js"]:::service
        GetAuthors["getAuthors.ts"]:::service
        SetAuthors["setAuthors.ts"]:::service
        SeedBooks["seedBooks.ts"]:::service
        UpdateBooks["updateBooks.ts"]:::service
    end

    %% Build & Deployment
    EAS["EAS (Expo Application Services)"]:::external

    %% Relationships
    Client -->|uses routing| TabsLayout
    TabsLayout --> Login & Signup & ForgetPwd & BookDetail & AuthorDetail & CartTab
    TabsLayout --> SearchScreen & Wishlist & MapsScreen & ChatScreen & AdminPanel & Checkout

    Login -->|calls| AuthService
    Signup -->|calls| AuthService
    ForgetPwd -->|calls| AuthService
    AdminPanel -->|calls| AuthService

    BookDetail & SearchScreen -->|calls| BookService
    CartTab -->|calls| CartService
    Checkout -->|calls| CartService
    Wishlist -->|calls| WishlistService

    MapsScreen -->|renders| MapComponent
    MapComponent -->|requests| GoogleMaps

    ChatScreen -->|uses| srcChat
    srcChat((chat.js)) -->|reads/writes| Firestore

    Checkout -->|invokes| CreditService
    CreditService -->|processes| PaymentGateway

    AuthService -->|auth ops| FirebaseAuth
    BookService & CartService & WishlistService -->|CRUD ops| Firestore

    Axios & GetAuthors & SetAuthors & SeedBooks & UpdateBooks -->|batch writes| Firestore

    EAS -->|builds| Client

    %% Click Events
    click Client "https://github.com/youssef-emad347/cs303-project/tree/main/app/"
    click TabsLayout "https://github.com/youssef-emad347/cs303-project/blob/main/app/(tabs)/_layout.tsx"
    click Login "https://github.com/youssef-emad347/cs303-project/blob/main/app/auth/login.tsx"
    click Signup "https://github.com/youssef-emad347/cs303-project/blob/main/app/auth/signup.tsx"
    click ForgetPwd "https://github.com/youssef-emad347/cs303-project/blob/main/app/auth/forgetPassword.tsx"
    click BookDetail "https://github.com/youssef-emad347/cs303-project/blob/main/app/book/[id].tsx"
    click AuthorDetail "https://github.com/youssef-emad347/cs303-project/blob/main/app/author/[id].tsx"
    click AdminPanel "https://github.com/youssef-emad347/cs303-project/blob/main/app/screens/Admin.tsx"
    click SearchScreen "https://github.com/youssef-emad347/cs303-project/blob/main/app/screens/search.tsx"
    click CartTab "https://github.com/youssef-emad347/cs303-project/blob/main/app/(tabs)/cart.tsx"
    click Checkout "https://github.com/youssef-emad347/cs303-project/blob/main/app/screens/cardDetails.tsx"
    click Wishlist "https://github.com/youssef-emad347/cs303-project/blob/main/app/screens/wishlist.tsx"
    click MapsScreen "https://github.com/youssef-emad347/cs303-project/blob/main/app/screens/maps.tsx"
    click MapComponent "https://github.com/youssef-emad347/cs303-project/blob/main/components/map.tsx"
    click ChatScreen "https://github.com/youssef-emad347/cs303-project/blob/main/app/screens/chat.tsx"
    click srcChat "https://github.com/youssef-emad347/cs303-project/blob/main/src/chat.js"
    click BookCard "https://github.com/youssef-emad347/cs303-project/blob/main/components/BookCard.tsx"
    click AuthorCard "https://github.com/youssef-emad347/cs303-project/blob/main/components/AuthorCard.tsx"
    click SearchBar "https://github.com/youssef-emad347/cs303-project/blob/main/components/SearchBar.tsx"
    click AuthService "https://github.com/youssef-emad347/cs303-project/blob/main/services/authServices.ts"
    click BookService "https://github.com/youssef-emad347/cs303-project/blob/main/services/bookService.ts"
    click CartService "https://github.com/youssef-emad347/cs303-project/blob/main/services/cartServices.ts"
    click WishlistService "https://github.com/youssef-emad347/cs303-project/blob/main/services/wishlistServices.ts"
    click FirebaseAuth "https://github.com/youssef-emad347/cs303-project/blob/main/firebase/firebase.js"
    click Firestore "https://github.com/youssef-emad347/cs303-project/blob/main/firebase/firebaseBooks.js"
    click CreditService "https://github.com/youssef-emad347/cs303-project/blob/main/firebase/creditService.ts"
    click Axios "https://github.com/youssef-emad347/cs303-project/blob/main/src/axios.js"
    click GetAuthors "https://github.com/youssef-emad347/cs303-project/blob/main/src/getAuthors.ts"
    click SetAuthors "https://github.com/youssef-emad347/cs303-project/blob/main/src/setAuthors.ts"
    click SeedBooks "https://github.com/youssef-emad347/cs303-project/blob/main/src/seedBooks.ts"
    click UpdateBooks "https://github.com/youssef-emad347/cs303-project/blob/main/src/updateBooks.ts"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
