# spejder/ms-vcard architecture

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

- Interactive diagram: https://gitdiagram.com/spejder/ms-vcard
- Repository: https://github.com/spejder/ms-vcard

## Overview

##### Client Layer
- HTTP Clients (e.g., ContactSync Android App)
- Basic Authentication Handler

##### Service Layer
- HTTP Server (Main Service)
- VCard Generator
- Medlemsservice Client

##### External Systems
- Medlemsservice (MS) Database/API

##### Component Organization

- Environment configurations (MS_DATABASE, MS_URL)

b. Create three vertical sections:
- Client Zone (Top)
- Application Zone (Middle)
- External Services Zone (Bottom)

##### Flow Representation

- Client → HTTP Basic Auth → Main Service
- Main Service → MS Client → Medlemsservice API
- VCard Generation Flow (Internal)
- Response Flow back to Client

##### Component Details

For each component, include:

a. Main Service:
- HTTP Endpoint Handler (main.go)
- VCard Generator (vcard.go)
- Profile Handler (profiles.go)

b. MS Client Package (internal/ms):
- Client Implementation
- Member Profile Handler
- Partner Relation Handler

##### Technical Specifications

Important technical details:
- Docker Container
- HTTP/HTTPS Protocol
- Basic Authentication
- VCard v4.0 Format

- Blue: Core service components
- Green: External services
- Yellow: Authentication/Security
- Gray: Infrastructure components

##### Labels
- Component names
- Protocol information
- Performance notes
- Environment variables

Keep in mind:

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef auth fill:#ff9,stroke:#333,stroke-width:2px
    classDef service fill:#9cf,stroke:#333,stroke-width:2px
    classDef external fill:#9f9,stroke:#333,stroke-width:2px
    classDef docker fill:#eee,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
    classDef infra fill:#ddd,stroke:#333,stroke-width:2px
    
    %% Client Layer
    Client["HTTP Clients\n(ContactSync Android App)"]:::client
    Auth["Basic Authentication"]:::auth
    
    %% Main Service Container
    subgraph DockerContainer["Docker Container"]
        MainService["HTTP Server\n(Main Service)"]:::service
        VCardGen["VCard Generator"]:::service
        ProfileHandler["Profile Handler"]:::service
        
        subgraph MSClient["Medlemsservice Client"]
            MSClientImpl["Client Implementation"]:::service
            MemberProfile["Member Profile Handler"]:::service
            PartnerRelation["Partner Relation Handler"]:::service
        end
    end
    
    %% External Services
    MS[("Medlemsservice\nDatabase/API")]:::external
    
    %% Relationships
    Client --> Auth
    Auth --> MainService
    MainService --> VCardGen
    MainService --> ProfileHandler
    ProfileHandler --> MSClientImpl
    MSClientImpl --> MemberProfile
    MSClientImpl --> PartnerRelation
    MSClientImpl --> MS
    
    %% Performance Note
    note["Performance: ~6s for 60 contacts"]
    
    %% Legend
    subgraph Legend
        Client1["Client"]:::client
        Auth1["Security"]:::auth
        Service1["Service"]:::service
        External1["External System"]:::external
    end
    
    %% Click Events
    click MainService "https://github.com/spejder/ms-vcard/blob/main/main.go"
    click VCardGen "https://github.com/spejder/ms-vcard/blob/main/vcard.go"
    click ProfileHandler "https://github.com/spejder/ms-vcard/blob/main/profiles.go"
    click MSClientImpl "https://github.com/spejder/ms-vcard/blob/main/internal/ms/client.go"
    click MemberProfile "https://github.com/spejder/ms-vcard/blob/main/internal/ms/member_profile.go"
    click PartnerRelation "https://github.com/spejder/ms-vcard/blob/main/internal/ms/res_partner_relation_all.go"
    click DockerContainer "https://github.com/spejder/ms-vcard/tree/main/Dockerfile"
```
