
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"},

In the modern technology world, reading open source code is becoming increasingly popular and important for developers. This not only helps them improve their programming skills, but also saves them time and enhances their careers. Below are some benefits of daily reading of open source code for developers.
Beiryu
Contributor

Polar is a Merchant of Record (MoR) billing platform built for developers selling software and digital products. Unlike payment processors like Stripe, Polar handles global tax compliance, automated benefit delivery (license keys, GitHub access, Discord), and full billing infrastructure in one product at 4% + 40¢. Compared to other MoR options (Paddle, Lemon Squeezy), Polar is open source, offers lower fees, framework adapters for a 6-line integration, and is designed to scale from indie to enterprise without switching platforms.
Beiryu
Contributor