Skip to content

Commit 1f90a11

Browse files
authored
GSoC'25 Final report by Diwangshu Kakoty (#406)
* gsoc25-final_report * link to backend code change * author name fix * updated image
1 parent 5af797c commit 1f90a11

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
title: "GSoC’25 Final Report by Diwangshu Kakoty"
3+
excerpt: "Reflection Widget for Music Blocks"
4+
category: "DEVELOPER NEWS"
5+
date: "2025-09-01"
6+
slug: "2025-09-01-gsoc-25-diwangshu-final-report"
7+
author: "@/constants/MarkdownFiles/authors/diwangshu-kakoty.md"
8+
tags: "gsoc25,sugarlabs,final-report,AI,Music Blocks,Final Submission"
9+
image: "assets/Images/GSOC.webp"
10+
---
11+
12+
<!-- markdownlint-disable -->
13+
14+
## Abstract
15+
16+
Music Blocks is an educational tool that combines coding and music to enhance learning outcomes. To further support this goal, the 'Reflection Widget' was developed.
17+
18+
But first, what is reflective learning? It is a technique in which learners ask themselves questions that encourage them to think critically about their past actions. This requires careful analysis of what actually happened in order to understand the depth of the experience. The AI-powered Reflection Widget provides an accessible way to engage in this process.
19+
20+
At its core, the widget is a chat interface where AI mentors pose reflective questions, and users respond. By answering these questions, learners are encouraged to think more deeply about their experiences.
21+
22+
Users can interact with any mentor at any time. Another key feature of the widget is analysis: the AI mentor generates a detailed report on the user’s learning progress by comparing past reflections with the most recent conversation.
23+
24+
---
25+
26+
## Technical Implementation
27+
28+
### Phase 1: Project Setup
29+
30+
- The first step was deciding which LLM to use, since it forms the core of the chatbot. I initially experimented with Llama-3 running locally, but later switched to Gemini API.
31+
- I explored various sentence transformers available on HuggingFace. These play a crucial role in building a reliable RAG system. I ultimately chose the `sentence-transformers/all-MiniLM-L6-v2` model because it is both lightweight and accurate.
32+
- I learned and implemented a basic RAG pipeline. At first, I used ChromaDB as the vector database, but eventually migrated to a Qdrant cluster, a cloud-based vector database.
33+
- The chatbot was hosted on Streamlit to allow mentors to test it.
34+
- A FastAPI backend was developed with `/chat`, `/summary`, and `/analysis` endpoints.
35+
36+
### Phase 2: Adding Features
37+
38+
**Multi-Agent Chatbot**
39+
- To make reflection more engaging, three persona-based AI agents were introduced:
40+
- **Rohan** – for general reflection practice.
41+
- **Alan Kay** – for logical and coding-related reflections.
42+
- **Ludwig van Beethoven** – for reflections on musical aspects.
43+
44+
**Enhanced Context Passing**
45+
- To better understand the user’s project, the chatbot now leverages the JSON conversion function originally developed for the `AI Debugger`. The resulting flowchart is transformed into an algorithmic summary, which helps the LLM interpret the project’s structure.
46+
- In addition, the descriptions of the blocks used in the project are also passed to the LLM.
47+
48+
**Automated Periodic Summaries**
49+
- Previously, users had to click a separate button to generate summaries. However, based on feedback from Streamlit app testing, the system was updated to generate summaries periodically on its own, improving the overall user experience.
50+
51+
**Reasoning Model Integration**
52+
- I experimented with `reasoning models`, which employ a chain-of-thought approach to simulate logical reasoning. This significantly improved the LLM’s ability to understand user projects.
53+
- As a result, the algorithmic summary is now generated using a reasoning model, while the rest of the conversation is handled by a base model.
54+
55+
### Phase 3: Fast API Backend
56+
57+
- Initially, FastAPI was not part of the setup. Later, it was upgraded to include new API endpoints such as `/chat` and `/analysis`. Over time, additional endpoints like `/projectcode` and `/updatecode` were also introduced.
58+
59+
You can learn more about this [here](https://github.com/sugarlabs/musicblocks_reflection_fastapi).
60+
61+
### Phase 4: Native Widget Integration
62+
63+
- Developed a JavaScript widget and integrated it into the Music Blocks application.
64+
- Added real-time project analysis that continuously evaluates the user’s project state, produces an algorithmic summary, and initiates reflection with the user.
65+
- Built a conversational interface with session-aware tracking, allowing seamless dialogue that carries over context from previous exchanges.
66+
- Implemented `localStorage` support to store analysis reports, which can be reused for generating updated insights.
67+
- Introduced a **Download as Text** button for easy report export.
68+
- Added a **Refresh** button to ensure the AI receives the latest code whenever the user makes changes.
69+
70+
<a href="https://ibb.co/kgVBJkJ9"><img src="https://i.ibb.co/Z6RXStSY/Screenshot-2025-09-04-213236.png" alt="reflection" border="0"></a>
71+
72+
### Phase 5: Deploy to EC2
73+
74+
- The FastAPI server was deployed on an AWS EC2 t3.micro instance running Ubuntu 22.04 LTS.
75+
- Security groups were configured to allow HTTP, HTTPS, SSH, and FastAPI’s custom port.
76+
- Since the default storage and memory were limited, the disk was resized and a swap file was created to prevent crashes.
77+
- The project repository was cloned, dependencies installed in a virtual environment, and environment variables configured. - - - Finally, the FastAPI app was set up as a systemd service, allowing it to run in the background, restart on failure, and start automatically on boot.
78+
79+
---
80+
81+
## Data Flow Diagram
82+
83+
<a href="https://ibb.co/LdrV1mp5"><img src="https://i.ibb.co/608jFzsB/final-report.png" alt="client-server" border="0"></a>
84+
85+
---
86+
87+
## Tech Stack and Tools
88+
89+
**Frontend**
90+
- Technologies: HTML, CSS, JavaScript
91+
- Component: Music Blocks widget (chat-based interface)
92+
93+
**Backend**
94+
- Framework: Python FastAPI with Uvicorn server, LangChain
95+
- LLM Services: Google Gemini API
96+
- Sentence-transformers (embedding generation)
97+
98+
**Vector Database**
99+
- Qdrant cluster for semantic search and storage
100+
101+
**Infrastructure**
102+
- AWS EC2 (deployment)
103+
- systemd (service management)
104+
105+
---
106+
107+
## Project Code
108+
109+
- **Backend Code:** [Fast API server](https://github.com/sugarlabs/musicblocks_reflection_fastapi)
110+
- **Frontend Code:** [Reflection Widget](https://github.com/sugarlabs/musicblocks/blob/master/js/widgets/reflection.js)
111+
112+
## Pull Requests
113+
114+
- [Music Blocks Reflection Widget (Frontend)](https://github.com/sugarlabs/musicblocks/pull/4747)
115+
- [Documentation for Developers](https://github.com/sugarlabs/musicblocks/pull/4749)
116+
- [Documentation for Users](https://github.com/sugarlabs/musicblocks/pull/4753)
117+
118+
## Weekly Blogs
119+
120+
- [Week 1](https://www.sugarlabs.org/news/developer-news/2025-06-04-gsoc-25-Diwangshu-week01)
121+
- [Week 2](https://www.sugarlabs.org/news/developer-news/diwangshu-kakoty)
122+
- [Week 3](https://www.sugarlabs.org/news/developer-news/2025-06-22-gsoc-25-diwangshu-week03)
123+
- [Week 4](https://www.sugarlabs.org/news/developer-news/2025-06-29-gsoc-25-diwangshu-week04)
124+
- [Week 5](https://www.sugarlabs.org/news/developer-news/2025-07-06-gsoc-25-diwangshu-week05)
125+
- [Week 6](https://www.sugarlabs.org/news/developer-news/2025-07-13-gsoc-25-diwangshu-week06)
126+
- [Week 7](https://www.sugarlabs.org/news/developer-news/2025-07-20-gsoc-25-diwangshu-week07)
127+
- [Week 8](https://www.sugarlabs.org/news/developer-news/2025-07-30-gsoc-25-diwangshu-week08)
128+
- [Week 9](https://www.sugarlabs.org/news/developer-news/2025-08-10-gsoc-25-diwangshu-week09)
129+
- [Week 10](https://www.sugarlabs.org/news/developer-news/2025-08-22-gsoc-25-diwangshu-week10)
130+
- [Week 11](https://www.sugarlabs.org/news/developer-news/2025-08-29-gsoc-25-diwangshu-week11)
131+
- [Week 12](https://www.sugarlabs.org/news/developer-news/2025-08-30-gsoc-25-diwangshu-week12)
132+
133+
---
134+
135+
## Key Learnings
136+
137+
### Frameworks and Tools
138+
- Gained hands-on experience with **FastAPI** and **Streamlit**, including building prototypes and integrating frontend widgets with backend services.
139+
- Learned to work with **LangChain** as the primary development framework.
140+
- Explored and deepened understanding of **Gemini** and **LangChain** documentation, covering advanced LLM concepts like structured output, function calling, reasoning, and prompting techniques.
141+
142+
### APIs and Backend Development
143+
- Learned how API endpoints function and how to manage API keys securely during deployment.
144+
- Improved understanding of structuring API requests and responses for a smoother user experience.
145+
146+
### Prompt Engineering
147+
- Discovered the importance of refining prompts and using **few-shot prompting** to achieve more accurate and context-aware LLM outputs.
148+
149+
### Deployment and Infrastructure
150+
- Learned how to deploy an **EC2 instance on AWS**.
151+
152+
### Learning Approach
153+
- Realized the importance of relying on **official documentation** over tutorials or blog posts, since it provides the most reliable and up-to-date information.
154+
155+
## Future Development Goals
156+
- Integrate **Sugar-AI** to enhance capabilities in the near future.
157+
- Add **multi-language support** to enable international educational use.
158+
- Implement **offline functionality** using small language models for resource-constrained environments.
159+
- Extend the reflection learning interface to additional Sugar apps like Sugar Journal.
160+
161+
---
162+
163+
## Acknowledgments
164+
165+
This project was carried out under the mentorship of **Walter Bender**, **Sumit Srivastava**, and **Devin Ulibarri** as part of **Google Summer of Code 2025** with **Sugar Labs**. Its successful implementation highlights the collaborative spirit of open-source educational technology and the dedication of the Sugar Labs community to creating accessible learning tools.
166+
167+
Special thanks to the wider **Music Blocks community** for their valuable feedback during development and testing, and to **Google Summer of Code** for making this contribution to educational technology possible.
168+
169+
---

0 commit comments

Comments
 (0)