โโโโโโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโ โโโ โโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโ โโโ โโโ โโโโโโ โโโโโโ โโโ
โโโโโโโโโโโโโโโ โโโโโโ โโโ โโโโโโโ โโโ โโโ โโโ โโโโโโ โโโโโโ โโโ
โโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโ โโโโโโโ
A radical journey through spec-driven development where documentation drives the future ๐
Welcome to the Spec2Cloud Introduction Lab, where we flip traditional development on its head! Instead of code-first development where documentation comes later (or never ๐ ), we embrace spec-driven development where specifications are the primary artifacts that drive everything else.
Think of it like this: in the retro arcade era, game designers started with specifications and design documents. Those specs drove the implementation. We're bringing that philosophy to cloud modernization! ๐น๏ธโจ
Spec2Cloud is a radical approach to application modernization where:
- ๐ Specifications come FIRST โ Architecture docs, API contracts, and data models are the source of truth
- ๐ค AI assists extraction โ Analyze legacy code to generate specs automatically
- ๐จ Specs drive generation โ Use those specs to build modern implementations
- โ๏ธ Cloud-native from specs โ Deploy to cloud platforms guided by your architecture specs
In this lab, you'll use the OpenShelf Library โ a retro library management app โ as your teaching playground! ๐
By completing this lab, you'll unlock these achievements:
- ๐ญ Spec-Driven Philosophy โ Understand why specs-first beats code-first
- ๐ ๏ธ Spec2Cloud Toolchain โ Install and configure the complete toolkit
- ๐ Legacy Code Analysis โ Point AI at old code and extract architectural knowledge
- ๐ Architecture Specifications โ Generate system architecture documents
- ๐ API Contract Generation โ Create OpenAPI specs from existing endpoints
- ๐๏ธ Data Model Extraction โ Document entity relationships and schemas
- ๐ Modernization Roadmap โ Use specs to guide your cloud migration
- โ Spec Validation โ Ensure implementations match specifications
ACHIEVEMENT UNLOCKED: SPEC MASTER ๐
Before you insert your coin and start playing, make sure you have:
- โ Node.js 18+ installed (Download here)
- โ Git CLI installed (Download here)
- โ Markdown proficiency (basic reading/writing)
- โ GitHub Copilot CLI installed (Setup guide)
- โ Visual Studio Code (or your favorite editor)
- โ A sense of adventure ๐ข
POWER-UP READY! โก
LOADING LEVEL 1... โโโโโโโโโโ 80%
Get the OpenShelf Library running in 3... 2... 1... GO! ๐
# Clone the repository
git clone https://github.com/EmeaAppGbb/appmodlab-spec2cloud-introduction.git
# Enter the game world
cd appmodlab-spec2cloud-introduction
# Install power-ups (dependencies)
npm install
# START THE GAME! ๐ฎ
npm start๐ Browse to: http://localhost:3000
SYSTEM ONLINE โจ You should see the OpenShelf Library running!
appmodlab-spec2cloud-introduction/
โ
โโโ ๐ src/ # Legacy application source code
โ โโโ app.js # Main Express server
โ โโโ routes/ # API route handlers
โ โโโ models/ # In-memory data models
โ โโโ public/ # Frontend HTML/CSS/JS
โ
โโโ ๐ specs/ # ๐ฏ TARGET: Your generated specs go here!
โ โโโ architecture/ # System architecture documents
โ โโโ api/ # OpenAPI/Swagger contracts
โ โโโ data/ # Entity relationship diagrams & schemas
โ
โโโ ๐ tests/ # Test suites
โ
โโโ package.json # Node.js dependencies
โโโ README.md # You are here! ๐
LEVEL MAP LOADED ๐บ๏ธ
The OpenShelf Library is a retro-styled library management system. It's intentionally simple but demonstrates real-world patterns perfect for spec extraction:
Core Features:
- ๐ Book Catalog โ Browse, search, and view book details
- ๐ฅ Member Management โ Register members and track accounts
- ๐ Loan Tracking โ Check out books, return them, track due dates
- ๐ Simple Reporting โ View loan history and popular books
Tech Stack (Legacy):
- ๐ข Node.js 14 (older version)
- ๐ Express.js (classic web framework)
- ๐พ In-Memory Storage (arrays/objects, no database!)
- ๐จ Vanilla JavaScript frontend
- ๐ No API documentation (the horror! ๐ฑ)
Why this app? It's complex enough to have meaningful architecture, APIs, and data models, but simple enough to understand in an afternoon. Perfect for learning Spec2Cloud! ๐ฏ
Here's what the legacy OpenShelf Library looks like when running:
Homepage โ Dashboard with live statistics:
Book Catalog โ Full inventory with search, genre badges, and availability tracking:
Add New Book โ Form for adding books to the catalog:
Library Members โ Member directory with status management:
Book Loans โ Active loans with status cards and filtering:
Checkout โ Book checkout form with member and book selection:
LOADING NEXT LEVEL... โโโโโโโโโโ 90%
Philosophy Time! ๐งโโ๏ธ
Traditional development:
Code โ (maybe) Docs โ (hopefully) Architecture Understanding โ Cloud Migration ๐ฐ
Spec-Driven Development:
Specs โ Clean Architecture โ Modern Code โ Cloud-Native Deployment ๐
Why Specs First?
- ๐ฏ Single Source of Truth โ Specs define the "what" independent of the "how"
- ๐ค AI-Friendly โ Modern AI excels at working with structured specifications
- ๐ Technology Agnostic โ Same specs, multiple implementations (Node, Python, Java, etc.)
- โ๏ธ Cloud-Ready โ Specs map naturally to cloud services and infrastructure
- ๐ Documentation that Lives โ Specs ARE the documentation, always in sync
INSIGHT GAINED ๐ก
MISSION: Get familiar with what you're modernizing!
-
Start the app (if not already running):
npm start
-
Browse the catalog ๐
- Open http://localhost:3000
- Check out the book listing
- Click into a book to see details
-
Register a member ๐ค
- Click "Members" in the nav
- Add a new member (use your name!)
- Note the member ID
-
Check out a book ๐ค
- Go back to books
- Click "Check Out" on any book
- Enter your member ID
- Success! You've borrowed a book! ๐
-
Return the book ๐ฅ
- Click "Return" on the same book
- Boom! Clean slate!
WORLD EXPLORED ๐บ๏ธ You now understand the user experience!
POWER-UP TIME! โก
The Spec2Cloud toolchain works through GitHub Copilot CLI. Let's set it up:
-
Verify Copilot CLI is installed:
gh copilot --version
-
Initialize Spec2Cloud in your project:
# Use Copilot CLI to bootstrap Spec2Cloud gh copilot suggest "Set up Spec2Cloud for analyzing a Node.js Express application"
-
Verify the setup:
# Check that spec directories exist ls -la specs/
TOOLCHAIN READY ๐ง
TIME TO SCAN THE CODEBASE! ๐
Use Spec2Cloud to analyze the legacy app:
# Analyze the entire src/ directory
gh copilot "Analyze the Node.js application in ./src and generate architecture specifications. Save to ./specs/architecture/"What's happening?
- ๐ค AI reads your source code
- ๐ง Identifies patterns, components, and relationships
- ๐ Generates structured specification documents
- ๐พ Saves them to your specs/ folder
SCAN COMPLETE โ
BOSS ENCOUNTER: THE ARCHITECTURE DOCUMENT ๐
Navigate to specs/architecture/ and open the generated architecture spec:
cd specs/architecture
# Open the generated markdown file
code system-architecture.mdWhat to look for:
- ๐๏ธ System Components โ Server, routes, models, frontend
- ๐ Component Interactions โ How pieces talk to each other
- ๐พ Data Flow โ Where data comes from and goes to
- ๐ฏ Design Patterns โ MVC? REST? What patterns are in use?
โ ๏ธ Technical Debt โ What needs modernization?
Example findings:
- "In-memory storage creates scalability bottleneck" ๐
- "No API versioning strategy" ๐ข
- "Frontend tightly coupled to backend" ๐
ARCHITECTURE MAPPED ๐บ๏ธ
MISSION: DOCUMENT THE APIs ๐ก
Check out the generated API specifications:
cd specs/api
# View the OpenAPI spec
code openapi.yamlWhat you'll see:
- ๐ฃ๏ธ Endpoints โ GET /books, POST /members, etc.
- ๐ฅ Request Schemas โ What data to send
- ๐ค Response Schemas โ What data you get back
โ ๏ธ Error Responses โ 404, 500, etc.- ๐ Security โ Authentication/authorization (or lack thereof!)
Example endpoint:
/api/books:
get:
summary: List all books
responses:
200:
description: Array of books
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Book'API CONTRACT LOCKED ๐
EXAMINE THE DATA LAYER ๐พ
Open the data model specifications:
cd specs/data
# Check entity models
code entity-model.mdWhat's documented:
- ๐ Entities โ Book, Member, Loan
- ๐ Attributes โ Fields and data types
- ๐ Relationships โ One-to-many, many-to-many
- ๐ Constraints โ Required fields, validations
- ๐๏ธ Current Implementation โ In-memory arrays (scary!)
Example entity:
### Book
- id: String (unique)
- title: String (required)
- author: String (required)
- isbn: String
- available: Boolean
- checkedOutBy: String (Member ID, nullable)DATA MODEL EXTRACTED ๐ฏ
CUSTOMIZE YOUR DESTINY โจ
Now the magic happens! Edit the specs to guide modernization:
-
Open architecture spec and add modernization notes:
## Target Architecture - โ Migrate from Express โ Fastify (better performance) - โ Replace in-memory storage โ PostgreSQL - โ Add Redis caching layer - โ Containerize with Docker
-
Enhance API specs with new requirements:
# Add authentication security: - bearerAuth: [] # Add pagination parameters: - name: page in: query schema: type: integer
-
Update data models for the database:
### Book (PostgreSQL Schema) - id: UUID PRIMARY KEY - title: VARCHAR(255) NOT NULL - author: VARCHAR(255) NOT NULL - isbn: VARCHAR(13) UNIQUE - available: BOOLEAN DEFAULT true - created_at: TIMESTAMP - updated_at: TIMESTAMP
SPECS REFINED ๐
RECONSTRUCTION TIME! ๐๏ธ
Use the refined specs to guide building the modern version:
# Create a new modern implementation folder
mkdir modern-implementation
cd modern-implementation
# Initialize new Node.js project
npm init -y
# Install modern stack
npm install fastify @fastapi/postgres @fastapi/redis
# Use Copilot to generate code from specs
gh copilot "Generate a Fastify server implementation based on the OpenAPI spec at ../specs/api/openapi.yaml"What's different?
- ๐ Fastify instead of Express (faster!)
- ๐ PostgreSQL instead of in-memory (persistent!)
- ๐ฆ TypeScript for type safety
- ๐ณ Docker for containerization
- โ๏ธ Cloud-ready architecture
NEW IMPLEMENTATION RISING ๐
FINAL BOSS: VERIFICATION ๐พ
Ensure your new implementation matches the specs:
-
Run API contract tests:
# Install OpenAPI validator npm install --save-dev jest-openapi # Run tests against the spec npm test
-
Check database schema:
# Compare PostgreSQL schema to data model spec psql -d openshelf -c "\d books"
-
Verify functionality:
- Browse books โ
- Register members โ
- Check out/return โ
- Performance better โ
- Data persists โ
ALL SYSTEMS GREEN ๐ข
๐ CONGRATULATIONS! LEVEL COMPLETE! ๐
THE FINAL FORM ๐ฆ
Your modernized OpenShelf Library will be:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Cloud Load Balancer โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ณ Docker Container (Fastify App) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Node.js 20 + Fastify โ โ
โ โ - REST API endpoints โ โ
โ โ - JWT authentication โ โ
โ โ - Input validation โ โ
โ โโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโ โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ ๐ PostgreSQL โ โ ๐ด Redis โ
โ - Books โ โ - Sessions โ
โ - Members โ โ - Cache โ
โ - Loans โ โโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโ
Tech Stack:
- Runtime: Node.js 20 LTS
- Framework: Fastify 4.x
- Database: PostgreSQL 15
- Cache: Redis 7
- Container: Docker + Docker Compose
- Cloud: Azure Container Apps / AWS ECS / GCP Cloud Run
EVOLUTION COMPLETE ๐
TIME TO BEAT: 2-3 hours โฐ
Speedrun Categories:
- ๐ฅ Bronze (Casual): 3+ hours โ Take your time, enjoy the journey
- ๐ฅ Silver (Normal): 2-3 hours โ Steady pace, good understanding
- ๐ฅ Gold (Expert): 1-2 hours โ You've done this before!
- ๐ Diamond (Speedrun): <1 hour โ Spec2Cloud master! ๐
READY PLAYER ONE? ๐ฎ
KNOWLEDGE BASE UNLOCKED ๐
- Spec2Cloud Official Docs ๐
- OpenAPI Specification ๐
- Fastify Documentation ๐
- PostgreSQL Docs ๐
- Swagger Editor โ Edit OpenAPI specs visually
- dbdiagram.io โ Design database schemas
- GitHub Copilot CLI โ AI pair programmer
- Spec2Cloud Discord ๐ฌ
- GitHub Discussions ๐ญ
Track your progress:
- ๐ฏ Started the legacy app
- ๐ Explored the codebase
- ๐ ๏ธ Installed Spec2Cloud toolchain
- ๐ Generated architecture specs
- ๐ Generated API contracts
- ๐๏ธ Generated data models
- โจ Refined specs for modernization
- ๐๏ธ Built modern implementation
- โ Validated against specs
- ๐ Deployed to cloud
COMPLETE ALL ACHIEVEMENTS TO BECOME A SPEC2CLOUD WIZARD ๐งโโ๏ธโจ
FOR THE BRAVE โ๏ธ
- ๐ Security Quest โ Add JWT authentication to all endpoints
- ๐ Analytics Arena โ Add book popularity tracking and reporting
- ๐ Search Saga โ Implement full-text search with Elasticsearch
- ๐ Multi-Tenant Mission โ Support multiple libraries in one system
- ๐ฑ Mobile Madness โ Create a React Native app using your API specs
- ๐ค AI Assistant โ Add a chatbot that recommends books
EXTRA LIVES EARNED ๐
โโโโโโโ โโโโโโโ โโโโ โโโ โโโโโโโ โโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโ โโโ โโโโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโ
โโโ โโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โโโโโโ โโโ โโโ โโโโโโโโโโโ
โโโโโโโ โโโโโโโ โโโ โโโโโ โโโโโโโ โโโ โโโโโโ โโโ โโโ โโโโโโโโโโโ
You've mastered Spec-Driven Development and unlocked the power of Spec2Cloud! ๐
Your Score: LEGENDARY ๐ฏ Rank: Spec Master ๐ Next Level: Production deployment! โ๏ธ
Stuck? No worries! ๐ค
- ๐ฌ Ask in GitHub Discussions
- ๐ Report bugs in Issues
- ๐ง Email the lab team: appmod-labs@microsoft.com
- ๐ค Use GitHub Copilot CLI:
gh copilot explain "how does spec2cloud work?"
WE'RE HERE TO HELP! ๐ค
MIT License - Share, modify, and enjoy! ๐
Created with ๐ by:
- Marco Antonio Silva โ Lab Designer ๐จ
- The Azure App Modernization GBB Team ๐
- GitHub Copilot โ AI Assistant ๐ค
- You โ The Spec2Cloud Pioneer! ๐
Special Thanks:
- The Node.js community ๐ข
- The OpenAPI Initiative ๐
- Everyone who believes specs > chaos โจ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ THANK YOU FOR PLAYING! โ
โ INSERT COIN TO CONTINUE... ๐ช โ
โ โ
โ โ Next Lab: Spec2Cloud Advanced โ
โ โ Coming Soon: Multi-Cloud Deploy โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
PRESS START TO BEGIN YOUR SPEC2CLOUD JOURNEY ๐ฎโจ
Made with โค๏ธ and a whole lot of โ in 2024





