How vibioh/fibr works
Project type and purpose
• Type: Full-stack, monolithic Go web application bundling frontend (HTML/CSS/JS) and backend in a single static binary.
• Purpose: Serve a mobile-friendly file-browser UI, manage files (CRUD), generate thumbnails & map views via sidecars, support sharing, webhooks, search, and telemetry.
File structure
• cmd/fibr/: Entrypoint, CLI flags, HTTP server, template & static assets loader, wiring of ports & adapters.
• pkg/: Core business logic layers by domain (crud, storage, metadata, thumbnail, webhook, search, share, provider, sanitizer).
• infra/ & compose.yaml: Deployment manifests (Kubernetes, Docker-Compose).
• Dockerfile, Makefile, .github/: CI/CD & build tooling.
Key architectural insights from README
• Uses HTML templates + minimal JS for UI.
• Pluggable communication to sidecars via HTTP or AMQP.
• Storage can be local filesystem or S3-compatible object store.
• Optional Redis for caching, locking, Pub/Sub to coordinate multiple instances.
• Exposes OpenTelemetry metrics and optional pprof profiling.
• Webhooks to external HTTP endpoints with optional HTTP Signatures.
Main components & relationships
a. User Browser (Web UI)
• Issues HTTP(S) requests (GET, POST, chunked uploads) to fibr’s HTTP server.
b. Fibr HTTP Server (cmd/fibr)
• Router & Handlers: Serve static assets & templates, implement endpoints (/health, /version, /files/*, share links, webhooks, search).
• Template Engine: Renders Go HTML templates.
• Domain Services (pkg/*)**:
• CRUD Service (browse, upload, delete, rename…)
• Share Service (create/read shares, password protection, expiration)
• Search Service (metadata lookup)
• Webhook Service (publish events)
• Thumbnail & Exif Orchestrator (dispatch tasks to sidecars)
• Ports & Adapters: Defined in cmd/fibr/adapters.go (file system adapter, AMQP client, HTTP client, Redis client, S3 client).
c. Storage Layer
• Local FS: Root folder + .fibr metadata subfolder.
• Object Store: S3-compatible (optional).
d. Sidecar Services
• Thumbnail Service (vignet): HLS & WebP thumbnail generation.
• Exif Service (exas): EXIF extraction & optional reverse-geocoding.
• Communication over HTTP or via AMQP broker.
e. Message Broker (AMQP)
• Exchanges & Queues for thumbnail and exif tasks and results.
f. Redis (optional)
• Locks & Pub/Sub for coordinating multiple instances, caching metadata.
g. External HTTP Endpoints
• Webhook subscribers receiving JSON events, signed with HTTP Signature.
h. Observability
• OpenTelemetry gRPC exporter for traces & metrics.
• pprof endpoint (optional).
• Metrics collected: HTTP latencies/status, AMQP operations, sidecar calls.
Architectural patterns & design principles
• Hexagonal Architecture (Ports & Adapters): Core logic decoupled from transport & persistence layers.
• Modular Monolith: Domain logic organized by feature in pkg/.
• Single Binary Deployment: All code + assets compiled into one Go executable.
• Sidecar Pattern: Offload CPU-intensive tasks to separate services.
• Pub/Sub & Message-driven: AMQP for resilient background processing.
Don’t overthink—capture all modules as sub‐components where relevant. E.g.,
• Under Domain: list pkg/crud, pkg/share, pkg/search, pkg/metadata, pkg/thumbnail, pkg/webhook.
• Under Adapters: file system, object storage, AMQP, HTTP (sidecars & webhooks), Redis.