Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐍 Python Academy

An interactive Python learning platform with AST-based code analysis, AI tutoring, and intelligent grading β€” built as a full-stack SaaS application.

Python Academy is a production-grade e-learning platform designed to teach Python programming through hands-on exercises, real-time code execution, and intelligent feedback. The platform features a modular FastAPI backend with advanced Python services and a modern Vue 3 frontend.


✨ Key Features

🎯 Core Learning

  • 100 structured lessons across 12 categories (NhαΊ­p MΓ΄n β†’ LeetCode Hard)
  • Interactive code editor with real-time execution and output display
  • Quiz system with scoring, history tracking, and chapter-based organization
  • Progress tracking β€” XP system, lesson completion, study streaks

🧠 Intelligent Code Analysis (Python ast module)

  • AST-based Code Analyzer β€” Static analysis engine that parses student code into Abstract Syntax Trees to evaluate complexity, detect patterns (functions, loops, comprehensions, classes), calculate nesting depth, and generate actionable refactoring suggestions
  • Smart Hint Engine β€” Uses difflib.SequenceMatcher + AST node comparison to structurally compare student code against the expected solution, providing targeted hints like "Missing a for loop" or "Try using a function definition"

πŸ“Š Code Similarity Checker with Anti-Cheat

A 4-dimensional partial credit scoring system β€” not just text matching:

Dimension Weight Method
Output Correctness 50% Exact, normalized & line-by-line output comparison
Code Quality 20% AST structural analysis (independent of answer)
Code Style 20% Indentation, naming, comments, docstrings
Text Similarity 10% difflib ratio (reference only)

Scoring Philosophy β€” Output is King:

  • βœ… Output correct β†’ minimum grade B regardless of approach
  • 🌟 Different approach (e.g. while vs for) + correct output β†’ creativity bonus +10%
  • 🚫 Hardcoded answer detected (e.g. print(15) when logic is required) β†’ capped at grade D
  • ⚠️ Syntax errors β†’ capped at grade C

πŸ”„ Real-Time Execution

  • WebSocket Live Streaming (asyncio subprocess) β€” Output streamed line-by-line to frontend
  • REST API Fallback β€” Reliable execution with sandboxed subprocess
  • Security Sandbox β€” Multi-level regex-based blocklist prevents os, subprocess, eval, exec, open, infinite loops

πŸ“ˆ Recommendation Engine

  • Weighted scoring algorithm analyzing quiz performance, lesson gaps, and completion patterns
  • Personalized "next lesson" suggestions based on student weak areas
  • Category-level progress analysis with priority scoring

πŸ“„ PDF Export

  • Professional PDF reports & certificates via reportlab
  • Student progress summary with lesson completion stats

πŸ€– AI Tutor Integration

  • Local Ollama-powered AI assistant for code explanation, hints, and code review
  • Streaming chat interface with contextual code understanding

πŸ—οΈ Architecture

python-academy/
β”œβ”€β”€ πŸ“ server/                    # FastAPI Backend (3,783 LoC Python)
β”‚   β”œβ”€β”€ main.py                   # App entry point + lifespan events
β”‚   β”œβ”€β”€ config.py                 # Centralized configuration
β”‚   β”œβ”€β”€ πŸ“ models/
β”‚   β”‚   └── schemas.py            # Pydantic request/response models
β”‚   β”œβ”€β”€ πŸ“ routers/
β”‚   β”‚   β”œβ”€β”€ analysis.py           # /api/analyze, /api/hints, /api/similarity
β”‚   β”‚   β”œβ”€β”€ execution.py          # /api/run, WebSocket /api/ws/execute
β”‚   β”‚   β”œβ”€β”€ export.py             # /api/export/pdf
β”‚   β”‚   └── progress.py           # /api/progress, /api/analytics
β”‚   β”œβ”€β”€ πŸ“ services/              # Business Logic Layer
β”‚   β”‚   β”œβ”€β”€ code_analyzer.py      # AST visitor, complexity scoring
β”‚   β”‚   β”œβ”€β”€ code_similarity.py    # 4-dim scoring + anti-cheat detection
β”‚   β”‚   β”œβ”€β”€ smart_hints.py        # difflib + AST hint generation
β”‚   β”‚   β”œβ”€β”€ recommendation.py     # Weighted learning path algorithm
β”‚   β”‚   β”œβ”€β”€ database.py           # SQLite ORM (6 tables)
β”‚   β”‚   β”œβ”€β”€ sandbox.py            # Secure code execution
β”‚   β”‚   β”œβ”€β”€ live_executor.py      # asyncio WebSocket streaming
β”‚   β”‚   └── pdf_generator.py      # reportlab PDF builder
β”‚   β”œβ”€β”€ πŸ“ utils/
β”‚   β”‚   β”œβ”€β”€ security.py           # Code safety checker
β”‚   β”‚   └── storage.py            # File-based storage (legacy)
β”‚   └── πŸ“ tests/                 # 87 unit tests
β”‚       β”œβ”€β”€ test_analyzer.py      # 13 tests β€” AST analysis
β”‚       β”œβ”€β”€ test_similarity.py    # 30 tests β€” scoring + anti-cheat
β”‚       β”œβ”€β”€ test_hints.py         # 12 tests β€” smart hints
β”‚       β”œβ”€β”€ test_sandbox.py       # 15 tests β€” security & execution
β”‚       └── test_database.py      # 17 tests β€” SQLite operations
β”‚
β”œβ”€β”€ πŸ“ src/                       # Vue 3 Frontend (4,689 LoC)
β”‚   β”œβ”€β”€ App.vue                   # Root component + routing
β”‚   β”œβ”€β”€ πŸ“ components/
β”‚   β”‚   β”œβ”€β”€ HomeView.vue          # Dashboard with stats & streaks
β”‚   β”‚   β”œβ”€β”€ LearnView.vue         # Lesson browser + sidebar
β”‚   β”‚   β”œβ”€β”€ LessonView.vue        # Code editor + all panels
β”‚   β”‚   β”œβ”€β”€ QuizView.vue          # Quiz engine
β”‚   β”‚   └── AITutorView.vue       # Chat interface
β”‚   β”œβ”€β”€ πŸ“ composables/
β”‚   β”‚   β”œβ”€β”€ useBackend.js         # FastAPI + WebSocket client
β”‚   β”‚   β”œβ”€β”€ usePyodide.js         # Browser-side Python (fallback)
β”‚   β”‚   └── useAITutor.js         # Ollama integration
β”‚   β”œβ”€β”€ πŸ“ stores/
β”‚   β”‚   └── academy.js            # Pinia state management
β”‚   β”œβ”€β”€ πŸ“ data/
β”‚   β”‚   └── index.js              # 100 lessons + quizzes content
β”‚   └── πŸ“ assets/
β”‚       └── style.css             # Premium dark glassmorphism (1,400+ lines)
β”‚
└── πŸ“ server/data/
    └── academy.db                # SQLite database (auto-created)

