AXIOM is a conversational AI agent built with Node.js and Express that uses Google Gemini API to summarize and extract key factual claims from user-provided content. The architecture is designed to support future blockchain-based verification integration.
- Content Summarization: Generate concise, accurate summaries of any text content
- Factual Claims Extraction: Identify and extract key factual statements from content
- RESTful API: Clean, well-documented API endpoints
- Beginner-Friendly: Well-commented, readable code structure
- Blockchain-Ready: Architecture designed for future blockchain verification integration
- Error Handling: Comprehensive error handling and validation
Axiom-AiAgent/
โโโ backend/
โ โโโ ai-agent/
โ โ โโโ geminiAgent.js # Google Gemini API integration
โ โโโ config/
โ โ โโโ config.js # Environment configuration
โ โโโ controllers/
โ โ โโโ aiController.js # Request handlers
โ โโโ middleware/
โ โ โโโ errorHandler.js # Error handling
โ โ โโโ requestLogger.js # Request logging
โ โโโ routes/
โ โ โโโ aiRoutes.js # API routes definition
โ โโโ server.js # Main server file
โโโ .env.example # Environment variables template
โโโ .gitignore # Git ignore rules
โโโ package.json # Project dependencies
โโโ README.md # This file
- Node.js (v14 or higher)
- npm (v6 or higher)
- Google Gemini API key (Get one here)
-
Clone the repository
git clone https://github.com/ayush-code303/Axiom-AiAgent.git cd Axiom-AiAgent -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Edit
.envand add your Google Gemini API key:GEMINI_API_KEY=your_actual_api_key_here PORT=3000 NODE_ENV=development -
Start the server
npm start
The server will start on
http://localhost:3000
GET /
Returns welcome message and available endpoints.
GET /api/ai/health
Check if the service is running.
Response:
{
"success": true,
"message": "AXIOM AI Agent is running",
"timestamp": "2024-01-01T00:00:00.000Z",
"version": "1.0.0"
}POST /api/ai/summarize
Generate a concise summary of provided content.
Request Body:
{
"content": "Your long text content here that you want to summarize..."
}Response:
{
"success": true,
"summary": "Concise summary of the content...",
"originalLength": 1000,
"summaryLength": 150,
"timestamp": "2024-01-01T00:00:00.000Z",
"verificationHash": null
}POST /api/ai/extract-claims
Extract key factual claims from provided content.
Request Body:
{
"content": "Your text content containing factual claims..."
}Response:
{
"success": true,
"claims": [
{
"claim": "First factual claim extracted",
"extracted": true
},
{
"claim": "Second factual claim extracted",
"extracted": true
}
],
"totalClaims": 2,
"rawResponse": "Full AI response...",
"timestamp": "2024-01-01T00:00:00.000Z",
"verificationHash": null,
"blockchainReady": true
}Summarize Content:
curl -X POST http://localhost:3000/api/ai/summarize \
-H "Content-Type: application/json" \
-d '{
"content": "Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to natural intelligence displayed by animals including humans. AI research has been defined as the field of study of intelligent agents, which refers to any system that perceives its environment and takes actions that maximize its chance of achieving its goals."
}'Extract Claims:
curl -X POST http://localhost:3000/api/ai/extract-claims \
-H "Content-Type: application/json" \
-d '{
"content": "The Earth orbits the Sun once every 365.25 days. Water boils at 100 degrees Celsius at sea level. The speed of light in vacuum is approximately 299,792,458 meters per second."
}'// Summarize content
const summarizeContent = async (text) => {
const response = await fetch('http://localhost:3000/api/ai/summarize', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content: text })
});
const data = await response.json();
console.log(data.summary);
};
// Extract claims
const extractClaims = async (text) => {
const response = await fetch('http://localhost:3000/api/ai/extract-claims', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content: text })
});
const data = await response.json();
console.log(data.claims);
};- Never commit your
.envfile or expose your API keys - The
.env.examplefile is provided as a template - API keys should be kept secure and rotated regularly
- Input validation is implemented to prevent malicious requests
The AXIOM architecture is designed with blockchain integration in mind:
- Verification Hashes: Response objects include
verificationHashfields (currently null) - Blockchain-Ready Flag: Claims responses include
blockchainReady: true - Modular Design: The AI agent module is independent and can easily interface with blockchain smart contracts
- Timestamping: All responses include ISO timestamps for audit trails
Future enhancements will include:
- Hash generation for content integrity verification
- Smart contract integration for claim verification
- Decentralized storage of summaries and claims
- Verification badges for authenticated content
This project is built with beginners in mind:
- Clear Code Structure: Organized into logical folders
- Extensive Comments: Every function and module is documented
- Readable Code: Descriptive variable names and clean formatting
- Error Messages: Helpful error messages for debugging
The modular architecture makes it easy to extend:
- New AI Capabilities: Add functions to
backend/ai-agent/geminiAgent.js - New Endpoints: Add routes to
backend/routes/aiRoutes.js - New Controllers: Add handlers to
backend/controllers/aiController.js
MIT License - feel free to use this project for your hackathon or learning purposes!
This is a hackathon project, but contributions and improvements are welcome!
Issue: "GEMINI_API_KEY is not set"
- Make sure you've created a
.envfile based on.env.example - Verify your API key is correct and active
Issue: "Failed to summarize content"
- Check your internet connection
- Verify your Gemini API key is valid
- Ensure the content length is within limits (10-50,000 characters)
Issue: Server won't start
- Check if port 3000 is already in use
- Try changing the PORT in your
.envfile
For questions or issues, please open an issue on GitHub.
Built with โค๏ธ for hackathons and learning