# ezeibekweemma/google-drive-clone architecture

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

- Interactive diagram: https://gitdiagram.com/ezeibekweemma/google-drive-clone
- Repository: https://github.com/ezeibekweemma/google-drive-clone

## Overview

##### Project Type and Purpose
- This is a full-stack, cloud-storage web application (“Google Drive Clone”) built with Next.js (React + TypeScript).
- It provides user authentication (NextAuth.js), file upload/management, search, and folder navigation, backed by Firebase (Firestore + Storage) and a relational database accessed via Prisma.

##### File-Structure Analysis
Top-level directories:
- prisma/ – your schema.prisma defines your relational DB tables (users, sessions, etc.).
- public/ – static assets (logo, screenshots).
- src/
– components/ – React UI components (Navbar, FileHeader, SideMenu, etc.).
– pages/ – Next.js pages and API routes (auth routes, drive views, serverless functions).
– API/ – client-side wrappers for Firestore and file-upload operations.
– server/ – server-side utilities: db.ts (Prisma client), auth.ts (NextAuth adapter setup).
– hooks/ – custom React hooks for data fetching.
– firebaseConfig.tsx – Firebase SDK initialization.
Config files: next.config.mjs, tsconfig.json, ESLint, Prettier, Tailwind config.

##### Key Insights from the README
- NextAuth.js for authentication
- Firebase (Firestore + Storage) for data and files
- Prisma managing relational data (likely for NextAuth adapters and any server-side metadata)
- Deployed on Vercel

##### Main Components & Interactions
A. Frontend (Next.js + React)
- Pages render via SSR/SSG, and client-side navigation (drive views, file/folder UI).
- Components communicate with backend API routes and directly with Firebase SDK for file operations.
B. Authentication Layer (NextAuth.js)
- pages/api/auth/[...nextauth].ts implements authentication providers.
- Uses Prisma adapter (src/server/db.ts) to persist user/session data in relational DB.
C. Backend API (Next.js Serverless Functions)
- pages/api routes for any custom server logic (e.g., additional folder or file metadata management).
- src/server/db.ts provides a Prisma client to these functions.
D. Databases & Storage
1. Relational DB (Postgres/SQLite) via Prisma – stores user accounts, sessions, metadata.
2. Firebase Firestore – stores file/folder metadata in a NoSQL store.
3. Firebase Storage – stores binary file contents.
E. Hosting & Deployment
- Vercel hosts the Next.js application (frontend + serverless API).
- Firebase is a third-party managed service for storage and real-time database.

##### Architectural Patterns & Principles
- Full-stack separation: clear distinction between UI, API, and data layers.
- Serverless functions for on-demand backend operations (Next.js API routes).
- Adapter pattern: NextAuth.js uses a Prisma adapter for DB interactions.
- Client-SDK usage for Firebase to reduce server load on file uploads/downloads.
- Hooks and reusable components on the front end to maintain modularity.

