# saalim-km/bella-imagine-client architecture

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

- Interactive diagram: https://gitdiagram.com/saalim-km/bella-imagine-client
- Repository: https://github.com/saalim-km/bella-imagine-client

## Overview

##### Project type and purpose
- Bella Imagine is a full-stack, single-page web application built in React (with TypeScript) that serves as a photography service marketplace.
- It connects three user roles—clients, photographers (vendors), and admins—offers real-time chat, community forums, booking workflows, AI-driven recommendations, and secure payments via Stripe.

##### File structure
- Top-level files:
- index.html, main.tsx, App.tsx → front-end entry point
- package.json, tsconfig.json, vite.config.ts, tailwind.config.js → build/config
- src/api → axios clients per domain (admin, auth, chat, client, community, vendor)
- src/components, src/pages → React component tree organized by feature (User, Admin, Community, Chat, etc.)
- src/hooks, src/services → data-fetch/service layer, encapsulating API calls and TanStack Query hooks
- src/context, src/store → global state (Redux slices) and React Context (Theme, Socket)
- src/config/socket.ts → WebSocket URL for real-time chat
- src/assets, src/utils, src/lib → static assets, utility functions, and formatters
- Deployment file: vercel.json

##### README for additional insights
- Frontend tech: React+TS, TanStack Query, Redux, Shadcn UI, Tailwind CSS
- External integrations: Google Maps SDK (autocomplete) for location search, Stripe for payments, Google OAuth for authentication
- Role-based access control across clients/vendors/admins
- Real-time collaboration via WebSockets

a. Main components
- Client-side (browser SPA)
- API Gateway / Load Balancer
- Microservice cluster (or API layer) with distinct domain services:
– Auth Service (signup/sign-in, Google OAuth)
– Client Service (client profiles, bookings)
– Vendor Service (vendor profiles, service listings, portfolios)
– Admin Service (category/community/user management)
– Community Service (posts, comments, feeds)
– Chat Service (WebSocket server for real-time messaging)
– Payment Service (Stripe integration, webhooks)
– Wallet Service (transaction history)
- Databases:
– Relational DB (PostgreSQL/MySQL) for core data (users, services, bookings, communities)
– NoSQL/Redis for real-time chat messages and caching
- External Services:
– Google Maps API (location autocomplete, geocoding)
– Stripe Payments & Webhook endpoint
– Google OAuth
b. Relationships and interactions
– Browser SPA communicates via HTTPS to API Gateway
– API Gateway routes requests to respective microservices
– Chat UI opens WebSocket connection to Chat Service (socket.ts)
– Payment Service triggers Stripe Checkout; Stripe sends webhooks back to Payment Service
– Services talk to shared databases or caches
– Redux/TanStack Query on frontend manage state and API calls
c. Architectural patterns/design principles
– Separation of concerns via domain-specific microservices or API modules
– Unidirectional data flow in front end (React → hooks → services → API → store)
– CQRS pattern (read models via TanStack Query, write operations via services)
– Real-time communication via WebSockets
– Role-based access control enforced at API gateway or service layer
d. Key technologies/frameworks
– Frontend: React, TypeScript, Redux Toolkit, TanStack Query, TailwindCSS, Shadcn components
– Backend (assumed): Node.js/Express or similar, WebSocket (socket.io or ws)
– Database: PostgreSQL/MySQL, Redis
– External: Google Maps SDK, Stripe, Google OAuth

##### Elements
- Labels: name each service, database, and external dependency.
- From SPA → API Gateway (HTTP requests)
- From SPA → Chat Service (WebSocket)
- From Payment Service ←→ Stripe (HTTPS + webhook)
- Services → Databases

