# mochiday/auto-apply-applet architecture

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

- Interactive diagram: https://gitdiagram.com/mochiday/auto-apply-applet
- Repository: https://github.com/mochiday/auto-apply-applet

## Overview

##### Main Components

a) Client Layer:
- External HTTP clients making POST requests
- Should show the JSON payload structure

b) Server Layer:
- Express.js server (Port 8762)
- Main application entry point

c) Driver Management Layer:
- Driver initialization system
- Driver registry/factory

d) Job Board Drivers:
- Lever driver (currently the only one)
- Placeholder for future drivers

e) Automation Layer:
- Puppeteer browser automation
- Form filling components

##### Component Relationships

**[Client] → [Express Server] → [Driver Manager] → [Specific Driver] → [Puppeteer Automation] → [Job Board Websites]**

##### Detailed Component Breakdown

For the Lever driver (use as a template for future drivers):
- Config management
- Input handlers
- Basic questions handler
- Custom questions handler
- Resume upload functionality
- Application submission

##### Specific Implementation Details to Highlight

a) Driver Architecture:
**src/drivers/**
- apply.ts (Main driver interface)
- init.ts (Driver initialization)
- Lever/ (Specific driver implementation)

b) Lever Driver Components:
- Configuration (config.ts)
- Input Processing (inputHandlers.ts)
- Form Filling (fillLeverBasicQuestions.ts, fillLeverCustomQuestions.ts)
- Resume Handling (uploadResumeToLever.ts)
- Submission Logic (submitLeverApplication.ts)

##### Key Flows

a) Application Flow:
##### Response returned to client

b) Data Flow:
- How candidate data moves through the system
- Where data transformation occurs
- Error handling paths

##### Additional Elements

- Notes about scalability points for future job board additions
- Configuration injection points
- Error handling paths
- Asynchronous operations

##### Technical Details

- TypeScript types and interfaces
- Puppeteer browser instances
- Express server endpoints
- File system interactions (for resume handling)

This architecture should be represented in a way that emphasizes its modular design and the separation of concerns between the driver interface, specific implementations, and the automation layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        C1[HTTP Client]
        C2[JSON Payload]
    end

    subgraph Server
        S1[Express Server]:::server
        S2[Main Entry Point]:::server
    end

    subgraph "Driver Management"
        DM1[Driver Interface]:::driver
        DM2[Driver Initialization]:::driver
    end

    subgraph "Lever Driver"
        LD1[Configuration]:::lever
        LD2[Input Processing]:::lever
        LD3[Main Application Logic]:::lever
        LD4[Submission Handler]:::lever
    end

    subgraph "Automation Layer"
        AL1[Basic Questions Handler]:::automation
        AL2[Custom Questions Handler]:::automation
        AL3[Resume Upload Handler]:::automation
    end

    subgraph "Utilities"
        U1[General Utilities]:::util
        U2[Resume Utilities]:::util
    end

    subgraph "Types"
        T1[Shared Types]:::types
        T2[Lever Types]:::types
    end

    subgraph "External"
        E1[Job Board Websites]
    end

    C1 --> C2
    C2 --> S1
    S1 --> S2
    S2 --> DM1
    S2 --> DM2
    DM1 --> LD1
    DM2 --> LD1
    LD1 --> LD2
    LD2 --> LD3
    LD3 --> AL1
    LD3 --> AL2
    LD3 --> AL3
    AL1 --> LD4
    AL2 --> LD4
    AL3 --> LD4
    LD4 --> E1
    U1 -.-> LD3
    U2 -.-> AL3
    T1 -.-> DM1
    T2 -.-> LD1

    click S2 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/index.ts"
    click DM1 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/apply.ts"
    click DM2 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/init.ts"
    click LD1 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/config/config.ts"
    click LD2 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/handlers/inputHandlers.ts"
    click LD3 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/fillLeverApplication.ts"
    click LD4 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/submitLeverApplication.ts"
    click AL1 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/lib/fillLeverBasicQuestions.ts"
    click AL2 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/lib/fillLeverCustomQuestions.ts"
    click AL3 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/lib/uploadResumeToLever.ts"
    click U1 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/utils/general.ts"
    click U2 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/utils/resume.ts"
    click T1 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/types/shared.ts"
    click T2 "https://github.com/MochiDay/auto-apply-applet/blob/main/src/drivers/Lever/types/types.ts"

    classDef server fill:#90EE90
    classDef driver fill:#FFD700
    classDef lever fill:#FFA500
    classDef automation fill:#FF6347
    classDef util fill:#A9A9A9
    classDef types fill:#87CEEB

    %% Legend
    subgraph Legend
        L1[Server Components]:::server
        L2[Driver Management]:::driver
        L3[Lever Components]:::lever
        L4[Automation Components]:::automation
        L5[Utilities]:::util
        L6[Type Definitions]:::types
    end
```