1. “User Browser” – React/Next.js SPA & SSR pages
2. “Next.js Serverless API” – pages/api routes + NextAuth endpoints
3. “Prisma PostgreSQL DB” – relational store for users, sessions, metadata
4. “Firebase Firestore” – NoSQL store for file/folder metadata
5. “Firebase Storage” – blob storage for actual files
7. “NextAuth.js” – authentication service layer (can be grouped inside API)
- Browser → Next.js pages (SSR/SSG)
- Browser → Next.js API (REST calls for metadata operations)
- Next.js API → Prisma DB (CRUD for user & session data)
- Browser (Firebase SDK) → Firestore (read/write file metadata)
- Browser (Firebase SDK) → Firebase Storage (upload/download blobs)
- NextAuth.js internal calls from API → Prisma DB
c. Technologies & Frameworks
- NextAuth.js as the auth provider.
d. Architectural Patterns
- “Serverless / API Routes” within Next.js
- “Prisma Client” inside the API container
- Client SDK bypassing your server for file transfers

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Next.js + React + Tailwind)" 
        direction TB
        Browser["User Browser"]:::frontend
        Pages["Pages (src/pages)"]:::frontend
        Components["Components (src/components)"]:::frontend
        Styles["Styles (src/styles/globals.css)"]:::frontend
    end

    %% API & Auth Layer
    subgraph "Next.js Serverless API" 
        direction TB
        AuthRoutes["Auth Routes ([...nextauth].ts)"]:::api
        APIRoutes["API Routes (src/pages/api)"]:::api
        NextAuth["NextAuth.js"]:::api
        PrismaClient["Prisma Client (src/server/db.ts)"]:::api
    end

    subgraph "Authentication Layer" 
        direction TB
        AuthConfig["NextAuth Config (src/pages/api/auth/[...nextauth].ts)"]:::api
        Adapter["Prisma Adapter (src/server/auth.ts)"]:::api
        Env["Env (.env.example)"]:::api
    end

    %% Databases
    subgraph "Relational DB (Postgres + Prisma)" 
        direction TB
        PrismaSchema["Schema (prisma/schema.prisma)"]:::db
    end

    subgraph "Firebase Services" 
        direction TB
        Firestore["Firestore (src/API/Firestore.tsx)"]:::external
        Storage["Storage (src/API/FileUpload.tsx)"]:::external
        FBConfig["Firebase Init (src/firebaseConfig.tsx)"]:::external
    end

    %% Hooks and Interfaces
    subgraph "Client Data Hooks & Interfaces"
        direction TB
        FetchFiles["fetchFiles Hook (src/hooks/fetchFiles.tsx)"]:::frontend
        FetchAllFiles["fetchAllFiles Hook (src/hooks/fetchAllFiles.tsx)"]:::frontend
        Interfaces["Interfaces (src/interfaces/index.tsx)"]:::frontend
    end

    %% Deployment & Config
    subgraph "Deployment & Config (Vercel + Config Files)"
        direction TB
        NextConfig["next.config.mjs"]:::config
        TSConfig["tsconfig.json"]:::config
        ESLint[".eslintrc.cjs"]:::config
        Prettier["prettier.config.mjs"]:::config
        PostCSS["postcss.config.cjs"]:::config
        Public["Static Assets (public)"]:::frontend
        Vercel["Vercel"]:::external
    end

    %% Relationships
    Browser -->|renders| Pages
    Browser -->|uses| Components
    Browser -->|loads styles| Styles
    Browser -->|calls| APIRoutes
    Browser -->|SDK read/write| Firestore
    Browser -->|SDK upload/download| Storage

    APIRoutes -->|uses| PrismaClient
    AuthRoutes -->|invokes| NextAuth
    NextAuth -->|adapter| Adapter
    Adapter -->|CRUD| PrismaSchema
    PrismaClient -->|CRUD| PrismaSchema

    AuthConfig -->|configures| NextAuth

    Vercel --> Pages
    Vercel --> APIRoutes
    Vercel --> Firestore
    Vercel --> Storage

    %% Click Events
    click Pages "https://github.com/ezeibekweemma/google-drive-clone/tree/dev/src/pages"
    click Components "https://github.com/ezeibekweemma/google-drive-clone/tree/dev/src/components"
    click Styles "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/styles/globals.css"
    click AuthRoutes "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/pages/api/auth/[...nextauth].ts"
    click APIRoutes "https://github.com/ezeibekweemma/google-drive-clone/tree/dev/src/pages/api"
    click AuthConfig "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/pages/api/auth/[...nextauth].ts"
    click Adapter "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/server/auth.ts"
    click PrismaClient "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/server/db.ts"
    click PrismaSchema "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/prisma/schema.prisma"
    click Firestore "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/API/Firestore.tsx"
    click Storage "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/API/FileUpload.tsx"
    click FBConfig "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/firebaseConfig.tsx"
    click FetchFiles "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/hooks/fetchFiles.tsx"
    click FetchAllFiles "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/hooks/fetchAllFiles.tsx"
    click Interfaces "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/src/interfaces/index.tsx"
    click NextConfig "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/next.config.mjs"
    click TSConfig "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/tsconfig.json"
    click ESLint "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/.eslintrc.cjs"
    click Prettier "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/prettier.config.mjs"
    click PostCSS "https://github.com/ezeibekweemma/google-drive-clone/blob/dev/postcss.config.cjs"
    click Public "https://github.com/ezeibekweemma/google-drive-clone/tree/dev/public"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef api fill:#D6F5D6,stroke:#28a745,color:#236e23
    classDef db fill:#FFE7B5,stroke:#ffa500,color:#8b5f00
    classDef external fill:#FFF5BA,stroke:#dbab09,color:#7a4800
    classDef config fill:#F2F2F2,stroke:#999,color:#333
```
