# karprabha/localfluence architecture

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

- Interactive diagram: https://gitdiagram.com/karprabha/localfluence
- Repository: https://github.com/karprabha/localfluence

## Overview

##### Main Components

A. Client Layer:
- Next.js Frontend Application
- Public Routes (/, /login, /signup)
- Protected Dashboard Routes (/dashboard/*)

B. Infrastructure Layer:
- NGINX Reverse Proxy (Load Balancer)

C. Backend Services:
- Auth Server (REST API)
- GraphQL Server
- Shared Database (PostgreSQL)

D. External Services:
- OAuth Providers (GitHub, Google)

**[Client Layer]**
- ↓
**[Infrastructure Layer]**
- ↓
**[Backend Services Layer]**
- ↓
**[Data Layer]**

##### Detailed Component Relationships

A. Frontend (Next.js):
- Public and dashboard layouts as separate containers
- Components:
- Authentication flows
- Campaign management
- User profile management

B. NGINX Layer:
- Routing rules:
- /api/* → Auth Server
- /graphql/* → GraphQL Server
- /* → Frontend

C. Backend Services:
- Auth Server:
- Authentication controllers
- OAuth services
- JWT service
- User management

- GraphQL Server:
- Schema definitions
- Resolvers (Queries/Mutations)
- Data loaders
- Campaign management

D. Database Layer:
- Main entities:
- Users
- UserOAuth
- UserPasswords
- RefreshTokens
- Campaigns
- Influencers
- CampaignManagers

##### Implementation Details

**[Client Browser] → [NGINX Reverse Proxy]**
- ↓
- ┌────────────┬──────────────┐
- ↓            ↓              ↓
**[Frontend]  [Auth Server]  [GraphQL Server]**
- ↑            ↑              ↑
- ┴──────────────┘
- ↓
- [PostgreSQL DB]

##### Additional Elements

- Version indicators for APIs (v1)
- Security boundaries
- Containerized services (Docker)
- Scalable components

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef infrastructure fill:#f1c40f,color:black
    classDef database fill:#9b59b6,color:white
    classDef external fill:#95a5a6,color:white
    
    %% Client Layer
    subgraph Client
        Browser["Client Browser"]
        PublicRoutes["Public Routes"]:::frontend
        DashRoutes["Dashboard Routes"]:::frontend
        AuthService["Authentication Service"]:::frontend
        CampaignUI["Campaign Management UI"]:::frontend
    end

    %% Infrastructure Layer
    NGINX["NGINX Reverse Proxy"]:::infrastructure
    
    %% Backend Services Layer
    subgraph BackendServices
        AuthServer["Auth Server"]:::backend
        GraphQLServer["GraphQL Server"]:::backend
        
        subgraph AuthComponents
            JWTService["JWT Service"]:::backend
            GitHubOAuth["GitHub OAuth"]:::backend
            GoogleOAuth["Google OAuth"]:::backend
            AuthModels["Auth Models"]:::backend
        end
        
        subgraph GraphQLComponents
            Schema["GraphQL Schema"]:::backend
            Resolvers["Resolvers"]:::backend
            CampaignMgmt["Campaign Management"]:::backend
            GraphQLModels["GraphQL Models"]:::backend
        end
    end
    
    %% Database Layer
    subgraph Database
        PostgreSQL[(PostgreSQL DB)]:::database
        Migrations["DB Migrations"]:::database
        Seeds["DB Seeds"]:::database
    end
    
    %% External Services
    GitHub["GitHub OAuth"]:::external
    Google["Google OAuth"]:::external
    
    %% Relationships
    Browser --> NGINX
    NGINX --> PublicRoutes
    NGINX --> DashRoutes
    NGINX --> AuthServer
    NGINX --> GraphQLServer
    
    PublicRoutes --> AuthService
    DashRoutes --> AuthService
    DashRoutes --> CampaignUI
    
    AuthServer --> JWTService
    AuthServer --> GitHubOAuth
    AuthServer --> GoogleOAuth
    AuthServer --> AuthModels
    
    GitHubOAuth --> GitHub
    GoogleOAuth --> Google
    
    GraphQLServer --> Schema
    GraphQLServer --> Resolvers
    GraphQLServer --> CampaignMgmt
    GraphQLServer --> GraphQLModels
    
    AuthModels --> PostgreSQL
    GraphQLModels --> PostgreSQL
    Migrations --> PostgreSQL
    Seeds --> PostgreSQL
    
    %% Click Events
    click PublicRoutes "https://github.com/karprabha/localfluence/tree/main/frontend/src/app/(public)"
    click DashRoutes "https://github.com/karprabha/localfluence/tree/main/frontend/src/app/(dashboard)"
    click AuthService "https://github.com/karprabha/localfluence/blob/main/frontend/src/services/authService.ts"
    click NGINX "https://github.com/karprabha/localfluence/blob/main/nginx/nginx.conf"
    click AuthServer "https://github.com/karprabha/localfluence/tree/main/backend/auth-server/src/api/v1"
    click GraphQLServer "https://github.com/karprabha/localfluence/tree/main/backend/graphql-server/src/graphql"
    click Migrations "https://github.com/karprabha/localfluence/tree/main/database/migrations"
    click Seeds "https://github.com/karprabha/localfluence/tree/main/database/seeds"
    click GitHubOAuth "https://github.com/karprabha/localfluence/blob/main/backend/auth-server/src/api/v1/services/githubOAuth.service.js"
    click GoogleOAuth "https://github.com/karprabha/localfluence/blob/main/backend/auth-server/src/api/v1/services/googleOAuth.service.js"
    click JWTService "https://github.com/karprabha/localfluence/blob/main/backend/auth-server/src/api/v1/services/jwt.service.js"
    click Schema "https://github.com/karprabha/localfluence/blob/main/backend/graphql-server/src/graphql/schema.js"
    click Resolvers "https://github.com/karprabha/localfluence/tree/main/backend/graphql-server/src/graphql/queries"
    click CampaignMgmt "https://github.com/karprabha/localfluence/blob/main/backend/graphql-server/src/graphql/mutations/createCampaign.js"
    click AuthModels "https://github.com/karprabha/localfluence/tree/main/backend/auth-server/src/api/v1/models"
    click GraphQLModels "https://github.com/karprabha/localfluence/tree/main/backend/graphql-server/src/models"
    click CampaignUI "https://github.com/karprabha/localfluence/tree/main/frontend/src/app/(dashboard)/dashboard/create-campaign"
```
