How wefantasy/fabriclearn works
Project Type and Purpose
• This is an educational, full-stack Hyperledger Fabric learning project (“FabricLearn”) that incrementally demonstrates how to deploy and operate a permissioned blockchain network. It packages each stage of the network lifecycle (from test-network to multi-host deployment, dynamic org/peer updates, CouchDB integration, SDK/Gateway usage, complex contracts) into self-contained directories with Docker Compose, configuration, scripts, chaincode, and client code.
File-Structure Analysis
• Top-level directories (0_TestNetworkExplain, 1_3Org2Peer1Orderer1TLS, …, 7_CouchDBAndComplexContract) each encapsulate one “stage” of network topology and feature set.
• Within each stage:
• compose/ → Docker Compose YAMLs to launch CAs, orderers, peers, CouchDB (when used).
• config/ → Fabric configtx and core/orderer configuration files.
• envpeer* → CLI environment variable scripts for each peer.
• *.sh scripts (0_Restart.sh, 1_RegisterUser.sh, …) orchestrate the network lifecycle.
• Chaincode directories (asset-transfer-basic-go, project_contract, etc.) hold smart contracts and their unit tests.
• Later stages add contract-gateway and contract-sdk Go applications as clients.
Key Components
a. Certificate Authorities (CAs)
• A root TLS-CA (e.g., council.fantasy.com) issuing TLS certs for all nodes.
• Org-specific CAs (soft.fantasy.com, hard.fantasy.com, web.fantasy.com, orderer.fantasy.com) issuing identity certs (MSP) for peers, orderers, admins, users.
b. Ordering Service
• Solo or Raft cluster of orderer nodes (often managed by the “council” org).
c. Peer Nodes
• One peer per org (soft, hard, web), each with:
• MSP (identity materials)
• TLS materials
• CouchDB state database (in stages that require rich queries)
d. Chaincode Containers
• Deployed and instantiated by peers, executing business logic and persisting state.
e. Client-side Components
• CLI containers/scripts (Bash + peer CLI) that invoke lifecycle commands.
• Go Gateway application (contract-gateway) and Go SDK application (contract-sdk) illustrating programmatic access.
f. Supporting Artifacts
• Configuration transactions (configtx.yaml, channel genesis blocks).
• Docker networks facilitating inter-container communication.
Relationships and Interactions
1. CA → Issues TLS certs and identity certs to Orderer and Peer nodes, Admins, Users.
2. CLI / Client App → Enrolls with CA to obtain certificates → Uses peer CLI or SDK/Gateway to:
a. Submit channel creation and join requests to Orderer.
b. Install and instantiate chaincode on Peers.
c. Submit endorsement proposals to Peers → Peers endorse → Client collects endorsements → Broadcasts transaction to Orderer → Orderer orders blocks.
d. Peers validate and commit blocks, update CouchDB (if enabled).
3. Docker Compose services connect via defined Docker networks.
4. Scripts sequence the above operations in each stage.
Architectural Patterns and Design Principles
• Micro-service style: each network node (CA, Peer, Orderer, CouchDB) runs in its own container with clear responsibilities.
• Infrastructure-as-code: all network topology and lifecycle steps are codified in Bash scripts and YAML.
• Separation of concerns:
• Certificates (CAs) vs. ledger services (Peers/Orderers) vs. state database (CouchDB) vs. client apps.
• Network configuration (configtx, core/orderer yaml) separated from runtime data (MSP, ledger).
• Incremental complexity: tutorials progress from a basic test network to multi-host, dynamic org addition/removal, complex contracts, and SDK usage.
Final Recommendations
• Incrementally annotate additional features per tutorial stage.
• Every component from the file tree (compose files, config, chaincode, clients) is represented or noted in callouts.
• This level of detail will ensure the principal software engineer sees exactly how each directory, script, and container maps to the running Fabric network.