You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comprehensive AI-powered agent built with Spring AI framework, featuring weather forecasting capabilities and secure OAuth integration.
4
+
5
+
## Related Documentation
6
+
7
+
This project is part of a larger microservices ecosystem:
8
+
9
+
-[Weather Service Documentation](../weather/README.md) - Weather forecast service with global coverage
10
+
11
+
## Project Overview
12
+
13
+
### Description
14
+
15
+
The Spring AI Agent is a demonstration of how to build modern AI-powered applications using the Spring AI framework. It provides weather forecasting capabilities through:
16
+
17
+
- Weather forecasts for any city worldwide
18
+
- Integration with external weather APIs
19
+
- Model Context Protocol (MCP) client for connecting to weather services
20
+
- Secure OAuth authentication and authorization
21
+
22
+
The application serves as the central component in a microservices architecture, connecting to the Weather service through the Model Context Protocol (MCP).
23
+
24
+
### Purpose
25
+
26
+
This application serves as:
27
+
28
+
1. A reference implementation for Spring AI integration with weather services
29
+
2. A demonstration of secure AI application patterns with OAuth
30
+
3. A practical example of building weather assistants with Spring Boot
31
+
4. A showcase for integrating with Amazon Bedrock and weather APIs
32
+
33
+
### Technology Stack
34
+
35
+
-**Java 21**: Latest LTS version with modern language features
36
+
-**Spring Boot 3.5.7**: Core framework for building the application
37
+
-**Spring AI 1.0.3**: AI integration framework
38
+
-**Spring Security**: OAuth 2.0 authentication and authorization
39
+
-**Amazon Bedrock**: AI model provider (Claude Sonnet 4)
40
+
-**Docker**: Containerization for application
41
+
42
+
## Security
43
+
44
+
### OAuth 2.0 Integration
45
+
46
+
The application implements OAuth 2.0 for secure authentication and authorization:
47
+
48
+
-**Authorization Server**: Integrated OAuth 2.0 authorization server
49
+
-**Resource Protection**: Secured API endpoints with JWT tokens
50
+
-**Token Validation**: Automatic JWT token validation and user context
51
+
52
+
## Getting Started
53
+
54
+
### Prerequisites
55
+
56
+
- Java 21 or higher
57
+
- Maven 3.8 or higher
58
+
- AWS account with Amazon Bedrock access
59
+
60
+
### Prerequisites for Full Functionality
61
+
62
+
Before starting the AI agent, ensure the required services are running:
63
+
64
+
1.**Start Authorization Server** (port 9000):
65
+
```bash
66
+
cd ../authorization-server/
67
+
mvn spring-boot:run
68
+
```
69
+
70
+
2.**Start Weather Service** (port 8083):
71
+
```bash
72
+
cd ../weather/
73
+
mvn spring-boot:run
74
+
```
75
+
76
+
These services provide OAuth authentication and weather forecasting tools that the AI agent uses.
77
+
78
+
#### Running the AI Agent
79
+
80
+
```bash
81
+
cd ai-agent/
82
+
mvn spring-boot:run
83
+
```
84
+
85
+
This will:
86
+
- Configure secure endpoints for weather data access
87
+
- Connect to the weather service via MCP for authenticated users only
88
+
- Connect to the authorization server for OAuth authentication
89
+
- Start the application on port 8080
90
+
91
+
#### Access Points
92
+
93
+
Once all applications are running, you can access:
94
+
95
+
-**Main Application**: `http://localhost:8080/`
96
+
97
+
### AWS Configuration
98
+
99
+
1. Configure AWS credentials:
100
+
```bash
101
+
aws configure
102
+
```
103
+
104
+
2. Ensure you have access to Amazon Bedrock and the required models (Claude Sonnet 4).
105
+
106
+
### Building and Running the Application
107
+
108
+
1.**Standard Build and Run:**
109
+
```bash
110
+
cd ai-agent/
111
+
mvn clean package
112
+
mvn spring-boot:run
113
+
```
114
+
115
+
2. The application will be available at:
116
+
```
117
+
http://localhost:8080/
118
+
```
119
+
120
+
### Authentication Flow
121
+
122
+
1. Navigate to `http://localhost:9000/` (authorization server)
123
+
2. Authenticate with your credentials
124
+
3. Use the authorization code to obtain an access token
125
+
4. Access weather endpoints with the Bearer token
126
+
127
+
## Contributing
128
+
129
+
Contributions are welcome! Please feel free to submit a Pull Request.
130
+
131
+
## License
132
+
133
+
This project is licensed under the MIT License - see the LICENSE file for details.
0 commit comments