Generative-AI-for-beginners-java / pcm
AGENTS.md559 starsChanged 5 months agoMITView on GitHub
Dis na educashonal repo wey you fit use learn Generative AI development with Java. E dey give una complete hands-on course wey cover Large Language Models (LLMs), prompt engineering, embeddings, RAG (Retrieval-Augmented Generation), plus di Model Context Protocol (MCP). Key Technologies: - Java 21 - Spring Boot 3.5.x - Spring AI 1.1.x - Maven - LangChain4j - Azure AI Foundry, Azure OpenAI, and OpenAI SDKs Architecture: - Plenty standalone Spring Boot apps organized by chapters - Sample projects wey show…
- Reads credentials
- Deletes or force-pushes
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository55 other files it gives its agents.
- AGENTS.mdAGENTS.md
- translations/ar/AGENTS.mdAGENTS.md
- translations/bg/AGENTS.mdAGENTS.md
- translations/bn/AGENTS.mdAGENTS.md
- translations/cs/AGENTS.mdAGENTS.md
- translations/da/AGENTS.mdAGENTS.md
- translations/de/AGENTS.mdAGENTS.md
- translations/el/AGENTS.mdAGENTS.md
- translations/en/AGENTS.mdAGENTS.md
- translations/es/AGENTS.mdAGENTS.md
- translations/et/AGENTS.mdAGENTS.md
- translations/fa/AGENTS.mdAGENTS.md
- translations/fi/AGENTS.mdAGENTS.md
- translations/fr/AGENTS.mdAGENTS.md
- translations/he/AGENTS.mdAGENTS.md
- translations/hi/AGENTS.mdAGENTS.md
- translations/hr/AGENTS.mdAGENTS.md
- translations/hu/AGENTS.mdAGENTS.md
- translations/id/AGENTS.mdAGENTS.md
- translations/it/AGENTS.mdAGENTS.md
- translations/ja/AGENTS.mdAGENTS.md
- translations/km/AGENTS.mdAGENTS.md
- translations/kn/AGENTS.mdAGENTS.md
- translations/ko/AGENTS.mdAGENTS.md
- translations/lt/AGENTS.mdAGENTS.md
- translations/ml/AGENTS.mdAGENTS.md
- translations/mr/AGENTS.mdAGENTS.md
- translations/ms/AGENTS.mdAGENTS.md
- translations/my/AGENTS.mdAGENTS.md
- translations/ne/AGENTS.mdAGENTS.md
- translations/nl/AGENTS.mdAGENTS.md
- translations/no/AGENTS.mdAGENTS.md
- translations/pa/AGENTS.mdAGENTS.md
- translations/pl/AGENTS.mdAGENTS.md
- translations/pt-BR/AGENTS.mdAGENTS.md
- translations/pt-PT/AGENTS.mdAGENTS.md
- translations/ro/AGENTS.mdAGENTS.md
- translations/ru/AGENTS.mdAGENTS.md
- translations/sk/AGENTS.mdAGENTS.md
- translations/sl/AGENTS.mdAGENTS.md
- translations/sr/AGENTS.mdAGENTS.md
- translations/sv/AGENTS.mdAGENTS.md
- translations/sw/AGENTS.mdAGENTS.md
- translations/ta/AGENTS.mdAGENTS.md
- translations/te/AGENTS.mdAGENTS.md
- translations/th/AGENTS.mdAGENTS.md
- translations/tl/AGENTS.mdAGENTS.md
- translations/tr/AGENTS.mdAGENTS.md
- translations/uk/AGENTS.mdAGENTS.md
- translations/ur/AGENTS.mdAGENTS.md
- translations/vi/AGENTS.mdAGENTS.md
- translations/zh-CN/AGENTS.mdAGENTS.md
- translations/zh-HK/AGENTS.mdAGENTS.md
- translations/zh-MO/AGENTS.mdAGENTS.md
- translations/zh-TW/AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
22 rules. About 0 are common, 14 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 159
Test files dey use JUnit 5 (Jupiter)
- Very specific: line 160
Test classes dey src/test/java/
- Very specific: line 166
Start app with mvn spring-boot:run
- Distinctive: line 167
Test endpoints or interact with CLI
- Distinctive: line 168
Check say wetin happen follow wetin README.md talk for each project
- Distinctive: line 172
Make sure say your account get Cognitive Services OpenAI User role for the resource
- Distinctive: line 173
Test content filtering with responsible AI example for Chapter 5
- Distinctive: line 179
Style: Follow normal Java conventions
- Very specific: line 187
Use @Service for business logic
- Very specific: line 188
Use @RestController for REST endpoints
- Very specific: line 191
Use @Tool annotation for MCP-exposed methods
- Distinctive: line 219
Add JavaDoc for public APIs
- Distinctive: line 220
Put comments wey explain complex AI work
- Distinctive: line 221
Document MCP tool descriptions well well
- Very specific: line 265
Use managed identity instead of az login for keyless auth
- Distinctive: line 271
No design for production deployment as e be
- Distinctive: line 273
Check each project README for deployment notes
- Distinctive: line 333
Follow chapters one by one (01 → 05)
- Distinctive: line 350
Use correct batch sizes for embeddings
- Very specific: line 355
No ever commit .env files (dem dey .gitignore already)
- Very specific: line 357
Use managed identities in Azure.
- Distinctive: line 358
Follow responsible AI rules for Chapter 5
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Project Overview
Dis na educashonal repo wey you fit use learn Generative AI development with Java. E dey give una complete hands-on course wey cover Large Language Models (LLMs), prompt engineering, embeddings, RAG (Retrieval-Augmented Generation), plus di Model Context Protocol (MCP).
Key Technologies:
- Java 21
- Spring Boot 3.5.x
- Spring AI 1.1.x
- Maven
- LangChain4j
- Azure AI Foundry, Azure OpenAI, and OpenAI SDKs
Architecture:
- Plenty standalone Spring Boot apps organized by chapters
- Sample projects wey show different AI patterns
- GitHub Codespaces-ready with pre-configured dev containers
Setup Commands
Prerequisites
- Java 21 or pass
- Maven 3.x
- Azure subscription wey get Azure AI Foundry model deployment (make you deploy with
azd up) - Azure CLI (
az) and Azure Developer CLI (azd), you don sign for keyless auth
Environment Setup
Option 1: GitHub Codespaces (Recommended)
# Fork di repository den create a codespace from GitHub UI
# Di dev container go automatically install all dependencies
# Wait about 2 minutes for environment setupOption 2: Local Dev Container
# Clone di repository
git clone https://github.com/microsoft/Generative-AI-for-beginners-java.git
cd Generative-AI-for-beginners-java
# Open am for VS Code wit Dev Containers extension
# Reopen am for Container wen e ask youOption 3: Local Setup
# Install all di tins wey e need
sudo apt-get update
sudo apt-get install -y maven openjdk-21-jdk
# Make sure say e don install well well
java -version
mvn -versionConfiguration
Azure AI Foundry Setup (keyless, recommended):
# Set up di Foundry account + model deployments as code
cd 02-SetupDevEnvironment
azd auth login
az login
azd up
# azd dey write examples/basic-chat-azure/.env wit your endpoint (no key)Manual endpoint config:
# If you no use azd, set di endpoint yourself (auth go still keyless if you use az login)
cd 02-SetupDevEnvironment/examples/basic-chat-azure
cp .env.example .env
# Edit .env: AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com/Development Workflow
Project Structure
/
├── 01-IntroToGenAI/ # Chapter 1: Introduction
├── 02-SetupDevEnvironment/ # Chapter 2: Environment setup
│ └── examples/ # Working examples
├── 03-CoreGenerativeAITechniques/ # Chapter 3: Core techniques
├── 04-PracticalSamples/ # Chapter 4: Sample projects
│ ├── calculator/ # MCP service example
│ ├── foundrylocal/ # Local model integration
│ └── petstory/ # Multi-modal app
├── 05-ResponsibleGenAI/ # Chapter 5: Responsible AI
└── translations/ # Multi-language supportRunning Applications
How to run Spring Boot app:
cd [project-directory]
mvn spring-boot:runBuilding project:
cd [project-directory]
mvn clean installStart MCP Calculator Server:
cd 04-PracticalSamples/calculator
mvn spring-boot:run
# Server dey run for http://localhost:8080Run Client Examples:
# After you don start di server for anoda terminal
cd 04-PracticalSamples/calculator
# Direct MCP client
mvn exec:java -Dexec.mainClass="com.microsoft.mcp.sample.client.SDKClient"
# AI-powered client (you go need AZURE_OPENAI_ENDPOINT + az login)
mvn exec:java -Dexec.mainClass="com.microsoft.mcp.sample.client.LangChain4jClient"
# Interactive bot
mvn exec:java -Dexec.mainClass="com.microsoft.mcp.sample.client.Bot"Hot Reload
Spring Boot DevTools dey inside projects wey support hot reload:
# Changes wey you do for Java files go automatically reload wen you save am
mvn spring-boot:runTesting Instructions
Running Tests
Run all tests for project:
cd [project-directory]
mvn testRun tests with detailed output:
mvn test -XRun specific test class:
mvn test -Dtest=CalculatorServiceTestTest Structure
- Test files dey use JUnit 5 (Jupiter)
- Test classes dey
src/test/java/ - Client examples for calculator project dey
src/test/java/com/microsoft/mcp/sample/client/
Manual Testing
Plenty examples na interactive apps wey need manual testing:
- Start app with
mvn spring-boot:run - Test endpoints or interact with CLI
- Check say wetin happen follow wetin README.md talk for each project
Testing with Azure AI Foundry
- Sign in with
az loginbefore you run examples (keyless auth) - Make sure say your account get Cognitive Services OpenAI User role for the resource
- Test content filtering with responsible AI example for Chapter 5
Code Style Guidelines
Java Conventions
- Java Version: Java 21 with new features
- Style: Follow normal Java conventions
- Naming:
- Classes: PascalCase
- Methods/variables: camelCase
- Constants: UPPER_SNAKE_CASE
- Package names: lowercase
Spring Boot Patterns
- Use
@Servicefor business logic - Use
@RestControllerfor REST endpoints - Configure by
application.ymlorapplication.properties - Environment variables better pass hardcoded values
- Use
@Toolannotation for MCP-exposed methods
File Organization
src/
├── main/
│ ├── java/
│ │ └── com/microsoft/[component]/
│ │ ├── [Component]Application.java
│ │ ├── config/
│ │ ├── controller/
│ │ ├── service/
│ │ └── exception/
│ └── resources/
│ ├── application.yml
│ └── static/
└── test/
└── java/
└── com/microsoft/[component]/Dependencies
- Manage with Maven
pom.xml - Spring AI BOM for version control
- LangChain4j for AI plugins
- Spring Boot starter parent for Spring dependencies
Code Comments
- Add JavaDoc for public APIs
- Put comments wey explain complex AI work
- Document MCP tool descriptions well well
Build and Deployment
Building Projects
Build without run test:
mvn clean install -DskipTestsBuild with all checks:
mvn clean installPackage application:
mvn package
# Dey create JAR inside target/ folderOutput Directories
- Compiled classes:
target/classes/ - Test classes:
target/test-classes/ - JAR files:
target/*.jar - Maven artifacts:
target/
Environment-Specific Configuration
Development:
# application.yml (keyless - no api-key; auth via DefaultAzureCredential)
spring:
ai:
azure:
openai:
endpoint: ${AZURE_OPENAI_ENDPOINT}
chat:
options:
deployment-name: ${AZURE_OPENAI_DEPLOYMENT:gpt-4o-mini}Production:
- Use managed identity instead of
az loginfor keyless auth - Point
AZURE_OPENAI_ENDPOINTto your production Foundry resource - Manage config with environment variables or Azure Key Vault
Deployment Considerations
- Na educational repo with sample apps
- No design for production deployment as e be
- Samples dey show patterns to fit adapt for production
- Check each project README for deployment notes
Additional Notes
Azure AI Foundry
- Keyless auth: connect with Microsoft Entra ID — no API keys to manage
- Provisioned as code: Bicep + azd (
azd up) create account and model deployments - Same OpenAI-compatible code dey run locally (
az login) and for Azure (managed identity)
Working with Multiple Projects
Each sample project na standalone:
# Comot go one particular project
cd 04-PracticalSamples/[project-name]
# Each get im own pom.xml wey dem fit build by imsef
mvn clean installCommon Issues
Java Version Mismatch:
# Make sure say Java 21 correct
java -version
# Change JAVA_HOME if e need am
export JAVA_HOME=/usr/lib/jvm/msopenjdk-currentDependency Download Problems:
# Clear Maven cache and try again
rm -rf ~/.m2/repository
mvn clean installEndpoint or Sign-in Missing:
# Set di endpoint for di current session and sign in (no need key)
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
az login
# Or use one .env file for di project directory
echo "AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/" > .envPort Already Use:
# Spring Boot dey use port 8080 by default
# Change for application.properties:
server.port=8081Multi-Language Support
- Documentation dey for 45+ languages through automated translation
- Translations dey
translations/folder - Translation controlled by GitHub Actions workflow
Learning Path
- Start with 02-SetupDevEnvironment
- Follow chapters one by one (01 → 05)
- Complete hands-on examples inside each chapter
- Explore sample projects for Chapter 4
- Learn responsible AI behavior for Chapter 5
Development Container
The .devcontainer/devcontainer.json dey setup:
- Java 21 development environment
- Maven pre-installed
- VS Code Java extensions
- Spring Boot tools
- GitHub Copilot integration
- Docker-in-Docker support
- Azure CLI
Performance Considerations
- Azure AI Foundry deployments get per-minute token/request limits
- Use correct batch sizes for embeddings
- Think about caching for repeat API calls
- Monitor token use to save cost
Security Notes
- No ever commit
.envfiles (dem dey.gitignorealready) - Better use keyless auth (Microsoft Entra ID) pass API keys
- Use managed identities in Azure;
az loginfor local development - Follow responsible AI rules for Chapter 5
<!-- CO-OP TRANSLATOR DISCLAIMER START -->Disclaimer: Dis document don translate wit AI translation service Co-op Translator. Even tho we dey try make am correct, abeg make you know say automated translation fit get errors or mistakes. Di original document for dia own language na im be di correct source. For important info, make person wey sabi human translation do am. We no go responsible for any misunderstanding or wrong understanding wey fit happen because of dis translation.
<!-- CO-OP TRANSLATOR DISCLAIMER END -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

