# aurumdev952/emotter architecture

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

- Interactive diagram: https://gitdiagram.com/aurumdev952/emotter
- Repository: https://github.com/aurumdev952/emotter

## Overview

##### Main Components

a. Frontend Layer:
- Next.js Client Components (/src/components)
- Pages Router Structure (/src/pages)
- UI Component Library (/src/components/ui)
- Client-side Utils (/src/utils)

b. API Layer:
- TRPC Router Setup (/src/server/api)
- Authentication System (NextAuth.js)
- File Upload Service (/pages/api/upload)

c. Database Layer:
- Prisma ORM
- Database (likely PostgreSQL based on Prisma usage)

##### Component Relationships

**[Client Layer]**
- ↓ ↑
**[API Layer (TRPC + REST)]**
- ↓ ↑
**[Database Layer]**

##### Specific Implementation Details

a. Client Layer (Top):
- Tweet Components (tweet.tsx, tweetLarge.tsx)
- User Profile Components (UserProfileComp.tsx)
- Comment Components (CommentComp.tsx)
- Form Components (NewTweetDialog.tsx, EditProfileDialog.tsx)

b. API Layer (Middle):
- TRPC Routers:
- Tweet Router (/server/api/routers/tweet.ts)
- User Router (/server/api/routers/user.ts)
- Example Router (/server/api/routers/example.ts)
- Authentication:
- NextAuth.js Integration
- File Upload:
- Image Upload Service

c. Database Layer (Bottom):
- Prisma Schema (prisma/schema.prisma)
- Database Tables (derive from schema)

##### Important Architectural Patterns to Highlight

- TRPC API Pattern: Show how type-safe API calls flow from client to server
- Next.js Pages Router: Illustrate the routing structure
- Component Hierarchy: Show the relationship between UI components
- Authentication Flow: Demonstrate how NextAuth.js integrates with the system

##### Additional Elements

- Technology badges: Next.js, TRPC, Prisma, NextAuth.js
- External services (if any)

##### The database schema and relationships

Remember to maintain clarity while showing the full stack nature of the application, with special attention to the type-safety features provided by TRPC and the seamless integration of Next.js features.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        FC[Frontend Components]
        TC[Tweet Components]
        PC[Profile Components]
        CC[Comment Components]
        FC[Form Components]
        UI[UI Component Library]
        PR[Pages Router]
        CU[Client Utils]
    end

    subgraph API
        TR[TRPC Root]
        TweetR[Tweet Router]
        UserR[User Router]
        Auth[NextAuth.js]
        Upload[File Upload Service]
    end

    subgraph Database
        PS[Prisma Schema]
        DB[(Database)]
        DBC[Database Connection]
    end

    %% Client Layer Relationships
    FC --> TC & PC & CC
    TC & PC & CC --> UI
    PR --> FC
    CU --> FC

    %% API Layer Relationships
    FC --> TR
    TR --> TweetR & UserR
    FC --> Auth
    FC --> Upload

    %% Database Layer Relationships
    TweetR & UserR --> PS
    PS --> DB
    DBC --> DB

    %% Component Mappings
    click FC "https://github.com/Aurumdev952/emotter/tree/main//src/components/"
    click TC "https://github.com/Aurumdev952/emotter/blob/main//src/components/tweet.tsx"
    click PC "https://github.com/Aurumdev952/emotter/blob/main//src/components/UserProfileComp.tsx"
    click CC "https://github.com/Aurumdev952/emotter/blob/main//src/components/CommentComp.tsx"
    click UI "https://github.com/Aurumdev952/emotter/tree/main//src/components/ui/"
    click PR "https://github.com/Aurumdev952/emotter/tree/main//src/pages/"
    click CU "https://github.com/Aurumdev952/emotter/blob/main//src/lib/utils.ts"
    click TR "https://github.com/Aurumdev952/emotter/blob/main//src/server/api/root.ts"
    click TweetR "https://github.com/Aurumdev952/emotter/blob/main//src/server/api/routers/tweet.ts"
    click UserR "https://github.com/Aurumdev952/emotter/blob/main//src/server/api/routers/user.ts"
    click Auth "https://github.com/Aurumdev952/emotter/blob/main//src/pages/api/auth/[...nextauth].ts"
    click Upload "https://github.com/Aurumdev952/emotter/blob/main//src/pages/api/upload/images/index.ts"
    click PS "https://github.com/Aurumdev952/emotter/blob/main//prisma/schema.prisma"
    click DBC "https://github.com/Aurumdev952/emotter/blob/main//src/server/db.ts"

    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#22c55e,color:white
    classDef auth fill:#eab308,color:white
    classDef database fill:#a855f7,color:white
    classDef utils fill:#f97316,color:white

    class FC,TC,PC,CC,UI,PR frontend
    class TR,TweetR,UserR,Upload api
    class Auth auth
    class PS,DB,DBC database
    class CU utils
```
