# carpediem-nepal/pslogger architecture

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

- Interactive diagram: https://gitdiagram.com/carpediem-nepal/pslogger
- Repository: https://github.com/carpediem-nepal/pslogger

## Overview

##### Project Type Analysis
This is a Python library/utility project that serves as a wrapper around different logging implementations (logfire for production and structlog for other environments). The project structure suggests it's designed to be installed as a package (presence of pyproject.toml and egg-info directory).

##### Key Components

A. Core Components:
- Logger Wrapper (Main Interface)
- Environment-based Logger Selection
- Logging Implementations
- Logfire (Production)
- Structlog (Other Environments)

B. Configuration Layer:
- Constants Management
- Environment Detection

##### Component Representation

a. Create three main sections:
- ┌─────────────────────────┐
- Client Application     │
- ┬──────────────┘
- ↓
- ┌─────────────────────────┐
- Logger Wrapper       │
- (pslogger)          │
- ┬──────────────┘
- ↓
- ┌──────────┴──────────────┐
- Logger Implementations  │
- ┘

##### Detailed Component Breakdown

a. Logger Wrapper Layer:
- Constants.py as a supporting component
- Environment detection logic

b. Implementation Layer:
- Create two parallel components for Logfire and Structlog
- Use a switch/decision diamond to show environment-based routing

##### Additional Details

Annotations for:
- Environment variables
- Configuration options
- Key method signatures
- Type hints (as indicated by .py.typed file)

Specific Instructions for Drawing:

##### Separation of concerns between
- Interface (logger.py)
- Configuration (constants.py)
- Implementation selection logic

##### Clear boundaries between
- Client code usage
- Wrapper logic
- Underlying logging implementations

##### Error handling and fallback paths

Remember to maintain a balance between:
- Showing the high-level architecture
- Including important implementation details

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        APP[Client Application]
    end

    subgraph Wrapper
        INIT["Package Interface"]:::core
        LOGGER["Logger Wrapper"]:::core
        CONST["Constants Management"]:::config
        TYPE["Type Definitions"]:::config
        CONFIG["Package Configuration"]:::config
    end

    subgraph Implementation
        ENV{Environment<br>Detection}
        LOGFIRE["Logfire Logger<br>(Production)"]:::prod
        STRUCT["Structlog Logger<br>(Development)"]:::dev
    end

    %% Flow
    APP --> INIT
    INIT --> LOGGER
    LOGGER --> ENV
    ENV -->|Production| LOGFIRE
    ENV -->|Development| STRUCT
    CONST -.->|Config| LOGGER
    TYPE -.->|Types| LOGGER
    CONFIG -.->|Settings| INIT

    %% Click Events
    click LOGGER "https://github.com/Carpediem-Nepal/pslogger/blob/main/src/pslogger/logger.py"
    click CONST "https://github.com/Carpediem-Nepal/pslogger/blob/main/src/pslogger/constants.py"
    click INIT "https://github.com/Carpediem-Nepal/pslogger/blob/main/src/pslogger/__init__.py"
    click TYPE "https://github.com/Carpediem-Nepal/pslogger/blob/main/src/pslogger/.py.typed"
    click CONFIG "https://github.com/Carpediem-Nepal/pslogger/blob/main/pyproject.toml"

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef config fill:#949494,stroke:#949494,color:#fff
    classDef prod fill:#2a9d8f,stroke:#2a9d8f,color:#fff
    classDef dev fill:#e76f51,stroke:#e76f51,color:#fff

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Configuration"]:::config
        L3["Production Logger"]:::prod
        L4["Development Logger"]:::dev
    end
```
