How saltbo/zpan works
Main Components
• Frontend/UI: Represented by the “web” directory, which holds the static assets (HTML, CSS, JS) built into a web application (likely a single-page app). It’s the user’s primary interaction point.
• API / Backend Server:
• The “cmd” directory (e.g., cmd/server.go) and “main.go” define the application’s entry points.
• The “internal/app” folder holds the business logic, with subdirectories like “api”, “dao”, “service”, “usecase”, “repo” – suggesting a layered architecture (controller → service → repository → persistence).
• Data Layer: Even if there is no explicit “database” folder, your “dao” and “repo” packages indicate that database interactions are abstracted through these layers. You might have a relational database behind these layers.
• External Services & Providers:
• The “internal/pkg/provider” package and the “pkg/nos”, “pkg/obs” directories indicate integrations with external cloud storage providers (S3, OSS, OBS, etc.).
• They act as connectors between your business logic and third-party storage services.
• Infrastructure & Deployment: Files like Dockerfile, heroku.yml, Procfile, and “deployments/” indicate containerized deployment and integrations with cloud tooling, while GitHub workflows encapsulate CI/CD processes.
Relationships and Interactions between Components
• The Frontend (Web UI) issues HTTP requests to the API server.
• The API server (in “internal/app/api” and “cmd”) handles incoming requests, performs authentication (note the “internal/pkg/middleware/auth.go” and “authz” usecase), and routes requests.
• The service and usecase layers in “internal/app/service” and “internal/app/usecase” contain the core business logic that processes file management, sharing, storage operations, and user management.
• Data persistence is managed by DAO (data access object) and repository layers (“internal/app/dao”, “internal/app/repo”), interfacing with the underlying database.
• Cloud storage integrations (in packages within “internal/pkg/provider” and “pkg/nos”, “pkg/obs”) process the actual storage functions by interacting with external cloud storage endpoints.
Architectural Patterns and Design Principles
• Layered Architecture: Separate concerns by dividing responsibilities among the API layer, service/usecase layer, repository layer, and external integrations.
• Modular Design: Encapsulation is evident in the separation of different functionalities (e.g., API, DAO, entity definitions, business logic, and external providers).
• Dependency Injection: Files like “internal/app/wire.go” and “internal/app/wire_gen.go” indicate automated wiring of dependencies.
• Extensibility: The project supports multiple cloud storage providers via distinct packages, signaling an extensible plugin-like approach.
Relevant Technologies and Frameworks
• Written in Go – leveraging native Go modules (go.mod, go.sum) for dependency management.
• Containerization with Docker (Dockerfile, .dockerignore) and deployment scripts (heroku.yml, Procfile).
• CI/CD workflows managed through GitHub Actions (see .github/workflows).
• Frontend assets appear pre-built (likely using a modern JavaScript framework) and served as static assets from the “web/dist” folder.
• Integration with cloud storage providers via S3 and others (through packages under pkg and internal/pkg/provider).