# shadowisf/feeltok architecture

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

- Interactive diagram: https://gitdiagram.com/shadowisf/feeltok
- Repository: https://github.com/shadowisf/feeltok

## Overview

##### Project type and purpose
- This is a full-stack social media application (“FeelTok”) consisting of:
– A React Native mobile client (CLIENT APP) built with Expo for end users to sign up, authenticate, create/view posts, interact with profiles.
– A Next.js-based admin dashboard (ADMIN APP) for moderators to list, review, resolve, and delete user reports or posts.
- The “backend” is serverless: Firebase (Auth + Firestore) for data and identity, Cloudinary for media storage, and Next.js API routes (in the admin app) as a backend-for-frontend.

##### File structure
- Top-level directories:
– CLIENT APP – mobile source code, assets, build artifacts, Expo config
– ADMIN APP – web dashboard with Next.js 13 app folder, serverless API routes under src/app/api
- Key patterns & services:
– CLIENT APP uses file-based routing under app/(auth) and app/(tabs), expo-managed workflow, async storage, 2FA, social sign-in.
– ADMIN APP uses Next.js 13 “app router,” Firebase Admin SDK, Cloudinary helper, RESTful API endpoints in route.ts files.
- Config & dependencies: package.json, tsconfig.json, babel.config.js, expo & eas config, firebase service account JSON.

##### README for insights
- Setup instructions confirm:
– CLIENT APP: Expo mobile dev environment, .apk/.app builds in builds folder.
– ADMIN APP: Next.js dev server that uses Firebase service account.
- No separate custom backend code beyond Next.js API routes and Firebase.

##### Main components & interactions
a. Components
1. Mobile Client (React Native / Expo)
2. Admin Dashboard (Next.js)
3. Firebase Auth & Firestore Database
4. Firebase Admin SDK (used by Next.js API)
5. Cloudinary Media Service
6. Device Local Storage (AsyncStorage on mobile)
b. Data flows & relationships
– Mobile ↔ Firebase Auth: user sign-in, sign-up, OTP, 2FA
– Mobile ↔ Firestore: CRUD operations on posts and user profiles via Firebase SDK
– Mobile ↔ Cloudinary: image/video upload & retrieval through Cloudinary REST API or SDK
– Admin Dashboard ↔ Firebase Admin SDK: secure, server-side management of Firestore data
– Admin API routes ↔ Firestore: listAllPosts, resolvePostReport, toggleUser, etc.
– Admin Dashboard UI calls its own Next.js API routes, which in turn call Firebase Admin SDK.
c. Architectural patterns & design principles
– Serverless / BFF (Backend-for-Frontend) for admin: Next.js API routes wrap Firebase Admin SDK rather than exposing SDK to browser.
– File-based routing both in Next.js and Expo.
– Separation of concerns: client only uses client-side Firebase SDK; admin uses server-side SDK.
– Cloud services for scale: Firebase & Cloudinary.
d. Key technologies & libraries
– React Native + Expo + TypeScript
– Next.js 13 app router + React + TypeScript
– Firebase Auth & Firestore + Firebase Admin SDK
– Cloudinary API helper modules
– AsyncStorage, two-factor auth logic, social login utilities

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client Layer
    subgraph "Mobile Client Layer"
        MC["Expo Mobile Client"]:::client
        MSDK["Firebase Auth & Firestore SDK"]:::client
        AS["AsyncStorage"]:::storage
        EXPOjson["app.json"]:::client
        EASjson["eas.json"]:::client
        TFA["Two-Factor Auth"]:::client
        SSO["Social Sign-In"]:::client
        PCRUD["Post CRUD Operations"]:::client
        UCRUD["User CRUD Operations"]:::client
        CLM["Cloudinary API"]:::media

        MC -->|uses SDK| MSDK
        MSDK -->|auth & data| FA["Firebase Auth"]:::backend
        MSDK -->|auth & data| FS["Firestore"]:::db
        MC -->|cache data| AS
        MC -->|build config| EXPOjson
        MC -->|build config| EASjson
        MC -->|2FA logic| TFA
        MC -->|social login| SSO
        MC -->|post functions| PCRUD
        MC -->|user functions| UCRUD
        MC -->|media upload/download| CLM
    end

    %% Admin Dashboard Layer
    subgraph "Web Admin Layer"
        AD["Next.js Admin Dashboard"]:::client
        APIR["API Routes (BFF)"]:::bff
        FSDKW["Firebase Admin SDK Wrapper"]:::backend
        CLW["Cloudinary Helper"]:::media
        NXCFG["next.config.ts"]:::client
        SvcAcc["firebase-service-account.json"]:::backend

        AD -->|calls BFF| APIR
        APIR -->|server-side sdk| FSDKW
        FSDKW -->|reads/writes| FS
        APIR -->|media helper| CLW
        APIR -->|config| NXCFG
        APIR -->|config| SvcAcc
    end

    %% Shared Backend Services
    subgraph "Serverless Backend Services"
        FA["Firebase Auth"]:::backend
        FS["Firestore"]:::db
        CL["Cloudinary"]:::media
    end

    %% Relationships
    CLM -->|REST API| CL
    CLW -->|Cloudinary API| CL

    %% Click Events
    click MC "https://github.com/shadowisf/feeltok/tree/main/CLIENT APP/"
    click MSDK "https://github.com/shadowisf/feeltok/tree/main/CLIENT APP/app/"
    click AS "https://github.com/shadowisf/feeltok/blob/main/CLIENT APP/utils/asyncStorage.ts"
    click EXPOjson "https://github.com/shadowisf/feeltok/blob/main/CLIENT APP/app.json"
    click EASjson "https://github.com/shadowisf/feeltok/blob/main/CLIENT APP/eas.json"
    click TFA "https://github.com/shadowisf/feeltok/blob/main/CLIENT APP/utils/twoFactorAuth.ts"
    click SSO "https://github.com/shadowisf/feeltok/blob/main/CLIENT APP/utils/googleAuth.ts"
    click PCRUD "https://github.com/shadowisf/feeltok/blob/main/CLIENT APP/utils/postCRUD.ts"
    click UCRUD "https://github.com/shadowisf/feeltok/blob/main/CLIENT APP/utils/userCRUD.ts"
    click APIR "https://github.com/shadowisf/feeltok/tree/main/ADMIN APP/src/app/api/"
    click AD "https://github.com/shadowisf/feeltok/tree/main/ADMIN APP/src/app/dashboard/"
    click FSDKW "https://github.com/shadowisf/feeltok/blob/main/ADMIN APP/src/utils/firebaseAdmin.ts"
    click CLW "https://github.com/shadowisf/feeltok/blob/main/ADMIN APP/src/utils/cloudinary.ts"
    click NXCFG "https://github.com/shadowisf/feeltok/blob/main/ADMIN APP/next.config.ts"
    click SvcAcc "https://github.com/shadowisf/feeltok/blob/main/ADMIN APP/firebase-service-account.json"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#FFA500,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef media fill:#90EE90,stroke:#333,stroke-width:1px
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef bff fill:#E6E6FA,stroke:#333,stroke-width:1px
```
