# sahildevil/horizonwalls architecture

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

- Interactive diagram: https://gitdiagram.com/sahildevil/horizonwalls
- Repository: https://github.com/sahildevil/horizonwalls

## Overview

##### Overall Project Type and Purpose
- Horizon Walls is a cross-platform wallpaper discovery app built using React Native. Its purpose is to allow users to browse and download high-quality wallpapers.
- In addition to the mobile client, the broader ecosystem includes a backend (built with Node.js, Express, and MongoDB) for data storage and API operations, as well as a Next.js-based admin panel for managing content. External services (Google OAuth for authentication and Google AdMob for monetization) are also integrated.

##### File Structure
- The mobile app repository (which you’re looking at) contains both native Android code (in the “android” folder) and JavaScript/JSX/TSX files for the React Native application (under “app”, “components”, “providers”, “services”, etc.).
- The “app” folder shows multiple subdirectories, including tabs (for different sections like Categories, Favs, etc.), static pages (AboutUs, ContactUs), various screens (like login and search), and a layout file. This indicates a modular, component-driven architecture.
- Directories like “assets” (for fonts and images) and “config” (for theme, fonts, mobile ads, etc.) reflect the app’s focus on UI and external service configuration.
- Supporting folders such as “providers” and “services” indicate context management (e.g., authentication and theme contexts) and API integrations, respectively.

##### Information from the README
- The README details the tech stack: a React Native frontend, native mobile code for Android (within the repository) plus a separate backend and admin panel hosted on different repositories.
- It specifies key features (Google OAuth 2.0 for authentication, a NextAuth-secured admin panel, and Google AdMob monetization) and even provides separate setup and install instructions for each component, which suggests distinct subsystems interacting with each other.

##### Components
a. Main Mobile Client (React Native App):
- React Native application, which includes:
- User Interface layer based on screens (e.g., Categories, Favs, Login, Search, AboutUs, ContactUs) found in the “app” folder.
- Reusable components (e.g., category cards, headers, image cards) from the “components” directory.
- Context management providers (authentication, theme, scroll context) from the “providers” folder.
- Utility modules and services (API integrations, helper functions) that connect to external data.
- Native integration details (Android code under “android”) which may include platform-specific implementations.

b. Backend Server (External Repository):
- Even though not in the file tree here, indicate that this mobile client communicates with a backend built on Node.js/Express, which handles:
- API endpoints for retrieving wallpaper data.
- User authentication (potentially integrating with Google OAuth).
- Database operations using MongoDB.

c. Admin Panel (Separate Repository):
- Admin panel built with Next.js and styled with Tailwind CSS. It uses NextAuth for protected access and is used for content management.

d. External Services:
- Google OAuth 2.0 for authentication.
- Google AdMob for monetization.
- Possibly other services, such as Appwrite (as seen in the “services/appwrite.js”) if used for additional backend functionality or synchronization.

##### Relationships and Data Flow
- The React Native front-end (mobile client) interacts with the backend via RESTful API calls (and possibly GraphQL if used).
- The mobile client uses external OAuth for authentication and then communicates user credentials to the backend.
- The mobile client receives configuration details (like mobile ads) via the “config” and “providers” modules.
- The admin panel interacts with the backend to manage and update wallpaper content.
- External monetization (Google AdMob) injects ads into the mobile client’s UI.

##### Architectural Patterns and Design Principles
- Componentization: separate modules for UI (screens, components) and logic (providers, services, utils).
- A clear separation between the mobile app’s presentation layer and the backend data/API layer.
- Use of cross-platform development (React Native) combined with native code (Android folder) to leverage platform-specific functionalities.
- Integration pattern with external authentication and monetization services.

##### Final Steps
- Subdivide the mobile client block to show internal modules such as views (tabs, screens), components, providers, and configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Client"
        subgraph "React Native UI"
            A["Screens (app)"]:::client
            B["Reusable Components (components)"]:::client
            C["Assets (assets)"]:::client
            D["Configuration (config)"]:::client
        end
        P["Context Providers"]:::client
        subgraph "API & Utility Modules"
            S["Services (API)"]:::client
            U["Utils"]:::client
        end
        N["Native Android Integration"]:::client
    end

    subgraph "External Services"
        O["Google OAuth"]:::external
        M["Google AdMob"]:::external
    end

    BK["Backend Server (Node.js/Express+MongoDB)"]:::backend
    AP["Admin Panel (Next.js+NextAuth)"]:::admin

    %% Connections within Mobile Client and to external systems
    A -->|"fetchData"| BK
    P -->|"wrapsUI"| A
    A -->|"callsAPI"| S
    S -->|"apiResponse"| BK
    A -->|"nativeIntegration"| N
    N -->|"nativeCall"| A
    O -->|"authResponse"| BK
    O -->|"authCallback"| A
    M -->|"adsInjection"| A
    AP -->|"managesContent"| BK
    BK -->|"updatesContent"| AP

    %% Click Events
    click A "https://github.com/sahildevil/horizonwalls/tree/appwrite/app/"
    click B "https://github.com/sahildevil/horizonwalls/tree/appwrite/components/"
    click C "https://github.com/sahildevil/horizonwalls/tree/appwrite/assets/"
    click D "https://github.com/sahildevil/horizonwalls/tree/appwrite/config/"
    click N "https://github.com/sahildevil/horizonwalls/tree/appwrite/android/"
    click P "https://github.com/sahildevil/horizonwalls/tree/appwrite/providers/"
    click S "https://github.com/sahildevil/horizonwalls/blob/appwrite/services/appwrite.js"
    click U "https://github.com/sahildevil/horizonwalls/tree/appwrite/utils/"
    click O "https://github.com/sahildevil/horizonwalls/blob/appwrite/app/oauth-native-callback.tsx"
    click M "https://github.com/sahildevil/horizonwalls/blob/appwrite/config/mobileAds.ts"

    %% Styles
    classDef client fill:#A1C3D1,stroke:#333,stroke-width:2px;
    classDef backend fill:#FCD9A3,stroke:#333,stroke-width:2px;
    classDef admin fill:#D1F2A1,stroke:#333,stroke-width:2px;
    classDef external fill:#D1A1F2,stroke:#333,stroke-width:2px;
```