πŸ’Ύ Database Schema

-- Normalized SQLite schema with 6 tables
students            -- User profiles (id, name, created_at)
lesson_completions  -- Completed lessons (student_id, lesson_id, xp, timestamp)
quiz_attempts       -- Quiz history (chapter, score, total, percent, timestamp)
code_runs           -- Execution logs (code, output, success, exec_time)
analysis_logs       -- AST analysis history (complexity, features, suggestions)
study_sessions      -- Daily activity tracking (date, lessons, quiz, code_runs)

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+

1. Backend Setup

cd server
pip install -r requirements.txt
python main.py
# βœ… Server running at http://localhost:8000
# πŸ“– API docs at http://localhost:8000/docs

2. Frontend Setup

npm install
npm run dev -- --port 5180
# βœ… App running at http://localhost:5180

3. (Optional) AI Tutor

# Install Ollama β†’ https://ollama.ai
ollama pull llama3.2
# AI Tutor auto-connects at localhost:1434

πŸ§ͺ Testing

cd server
python -m pytest tests/ -v
tests/test_analyzer.py    β€” 13 passed βœ…  (AST analysis, complexity scoring)
tests/test_similarity.py  β€” 30 passed βœ…  (scoring, anti-cheat, output-first)
tests/test_hints.py       β€” 12 passed βœ…  (difflib, AST comparison, hints)
tests/test_sandbox.py     β€” 15 passed βœ…  (security blocklist, execution)
tests/test_database.py    β€” 17 passed βœ…  (SQLite CRUD, analytics)
─────────────────────────────────────────
Total                       87 passed βœ…  in 1.84s

πŸ”‘ Python Skills Demonstrated

Skill Where Used
ast module Code analyzer, structural quality scoring, anti-cheat detection
difflib Text similarity, smart hints, code comparison
asyncio WebSocket live execution streaming, subprocess management
sqlite3 Normalized database with 6 tables, row factory, transactions
FastAPI REST API, WebSocket endpoints, Pydantic validation, CORS
reportlab PDF certificate & progress report generation
Data Structures Weighted scoring algorithms, frequency maps, AST trees
Design Patterns Service layer, router pattern, dependency injection
Security Regex-based code blocklist, sandboxed execution, env isolation
Testing 87 unit tests with pytest, edge cases, anti-cheat validation

πŸ“Š Project Stats

Metric Value
Total Python LoC 3,783
Total Frontend LoC 4,689
Python Files 29
Unit Tests 87 (all passing)
API Endpoints 12 REST + 1 WebSocket
Lessons 100 across 12 categories
Database Tables 6 (normalized schema)
Services 8 modular business logic modules

πŸ“‘ API Endpoints

Method Endpoint Description
POST /api/run Execute Python code in sandbox
WS /api/ws/execute WebSocket live output streaming
POST /api/analyze AST code analysis
POST /api/hints Smart hint generation
POST /api/similarity Code similarity + anti-cheat scoring
GET /api/recommendations Personalized learning path
GET/POST /api/progress Load/save student progress
GET /api/analytics Study stats & activity heatmap
POST /api/export/pdf Generate PDF report
GET /api/health Backend health check
POST /api/quiz Submit quiz attempt
GET /api/quiz/:chapter Quiz history by chapter

πŸ› οΈ Tech Stack

Layer Technology
Frontend Vue 3 (Composition API), Vite 8, Pinia, Chart.js
Backend FastAPI, Uvicorn, Pydantic v2
Database SQLite 3 (persistent, auto-initialized)
Analysis Python ast, difflib, custom AST visitors
PDF ReportLab 4.0
AI Ollama (local LLM, optional)
Testing pytest, pytest-asyncio
Styling Custom CSS β€” dark glassmorphism, 1,400+ lines

πŸ“œ License

This project was built as a demonstration of Python engineering skills for the Vingroup AI Talent program application.


Built with 🐍 Python + ⚑ FastAPI + πŸ’š Vue 3

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages