How ignaciocorball/go-blockchain works
Project Type and Purpose
• This is a backend-focused blockchain application written in Go.
• Purpose: expose a RESTful API for creating transactions, querying blocks, deploying/executing smart contracts, all backed by a PoS blockchain core and a BadgerDB storage layer.
File Structure
• Top‐level modules:
• api/ → HTTP server (Echo framework)
• blockchain/ → Core blockchain logic (blocks, transactions, PoS consensus, wallet)
• contracts/ → Smart contract framework (deployment, execution, state)
• storage/ → Persistence layer (BadgerDB integration)
• main.go → Application entrypoint, ties everything together
• Config/build files: go.mod/go.sum
• Supporting artifacts: Postman collection for API testing
Key README Insights
• Stacks: Go 1.16+, Echo, BadgerDB
• Features: PoS consensus, smart contracts, ECDSA signing, REST endpoints
• Roadmap hints at P2P network layer (not yet implemented)
Main Architectural Components
a. Client Applications (e.g., Postman, front-end dApp)
b. API Server (Echo)
c. Blockchain Core
d. Smart Contract Engine
e. Storage Layer (BadgerDB)
f. Cryptographic Wallet Module
Interactions and Data Flows
1) Client → API Server: HTTP calls (/transaction, /block, /contract)
2) API Server → Blockchain Core:
• Transaction creation → Core validates & signs via wallet
• Block querying → Core retrieves from storage
• Contract deployment/execution → Delegates to Contracts module
3) Blockchain Core ↔ Storage Layer:
• Persist/Retrieve blocks, transactions, UTXOs, contract state
4) Blockchain Core → Consensus module: decides new block producer (PoS)
5) Contracts module → Storage: store contract code and state
Architectural Patterns & Principles
• Layered architecture: API layer, service/domain layer (blockchain + contracts), persistence layer
• Single‐binary monolith with well‐separated Go packages
• Dependency injection via Go interfaces if desired (e.g., for storage, consensus)
• Modular separation: each directory = self‐contained component
Final Advice
• Be very detailed: capture each major package as a component.