An intelligent Firebase Cloud Functions-based AI assistant that learns from every conversation and provides personalized programming guidance.
- AI-Powered Programming Assistance: Uses Google's Gemini AI to help with HTML, CSS, JavaScript, and Python
- Bulgarian Language Support: Responds in Bulgarian for local users
- Conversational Memory: Remembers all past interactions
- Continuous Learning: Extracts and tracks programming topics from conversations
- Personalized Responses: Tailors answers based on user's learning history
- Multi-User Support: Maintains separate learning profiles for each user
- Firebase Cloud Functions backend
- Firestore database for conversation storage
- Google Generative AI (Gemini) integration
- RESTful API endpoints
- Callable Cloud Functions for client integration
- Automatic topic extraction and categorization
- Session management
- Node.js 22.x (note: currently running on Node 20.x with warnings)
- Firebase CLI
- Google Cloud account
- Gemini API key
-
Clone the repository
git clone https://github.com/papica777-eng/dpengeneering.git cd dpengeneering -
Install dependencies
cd functions npm install -
Configure API Key Edit
functions/index.jsand replace the API key:const API_KEY = "YOUR_GEMINI_API_KEY_HERE";
-
Deploy to Firebase
firebase deploy --only functions
-
Deploy Firestore indexes
firebase deploy --only firestore:indexes
Main function for interacting with the AI assistant.
Parameters:
{
userId: string, // User identifier (optional, defaults to 'anonymous')
sessionId: string, // Session identifier (optional)
chatHistory: array, // Previous messages in the conversation
userParts: array // Current user message
}Returns:
{
text: string // AI's response
}Example:
const result = await firebase.functions().httpsCallable('callKodyAPI')({
userId: 'user123',
chatHistory: [],
userParts: ['Как да създам функция в JavaScript?']
});
console.log(result.data.text);Retrieve learning statistics for a user.
Parameters:
{
userId: string // User identifier
}Returns:
{
topics: array, // List of topics discussed
preferences: object, // User preferences
firstInteraction: timestamp,
lastInteraction: timestamp,
interactionCount: number
}Get past conversations for a user.
Parameters:
{
userId: string, // User identifier
limit: number // Maximum number of conversations (default: 10)
}Returns:
{
conversations: array // Array of conversation objects
}Check system health and database connectivity.
Endpoint: GET /systemHealth
Returns:
{
status: string, // 'OK' or 'ERROR'
checks: {
server: { status: string, message: string },
database: { status: string, message: string }
}
}Test database with a greeting function.
Endpoint: GET /greetUserDB?name=<username>
Stores all user-AI conversations.
{
userId: string,
sessionId: string,
timestamp: Timestamp,
userMessage: string,
aiResponse: string,
chatHistory: array
}Index: userId (ASC) + timestamp (DESC)
Stores user learning profiles.
{
topics: array, // e.g., ['HTML', 'CSS', 'JavaScript']
preferences: object,
firstInteraction: Timestamp,
lastInteraction: Timestamp,
interactionCount: number
}Tracks user visits (from greetUserDB function).
{
firstVisit: Date
}- User sends a message → System retrieves their learning profile
- AI generates response → Enhanced with context from past interactions
- Conversation is saved → Stored in Firestore for future reference
- Topics are extracted → Automatically identified from the conversation
- Profile is updated → New topics and interaction count saved
The system tracks 20+ programming keywords:
- Languages: HTML, CSS, JavaScript, Python
- Bulgarian terms: функция, клас, променлива, масив, обект, цикъл, условие
- English terms: function, class, array, loop, variable
- Technologies: Firebase, база данни, API
- LEARNING_SYSTEM.md - Comprehensive documentation of the learning system
- USAGE_EXAMPLES.js - Code examples for all API functions
Run basic tests:
cd functions
node test-learning.js- CodeQL security scanning: ✅ No vulnerabilities found
- User data is isolated by
userId - Anonymous mode available
- API key should be stored securely (use environment variables in production)
- Enable authentication check in
callKodyAPI:if (!context.auth) { throw new functions.https.HttpsError('unauthenticated', 'Please log in.'); }
- Store API key in environment variables
- Implement rate limiting
- Add data retention policies
- Comply with data protection regulations (GDPR, etc.)
# Start Firebase emulators
firebase emulators:start
# Test functions locally
curl http://127.0.0.1:5001/kodi-backend/us-central1/systemHealthdpengeneering/
├── functions/
│ ├── index.js # Main Cloud Functions
│ ├── package.json # Dependencies
│ └── test-learning.js # Basic tests
├── public/
│ ├── index.html # Web interface
│ └── manifest/
├── firestore.indexes.json # Database indexes
├── firestore.rules # Security rules
├── firebase.json # Firebase configuration
├── LEARNING_SYSTEM.md # Learning system documentation
├── USAGE_EXAMPLES.js # API usage examples
└── README.md # This file
- Sentiment analysis for user satisfaction tracking
- Difficulty level adaptation
- Personalized learning paths
- Quiz generation based on discussed topics
- Progress visualization dashboard
- Multi-language support expansion
- Advanced preference learning (learning style, explanation depth)
- Integration with code execution environments
- Voice interface support
Created by Камелия (Kamelia)
Maintained by the dpengineering team
This project is private.
- Google Generative AI (Gemini) for AI capabilities
- Firebase for backend infrastructure
- The open-source community for various dependencies
For issues and questions, please open an issue in the GitHub repository.
Note: This AI assistant is designed for educational purposes to help beginners learn programming. Always verify code suggestions and follow best practices.