A smart, privacy-aware, academically-structured, cost-optimized AI proxy built for the AMD Singapore Hackathon 2025
Aegis Learn is a Multi-Mode Intelligent AI Platform that sits between your application and an LLM (like Gemini/GPT-4). Instead of calling an LLM directly and getting raw text, the middleware adds structure, privacy, efficiency, and intelligence to every request.
This project was developed for the AMD Slingshot Hackathon, showcasing advanced AI middleware capabilities with privacy protection, academic structuring, and intelligent UI generation.
- Node.js 18+ and npm or yarn
- Python 3.9+ and pip
- Google Gemini API Key
-
Clone the repository
git clone https://github.com/your-username/aegis-learn.git cd Aegis-learn -
Backend Setup
cd middleware pip install -r requirements.txt # Configure environment cp .env.example .env # Edit .env with your API keys
-
Frontend Setup
cd ../website npm install cp .env.example .env.local # Edit .env.local with API URL
-
Start the Backend (Terminal 1)
cd middleware python main.py # Backend runs on http://localhost:8000
-
Start the Frontend (Terminal 2)
cd website npm run dev # Frontend runs on http://localhost:3001
-
Access the Application
- Frontend: http://localhost:3001
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- PII Redaction: Automatically strips names, emails, phone numbers, Aadhaar numbers, medical terms, and financial identifiers
- Risk Scoring: Real-time content risk assessment
- Audit Trails: Complete logging for compliance
- Structured Responses: 2-mark answers, 13-mark answers (with diagrams + 6 points + conclusions)
- Multiple Formats: MCQs, Case Studies, and academic essays
- Intent Analysis: Differentiates casual chat from academic questions
- Smart Schema Selection: Automatically chooses the right response format
- Natural Language to UI: Convert descriptions into functional interfaces
- A2UI v0.9 Specification: Industry-standard UI generation format
- Interactive Components: Buttons, forms, inputs, and layouts
- Real-time Rendering: Live preview of generated interfaces
- Google Classroom Integration: Fetch real assignment deadlines
- Intelligent Reminders: 48-hour advance notifications
- Academic Format Suggestions: Context-aware response recommendations
- FastAPI: High-performance async web framework
- Google Gemini 2.5: Advanced language model
- Pydantic: Data validation and serialization
- Semantic Cache: Token optimization and context pruning
- JWT Authentication: Secure token-based auth
- Next.js 14: React framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS: Utility-first styling
- Framer Motion: Smooth animations
- ShadCN UI: Modern component library
- A2UI Agent: Python-based UI generation
- v0.9 Specification: Standardized component format
- Real-time Rendering: Live component preview
- Interactive Elements: Click handlers and form inputs
| Phase | Feature | Status |
|---|---|---|
| 1 | FastAPI Gateway + Mode Router + Code Mode (A2UI) | ✅ Complete |
| 2 | Structured Study Engine (Pydantic Schemas) | ✅ Complete |
| 3 | Privacy Middleware: PII Redaction + Risk Scoring | ✅ Complete |
| 4 | Token Optimization: Semantic Cache + Context Pruning | ✅ Complete |
| 5 | Google Classroom Integration + Smart Reminders | ✅ Complete |
| 6 | Monitoring Dashboard: Analytics, Heatmap, Audit Export | ✅ Complete |
| Audience | How They Benefit |
|---|---|
| Students | Smart exam preparation, structured answers, deadline reminders |
| Educational Institutions | Standardized AI output that matches academic formats |
| Healthcare SaaS companies | HIPAA-leaning privacy layer before sending prompts to any LLM |
| Finance/Legal firms | Industry-specific PII redaction and audit trails for compliance |
| AI developers / startups | A reusable middleware layer to add to any LLM-powered product |
| Enterprise IT teams | A privacy proxy they can deploy in front of any commercial LLM API |
# Chat with automatic PII redaction
"Hi, my name is John Doe and my email is john@example.com. I need help with a sensitive medical question."
# → PII automatically redacted before reaching LLM# Get structured academic answers
"What is artificial intelligence? Explain in detail."
# → Returns 13-mark format with intro, diagram description, 6 explanation points, advantages, and conclusion# Generate user interfaces
"Create a login form with username and password fields"
# → Returns A2UI v0.9 JSON that renders as a functional login form# Google Gemini API
GEMINI_API_KEY=your_gemini_api_key_here
LITELLM_MODEL=gemini-2.5-flash
# JWT Authentication
JWT_SECRET=your_jwt_secret_here
# Database/Cache (optional)
REDIS_URL=redis://localhost:6379NEXT_PUBLIC_API_URL=http://localhost:8000aegis-learn/
├── middleware/ # FastAPI Backend
│ ├── main.py # Main application entry
│ ├── router.py # Request routing logic
│ ├── core/ # Core utilities
│ │ ├── llm.py # LLM integration
│ │ ├── auth.py # JWT authentication
│ │ ├── cache.py # Semantic caching
│ │ └── privacy.py # PII redaction
│ ├── modes/ # AI operation modes
│ │ ├── general_mode.py # Privacy-protected chat
│ │ ├── study_mode.py # Academic responses
│ │ └── code_mode.py # UI generation
│ └── requirements.txt # Python dependencies
├── website/ # Next.js Frontend
│ ├── src/
│ │ ├── app/ # App Router pages
│ │ ├── components/ # React components
│ │ └── lib/ # Utilities and API
│ ├── package.json # Node.js dependencies
│ └── tailwind.config.ts # Tailwind configuration
├── a2a_agents/ # A2UI Generation System
│ └── python/a2ui_agent/ # Python A2UI agent
├── specification/ # A2UI v0.9 Specification
├── samples/ # A2UI Examples
└── tools/ # Development tools
cd middleware
python test.py
pytest tests/cd website
npm run test
npm run test:e2e# Test health endpoint
curl http://localhost:8000/
# Test authentication
curl -X POST http://localhost:8000/auth/token \
-H "Content-Type: application/json" \
-d '{"user_id": "test_user"}'
# Test chat with token
curl -X POST http://localhost:8000/chat \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"mode": "general", "message": "Hello!"}'| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check |
/auth/token |
POST | Get JWT token |
/chat |
POST | Send chat message |
/a2ui/generate |
POST | Generate UI from text |
/audit-logs |
GET | View audit logs |
/cache-stats |
GET | Cache statistics |
{
"mode": "study",
"message": "What is photosynthesis?",
"session_id": "user123",
"industry": "education"
}{
"message": "Create a contact form",
"session_id": "default_session",
"a2ui_data": {}
}# Build and run with Docker Compose
cd middleware
docker-compose up -d- Backend: Deploy to cloud service (AWS, GCP, Azure)
- Frontend: Deploy to Vercel, Netlify, or similar
- Environment: Set production API keys and secrets
- Monitoring: Enable audit logs and analytics
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- AMD Slingshot for hosting the hackathon
- Google for the Gemini API
- FastAPI team for the excellent framework
- Next.js team for the React framework
- A2UI Community for the UI generation specification
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: your-email@example.com
⭐ If this project helped you, please give it a star!