This document explains the structure and purpose of each major component in the BaSyx Go Components repository. It is intended to help new developers understand how the codebase is organized and how the different layers interact.
-
cmd/
- Contains service entry points (main.go), configuration files, and Dockerfiles for each microservice (e.g.,
aasregistryservice,submodelrepositoryservice). - Each service folder includes its own config and healthcheck scripts.
- Contains service entry points (main.go), configuration files, and Dockerfiles for each microservice (e.g.,
-
internal/
- Core business logic, persistence, and integration tests.
- Organized by domain (e.g.,
aasregistry,submodelrepository,discoveryservice). - Each domain contains:
api/: Service layer, request/response handling, endpoint logic.persistence/: Database access, repositories, file handlers.model/: Data structures and types for the domain.benchmark_results/,integration_tests/: Performance and integration test suites.security/,testenv/: Security logic and test environments.
-
pkg/
- Shared libraries and API clients for use across services.
- Contains reusable helpers, routers, and generated API code.
-
examples/
- Minimal working examples and sample setups, including Docker Compose files for quick local testing.
-
docu/
- Documentation, error explanations, and security notes.
-
basyx-database-wiki/
- In-depth documentation of the database schema, relationships, and usage notes.
-
sql_examples/
- Example SQL scripts for schema setup, sample data, and pagination.
- Located in
internal/*/builder/ - Used for constructing complex domain objects (e.g., submodels, descriptors) from input data or configuration.
- Encapsulate creation logic to keep service and API layers clean.
- Found in
internal/*/api/andpkg/*/api.go - Implements REST endpoint logic, request validation, and response formatting.
- Connects HTTP requests to business logic and persistence.
- Uses OpenAPI specs for endpoint definitions.
- Defined in
internal/*/model/andpkg/*/model.go - Contains Go structs and types representing AAS, Submodels, File SME, Registry entries, etc.
- Used for serialization/deserialization and type safety across the codebase.
- Located in
internal/*/persistence/ - Handles database operations, including CRUD for submodels, registries, and file attachments.
- Implements logic for PostgreSQL Large Object storage for File SME.
- Found in
pkg/*/routers.go - Maps HTTP routes to handler functions, sets up middleware, and manages request lifecycle.
- Used by services to expose REST APIs.
- In
internal/*/security/anddocu/security/ - Implements authentication, authorization, and security best practices for API endpoints.
- In
internal/*/integration_tests/ - End-to-end tests for service APIs, file attachment logic, and database interactions.
- Use Docker Compose for isolated test environments.
- In
internal/*/benchmark_results/ - Performance tests and results for critical operations.
- API Layer receives HTTP requests, validates input, and calls Builders or Persistence logic.
- Model types are used throughout for data exchange and validation.
- Persistence stores and retrieves data, including large files for File SME.
- Routers connect endpoints to handlers and manage middleware.
- Security ensures only authorized access to sensitive operations.
- Integration Tests verify that all layers work together as expected.
- API receives a PUT request to
/submodels/{id}/submodel-elements/{idShort}/attachment. - Router maps the request to the handler in
internal/submodelrepository/api/. - Handler validates input and calls the File SME builder/persistence logic.
- File is stored in PostgreSQL using Large Object API.
- GET requests to
/attachmentreturn the file, using model types for response formatting.
- See
DeveloperDocumentation/README.mdfor onboarding and godoc usage. - Explore
basyx-database-wiki/for database details. - Review OpenAPI specs in
cmd/*/openapi.yamland generated copies inpkg/*/api/openapi.yamlfor endpoint documentation.
For questions, open an issue or contact the maintainers.