How sangam14/syft-api works
Project Type & Purpose
• This is a backend service written in Go that provides an API (with an exposed OpenAPI spec at http://localhost:3000) for generating Software Bill of Materials (SBOMs).
• It integrates AI capabilities through the use of the Ollama model runner and can scan Docker images, local directories, and GitHub repositories.
• The presence of a static folder (with an index.html, a JavaScript file, and CSS) indicates a basic frontend served by the API (or via static hosting) to interact with users.
Main Components
• API/Backend Service: Represented by main.go and its supporting backend business logic. This is the central component of the system.
• SBOM Generation Engine: A logical component within the backend that coordinates scans across different sources (Docker images, directories, and GitHub repositories) and integrates with the AI-powered model.
• External Service Integration (Ollama): Since the README mandates that Ollama must be running locally, outline this as an external dependency that the SBOM generator communicates with.
• Static Frontend Assets: The static directory contains assets like index.html, script.js, style.css, and even an output.log. This represents a user interface that interacts with the backend service.
• Containerization/Docker Environment: With files such as docker-compose.yaml, dockerfile, and .dockerignore, stress the importance of container orchestration. This encapsulates the runtime environment of the application.
Relationships & Data Flow
• The frontend (static assets) is served to the user’s browser. Users interact with the UI, which sends HTTP requests (via API calls) to the Go-based backend service.
• The backend service (API) processes these requests. Depending on the source the user wants to scan (Docker images, directories, or GitHub repositories), it triggers the appropriate scanning logic.
• When AI capabilities are required, the backend makes a request to the local Ollama model runner to get model-based insights or enhance the SBOM generation.
• Docker Compose manages the container lifecycle, ensuring that the API service and any related services (if added in the future, such as a Docker-model-runner container) run with the proper configuration.
Architectural Patterns & Design Principles
• Layered Architecture: Separate the system into layers – a presentation layer (frontend), an application layer (API endpoints and business logic), and integrations with external services (Ollama).
• Clear Separation of Concerns: Distinguish between scanning logic, AI integration, and deployment responsibilities.
• Containerized Deployment: Emphasize how Docker (via docker-compose) is used to encapsulate and deploy the complete environment, ensuring consistency between development and production.
• Next, highlight the static assets being served to users from the backend or as a separate delivery mechanism.
• External dependencies—particularly the local Ollama service that the API calls during SBOM generation.