##### Final advice
- Be exhaustive: represent each domain component (Auth, Client, Vendor, Admin, Community, Chat, Payment, Wallet) separately.
- Data flows precisely: who calls whom, which data stores are used.
- Deployment context (e.g., Vercel for frontend, Kubernetes or VM cluster for backend) at the bottom.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser SPA)"
        React["React SPA"]:::frontend
        Redux["Redux & TanStack Query"]:::frontend
        SocketClient["WebSocket Client"]:::frontend
    end

    %% API Gateway
    API["API Gateway / Load Balancer"]:::backend

    %% Backend Services
    subgraph "Backend Services"
        AuthService["Auth Service"]:::backend
        ClientService["Client Service"]:::backend
        VendorService["Vendor Service"]:::backend
        AdminService["Admin Service"]:::backend
        CommunityService["Community Service"]:::backend
        ChatService["Chat Service"]:::backend
        PaymentService["Payment Service"]:::backend
        WalletService["Wallet Service"]:::backend
    end

    %% Databases & Cache
    subgraph "Databases & Cache"
        Relational["Relational DB (PostgreSQL/MySQL)"]:::database
        Cache["NoSQL/Redis"]:::database
    end

    %% External Services
    Stripe["Stripe Payments"]:::external
    GoogleOAuth["Google OAuth"]:::external
    GoogleMaps["Google Maps API"]:::external

    %% Deployment
    Vercel["Vercel"]:::deployment
    K8s["Kubernetes Cluster"]:::deployment

    %% Connections Frontend to Gateway & Chat
    React --> Redux
    React --> SocketClient
    React -->|HTTPS| API
    Redux -->|queries & mutations| API
    SocketClient -- "ws" --> ChatService

    %% Gateway to Backend Services
    API --> AuthService
    API --> ClientService
    API --> VendorService
    API --> AdminService
    API --> CommunityService
    API --> PaymentService
    API --> WalletService

    %% Services to Databases
    AuthService --> Relational
    ClientService --> Relational
    VendorService --> Relational
    AdminService --> Relational
    CommunityService --> Relational
    WalletService --> Relational
    ChatService --> Cache

    %% External Integrations
    AuthService -->|OAuth| GoogleOAuth
    ClientService -->|Maps Autocomplete| GoogleMaps
    PaymentService -->|HTTPS| Stripe
    Stripe -->|webhook| PaymentService

    %% Deployment links
    Vercel --> React
    K8s --> API
    K8s --> AuthService
    K8s --> ClientService
    K8s --> VendorService
    K8s --> AdminService
    K8s --> CommunityService
    K8s --> ChatService
    K8s --> PaymentService
    K8s --> WalletService

    %% Click Events for component mappings
    click AuthService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/api/auth.axios.ts"
    click AuthService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/auth/authService.ts"
    click AuthService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/auth/googleService.ts"
    click AuthService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/auth/useLogin.ts"
    click AuthService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/auth/useRegister.ts"
    click AuthService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/auth/useGoogleLogin.ts"
    click AuthService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/auth/useLogout.ts"

    click ClientService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/api/client.axios.ts"
    click ClientService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/client/clientService.ts"
    click ClientService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/client/useClient.ts"
    click ClientService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/booking/useBooking.ts"

    click VendorService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/api/vendor.axios.ts"
    click VendorService "https://github.com/saalim-km/bella-imagine-client/tree/main/src/services/vendor"
    click VendorService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/store/slices/vendorSlice.ts"

    click AdminService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/api/admin.axios.ts"
    click AdminService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/admin/adminService.ts"
    click AdminService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/admin/useAllCategory.ts"
    click AdminService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/admin/useClients.ts"
    click AdminService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/admin/useVendor.ts"

    click CommunityService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/api/community.axios.ts"
    click CommunityService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/community/communityService.ts"
    click CommunityService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/community/useCommunity.ts"
    click CommunityService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/community/useInfiniteScroll.ts"

    click ChatService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/api/chat.axios.ts"
    click ChatService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/chat/chatService.ts"
    click ChatService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/config/socket.ts"
    click ChatService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/context/SocketContext.tsx"
    click ChatService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/chat/useChat.ts"
    click ChatService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/chat/useSocketEvents.ts"

    click PaymentService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/payment/paymentService.ts"
    click PaymentService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/payment/transactionService.ts"
    click PaymentService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/payment/usePayment.ts"
    click PaymentService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/components/stripe/PaymentForm.tsx"

    click WalletService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/services/wallet/WalletService.ts"
    click WalletService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/hooks/wallet/useWallet.ts"
    click WalletService "https://github.com/saalim-km/bella-imagine-client/blob/main/src/components/common/WalletComponent.tsx"

    click API "https://github.com/saalim-km/bella-imagine-client/blob/main/src/api/endpoints.ts"
    click Vercel "https://github.com/saalim-km/bella-imagine-client/blob/main/vercel.json"

    click Redux "https://github.com/saalim-km/bella-imagine-client/blob/main/src/store/store.ts"
    click Redux "https://github.com/saalim-km/bella-imagine-client/tree/main/src/store/slices"

    click React "https://github.com/saalim-km/bella-imagine-client/tree/main/src/components/layout"
    click React "https://github.com/saalim-km/bella-imagine-client/tree/main/src/components/common"

    click GoogleMaps "https://github.com/saalim-km/bella-imagine-client/blob/main/src/utils/config/map.config.ts"
    click GoogleMaps "https://github.com/saalim-km/bella-imagine-client/blob/main/src/lib/utils.ts"
    click GoogleMaps "https://github.com/saalim-km/bella-imagine-client/blob/main/src/lib/formatters.ts"
    click GoogleMaps "https://github.com/saalim-km/bella-imagine-client/blob/main/src/utils/formatters/format-price.utils.ts"
    click React "https://github.com/saalim-km/bella-imagine-client/blob/main/tailwind.config.js"
    click React "https://github.com/saalim-km/bella-imagine-client/blob/main/vite.config.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0366d6,color:#0366d6
    classDef backend fill:#d4edda,stroke:#28a745,color:#155724
    classDef database fill:#fff3cd,stroke:#ffcd39,color:#856404,shape:cylinder
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#343a40,shape:cloud
    classDef deployment fill:#f8d7da,stroke:#dc3545,color:#721c24
```
