
The system will be build on a serverless microservices architecture, primarily utilizing AWS services. This architecture allows for high scalability, cost-effectiveness, and ease of maintenance. The system consists of several interconnected components that work together to deliver a seamless user experience.
The virtual coach is the heart of the AllBlazing system, powered by OpenAI's GPT models. It provides personalized advice, generates fitness challenges, and engages in natural language conversations with users.
pythonclass VirtualCoach:def __init__(self, history=""):self.OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")self.base_data = base_dataset.dataset["qa"]["qa_dataset"]self.persona = base_dataset.dataset["persona"]["tutorial_coach_regular_persona"]self.features = base_dataset.dataset["tutorial_features"]# ... (other initialization code)def call_gpt(self, custom_prompt):# ... (code to call OpenAI API)def create_custom_prompt(self, question):# ... (code to create prompts for the GPT model)
This component interacts with the OpenAI API to generate responses based on user input and context.
The system maintains detailed user profiles, including fitness data, goals, and progress. This information is crucial for providing personalized coaching and tracking improvements over time.
User data is primarily stored in AWS DynamoDB, a NoSQL database that allows for flexible schema and fast retrieval
The application meticulously tracks user activities and health metrics, storing this data in DynamoDB for analysis and progress tracking.
typescriptconst trackActivity = async (userId: string, activityData: ActivityData) => {const enrichedData = await enrichActivityData(activityData);await saveActivityToDatabase(userId, enrichedData);await updateUserStats(userId, enrichedData);};
typescriptconst enrichActivityData = async (activityData: ActivityData) => {const activityType = await detectActivityType(activityData);const caloriesBurned = calculateCaloriesBurned(activityData, activityType);const trainingEffect = calculateTrainingEffect(activityData, activityType);return { ...activityData, activityType, caloriesBurned, trainingEffect };};
typescriptconst syncActivities = async (userId: string, activities: ActivityData[]) => {for (const activity of activities) {await trackActivity(userId, activity);}await notifyUserOfSync(userId);};
typescriptconst generateCoachAdvice = async (userId: string) => {const recentActivities = await getRecentActivities(userId);const userProfile = await getUserProfile(userId);const advice = await callGPTForAdvice(recentActivities, userProfile);return advice;};
typescriptconst updateUserProgress = async (userId: string) => {const activities = await getUserActivities(userId, { last: '30 days' });const progress = calculateProgress(activities);await updateUserProgressInDB(userId, progress);};
typescriptconst updateLeaderboards = async () => {const topRunners = await getTopRunners({ last: '7 days' });await updateLeaderboardInDB('weekly_runners', topRunners);};
typescriptconst generateHealthInsights = async (userId: string) => {const healthMetrics = await getHealthMetrics(userId, { last: '90 days' });const insights = await analyzeHealthTrends(healthMetrics);await saveInsightsToDatabase(userId, insights);};

The application system utilizes the Serverless Framework for efficient deployment and management of AWS resources. This approach simplifies the process of updating and scaling the application as needed.
typescriptimport changeActivityStatus from "@functions/change-activity-status";import chatWithGPT from "@functions/chat-with-gpt";import coachResponse from "@functions/coach-response";// ... (other function imports)// Serverless configuration file
The development environment is set up with npm for package management, including scripts for local development and deployment to different environments:
typescript"scripts": {"test": "echo \"Error: no test specified\" && exit 1","debug": "sls offline start --httpPort 4000 --lambdaPort 4002 --websocketPort 4003 --aws-profile default","deploy": "sls deploy --stage dev --region eu-west-1 --aws-profile default","deploy-prod": "sls deploy --stage prod --region eu-central-1 --aws-profile default"},

Netdata provides real-time performance monitoring for Linux systems, visualizing processes and services through web dashboards. The tutorial outlines how to install and configure Netdata, including installing dependencies, cloning the Netdata repository, building and installing the application, and configuring memory usage. It also covers enabling Kernel Same-page Merging to optimize performance, and hosting the Netdata dashboard through Nginx for secure access. The tutorial concludes with a brief exploration of the Netdata dashboard.
Beiryu
Contributor

In the previous part, we discussed the challenges and experiences of building the "Let's Story" feature in the Applaydu application. However, with the introduction of Ferrero WAF (Web Application Firewall), a new requirement emerged: we needed to thoroughly retest all the stories.
Beiryu
Contributor