# eagledb14/paperlink architecture

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

- Interactive diagram: https://gitdiagram.com/eagledb14/paperlink
- Repository: https://github.com/eagledb14/paperlink

## Overview

##### Main System Components

A. Presentation Layer
- Web Interface (HTML Templates in /tmpl directory)
- Static Assets (CSS)

B. Application Layer
- HTTP Server (main.go)
- Authentication System (/auth)
- Core Business Logic Modules:
- Engagement Management
- Asset Management
- Finding Management
- Code Management
- Template System
- Dictionary Management

C. Data Layer
- Database Interface (/db)

##### Component Relationships

**[Web Browser] ←→ [HTTP Server]**
- ↓
- ┌───────────────┴─────────────────┐
- ↓               ↓                 ↓
**[Auth Service]  [Core Services]    [Templates]**
- ↓               ↓                 ↓
- ┴─────────────────┘
- ↓
- [Database Layer]

##### Specific Component Details

A. Frontend Components (Blue):
- HTML Templates (tmpl/*.html)
- CSS Styles (tmpl/styles.css)

B. API Layer (Green):
- Net Package Handlers (/net/*.go)
- Asset Handler
- Authentication Handler
- Engagement Handler
- Finding Handler
- etc.

C. Core Services (Orange):
- Engagement Service
- Asset Service
- Finding Service
- Dictionary Service
- Template Service

D. Authentication (Red):
- Auth Package
- User Management

E. Data Layer (Purple):
- Database Wrapper

##### Data Flow Indicators

- User request flow from browser through the system
- Authentication flow
- Data persistence operations
- Template rendering process

##### Important Architectural Patterns to Highlight

- MVC-like pattern:
- Models: engagement/, types/
- Views: tmpl/
- Controllers: net/

- Service-oriented architecture:
- Separate packages for different business domains
- Clear separation of concerns

##### Technical Details

Annotations for:
- HTTP server running on port 8080
- Authentication mechanisms
- Admin account creation process
- Template rendering pipeline

##### Integration Points

External integration points:
- npm dependencies
- Database connection
- Authentication system

Key Considerations:
- Security aspects of the system
- Clear boundaries between authenticated and public areas
- Reporting and collaboration features
- Template system's role in report generation

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Browser
        WB[Web Browser]
    end

    subgraph "Presentation Layer"
        UI["Web Interface"]
        SA["Static Assets"]
    end
    click UI "https://github.com/eagledb14/paperlink/blob/main/tmpl/*.html"
    click SA "https://github.com/eagledb14/paperlink/blob/main/tmpl/styles.css"

    subgraph "HTTP Layer"
        HS["HTTP Server"]
    end
    click HS "https://github.com/eagledb14/paperlink/blob/main/main.go"

    subgraph "API Handlers"
        direction TB
        EH["Engagement Handler"]
        AH["Asset Handler"]
        FH["Finding Handler"]
        CH["Code Handler"]
        TH["Template Handler"]
        DH["Dictionary Handler"]
    end
    click EH "https://github.com/eagledb14/paperlink/blob/main/net/engagement.go"
    click AH "https://github.com/eagledb14/paperlink/blob/main/net/asset.go"
    click FH "https://github.com/eagledb14/paperlink/blob/main/net/finding.go"
    click CH "https://github.com/eagledb14/paperlink/blob/main/net/code.go"
    click TH "https://github.com/eagledb14/paperlink/blob/main/net/template.go"
    click DH "https://github.com/eagledb14/paperlink/blob/main/net/dictionary.go"

    subgraph "Core Services"
        direction TB
        ES["Engagement Service"]
        AS["Asset Service"]
        FS["Finding Service"]
        CS["Code Service"]
        TS["Template Service"]
        DS["Dictionary Service"]
    end
    click ES "https://github.com/eagledb14/paperlink/blob/main/engagement/engagement.go"
    click AS "https://github.com/eagledb14/paperlink/blob/main/engagement/asset.go"
    click FS "https://github.com/eagledb14/paperlink/blob/main/engagement/finding.go"
    click CS "https://github.com/eagledb14/paperlink/blob/main/engagement/code.go"
    click TS "https://github.com/eagledb14/paperlink/blob/main/engagement/template.go"
    click DS "https://github.com/eagledb14/paperlink/blob/main/dictionary/dictionary.go"

    subgraph "Authentication"
        AuthS["Auth Service"]
        UM["User Management"]
    end
    click AuthS "https://github.com/eagledb14/paperlink/blob/main/auth/auth.go"
    click UM "https://github.com/eagledb14/paperlink/blob/main/auth/user.go"

    subgraph "Data Layer"
        DB["Database Interface"]
        State["Application State"]
    end
    click DB "https://github.com/eagledb14/paperlink/blob/main/db/db_wrapper.go"
    click State "https://github.com/eagledb14/paperlink/blob/main/types/state.go"

    %% Connections
    WB <--> UI
    WB <--> SA
    UI --> HS
    SA --> HS
    
    HS --> EH & AH & FH & CH & TH & DH
    HS --> AuthS
    
    EH --> ES
    AH --> AS
    FH --> FS
    CH --> CS
    TH --> TS
    DH --> DS
    
    ES & AS & FS & CS & TS & DS --> DB
    ES & AS & FS & CS & TS & DS --> State
    
    AuthS --> UM
    UM --> DB
    
    %% Styles
    classDef browser fill:#f9f,stroke:#333
    classDef presentation fill:#69c,stroke:#333
    classDef http fill:#396,stroke:#333
    classDef api fill:#3c9,stroke:#333
    classDef core fill:#f93,stroke:#333
    classDef auth fill:#c33,stroke:#333
    classDef data fill:#939,stroke:#333
    
    class WB browser
    class UI,SA presentation
    class HS http
    class EH,AH,FH,CH,TH,DH api
    class ES,AS,FS,CS,TS,DS core
    class AuthS,UM auth
    class DB,State data
```
