# adamkhalif8254/hirestack architecture

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

- Interactive diagram: https://gitdiagram.com/adamkhalif8254/hirestack
- Repository: https://github.com/adamkhalif8254/hirestack

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js application with server and client components
- Authentication system (NextAuth.js)
- tRPC client for type-safe API communication
- User interface components (Dashboard, Search, Settings)

b) Backend Layer:
- Lambda functions for different operations
- Database interactions
- Web scraping functionality
- Data processing utilities

c) Database Layer:
- Prisma ORM
- Database schema (as indicated by prisma/schema.prisma)

##### Component Relationships

a) Client-Server Flow:
- How the Next.js frontend communicates with the backend via tRPC
- Authentication flow through NextAuth.js
- API routes and their connections

b) Backend Services:
- Demonstrate how Lambda functions interact with the main backend
- Data flow from web scraping to processing to storage
- Cleaning and search operations

##### Specific Implementation Details

Technical elements:

**[Frontend Layer]**
- Next.js App Router
- Public Pages
- Protected Dashboard
- API Routes
- tRPC Client
- Authentication

**[Backend Layer]**
- Lambda Functions
- Search Service
- DB Cleaning Service
- Utilities
- Web Scraper
- Data Processor
- Database Handler
- Main Application

**[Database Layer]**
- Prisma ORM
- Database Schema

##### Key Workflows

Important processes:
- Job data aggregation flow
- Search and filtering pipeline
- Authentication and authorization flow
- Real-time updates mechanism

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        NextApp["Next.js App"]:::frontend
        Auth["NextAuth.js"]:::frontend
        tRPCClient["tRPC Client"]:::frontend
        UI["UI Layer"]:::frontend
        
        subgraph Components
            Dashboard["Dashboard"]:::frontend
            Search["Search"]:::frontend
            JobCard["Job Display"]:::frontend
        end
        
        UI --> Dashboard
        UI --> Search
        UI --> JobCard
        NextApp --> UI
        NextApp --> Auth
        NextApp --> tRPCClient
    end
    
    subgraph Backend
        tRPCRouter["tRPC Router"]:::backend
        APIRoutes["API Routes"]:::backend
        
        subgraph LambdaFunctions
            SearchLambda["Search Service"]:::lambda
            CleaningLambda["DB Cleaning Service"]:::lambda
        end
        
        subgraph Utils
            WebScraper["Web Scraper"]:::util
            DataProcessor["Data Processor"]:::util
            DBHandler["Database Handler"]:::util
        end
    end
    
    subgraph Database
        PrismaORM["Prisma ORM"]:::database
        DBSchema["Database Schema"]:::database
        DBMigrations["Database Migrations"]:::database
    end
    
    tRPCClient --> tRPCRouter
    tRPCRouter --> DBHandler
    SearchLambda --> DBHandler
    CleaningLambda --> DBHandler
    WebScraper --> DataProcessor
    DataProcessor --> DBHandler
    DBHandler --> PrismaORM
    PrismaORM --> DBSchema
    
    %% Component Mappings
    click NextApp "https://github.com/AdamKhalif8254/Hirestack/tree/main/frontend/src/app"
    click Auth "https://github.com/AdamKhalif8254/Hirestack/blob/main/frontend/src/app/api/auth/[...nextauth]"
    click tRPCClient "https://github.com/AdamKhalif8254/Hirestack/tree/main/frontend/src/trpc"
    click Dashboard "https://github.com/AdamKhalif8254/Hirestack/blob/main/frontend/src/app/_components/DashboardClient.tsx"
    click Search "https://github.com/AdamKhalif8254/Hirestack/blob/main/frontend/src/app/_components/SearchClient.tsx"
    click JobCard "https://github.com/AdamKhalif8254/Hirestack/blob/main/frontend/src/app/_components/JobCard.tsx"
    click SearchLambda "https://github.com/AdamKhalif8254/Hirestack/blob/main/backend/lambda_folders/search_lambda/lambda_function.py"
    click CleaningLambda "https://github.com/AdamKhalif8254/Hirestack/blob/main/backend/lambda_folders/cleanDB/lambda_funciton.py"
    click WebScraper "https://github.com/AdamKhalif8254/Hirestack/blob/main/backend/utils/scrape.py"
    click DataProcessor "https://github.com/AdamKhalif8254/Hirestack/blob/main/backend/utils/processor.py"
    click DBHandler "https://github.com/AdamKhalif8254/Hirestack/blob/main/backend/utils/database.py"
    click PrismaORM "https://github.com/AdamKhalif8254/Hirestack/blob/main/frontend/prisma/schema.prisma"
    click DBMigrations "https://github.com/AdamKhalif8254/Hirestack/tree/main/frontend/prisma/migrations"
    click tRPCRouter "https://github.com/AdamKhalif8254/Hirestack/blob/main/frontend/src/server/api/root.ts"
    click APIRoutes "https://github.com/AdamKhalif8254/Hirestack/tree/main/frontend/src/app/api"
    
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef lambda fill:#e74c3c,stroke:#c0392b,color:white
    classDef util fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    
    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Service"]:::backend
        Lambda_L["Lambda Function"]:::lambda
        Util_L["Utility Service"]:::util
        DB_L["Database Component"]:::database
    end
```
