CoolFace
Apppublic

Adam1230/educational-environment

sourceHugging Facemitupdated 3mo agoView on Hugging Face
0likes
App README

๐ŸŽ“ Educational Training Environment โ€” ุจูŠุฆุฉ ุชุฏุฑูŠุจูŠุฉ

A modern, gamified educational training platform built for PhD research. Rebuilt with FastAPI + Tailwind CSS + Alpine.js + SQLite โ†’ deployed on Hugging Face Spaces (Docker).

![License: MIT](LICENSE) ![FastAPI](https://fastapi.tiangolo.com) ![Python 3.11](https://python.org) ![Hugging Face Spaces](https://huggingface.co/spaces)


๐Ÿ“ Project Structure

edu-app/
โ”œโ”€โ”€ Dockerfile                  # Docker config for HF Spaces
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ app/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ main.py                 # FastAPI routes & app entry point
    โ”œโ”€โ”€ database.py             # SQLAlchemy + SQLite setup
    โ”œโ”€โ”€ auth.py                 # JWT auth + bcrypt password hashing
    โ”œโ”€โ”€ static/
    โ”‚   โ””โ”€โ”€ Photo/              # All original image assets (86 files)
    โ””โ”€โ”€ templates/
        โ”œโ”€โ”€ login.html          # Login + Register page (Alpine.js)
        โ”œโ”€โ”€ dashboard.html      # Main dashboard with all tabs
        โ”œโ”€โ”€ module1.html        # Module 1 โ€” Technology Integration Concepts
        โ”œโ”€โ”€ module2.html        # Module 2 โ€” Educational Video Production
        โ”œโ”€โ”€ module3.html        # Module 3 โ€” Google Forms Assessment
        โ”œโ”€โ”€ module4.html        # Module 4 โ€” Digital Communication & Collaboration
        โ”œโ”€โ”€ questions.html      # Pre-assessment test (15 questions)
        โ””โ”€โ”€ questions2.html     # Post-assessment test (15 questions)

๐Ÿš€ Step-by-Step Deployment on Hugging Face Spaces

Step 1 โ€” Create a Hugging Face Account

  1. 1.Go to https://huggingface.co and sign up (free).
  2. 2.Verify your email address.

Step 2 โ€” Create a New Space

  1. 1.Click your profile icon (top-right) โ†’ "New Space".
  2. 2.Fill in the form:
  3. 3.Space name: educational-environment (or any name you like)
  4. 4.License: MIT
  5. 5.SDK: Select "Docker" โ† CRITICAL
  6. 6.Visibility: Public (free) or Private (Pro plan)
  7. 7.Click "Create Space".

Step 3 โ€” Enable Persistent Storage (Important!)

  1. 1.In your Space, go to Settings tab.
  2. 2.Scroll to "Persistent Storage".
  3. 3.Click "Add Persistent Storage" โ†’ choose Small (20GB) (free tier).
  4. 4.The persistent volume will be mounted at /data โ€” our app uses /code/data for SQLite.
โš ๏ธ Without persistent storage, user accounts reset every time the Space restarts!

Step 4 โ€” Upload Your Files

Option A โ€” Via Hugging Face Web UI (Easiest):

  1. 1.In your Space, click the "Files" tab.
  2. 2.Click "Add file" โ†’ "Upload files".
  3. 3.Upload the entire edu-app/ folder contents:
  4. 4.Drag & drop Dockerfile, requirements.txt, README.md, LICENSE
  5. 5.Then upload the app/ folder (with all subfolders)
  6. 6.Commit the files.

Option B โ€” Via Git (Recommended for updates):

bash
# Clone your space
git clone https://huggingface.co/spaces/YOUR_USERNAME/educational-environment
cd educational-environment

# Copy your project files
cp -r /path/to/edu-app/* .

# Configure Git LFS for large files (images)
git lfs install
git lfs track "*.jpg" "*.jpeg" "*.png" "*.jfif" "*.gif"
git add .gitattributes

# Push everything
git add .
git commit -m "Initial deployment of Educational Training Environment"
git push

Step 5 โ€” Set Environment Variables (Optional but Recommended)

  1. 1.In your Space โ†’ Settings โ†’ "Repository secrets".
  2. 2.Add: | Key | Value | |-----|-------| | SECRET_KEY | your-super-secret-jwt-key-change-this-in-production | | DB_DIR | /data |
If DB_DIR is not set, the app defaults to /code/data.

Step 6 โ€” Wait for Build

  1. 1.After pushing, HF Spaces will automatically build the Docker image.
  2. 2.Build takes ~2-5 minutes.
  3. 3.Monitor progress in the "Logs" tab.
  4. 4.When you see Application startup complete, your app is live! ๐ŸŽ‰

Step 7 โ€” Access Your App

  • โ€”Your app URL: https://YOUR_USERNAME-educational-environment.hf.space
  • โ€”The login page will appear โ€” register a new account and start!

๐Ÿ”ง Local Development

bash
# 1. Clone or download this repo
git clone https://huggingface.co/spaces/YOUR_USERNAME/educational-environment
cd educational-environment

# 2. Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Create data directory
mkdir -p /code/data
# Or set custom path:
export DB_DIR="./data"

# 5. Run the app
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

# 6. Open browser
# โ†’ http://localhost:8000

๐Ÿ›ก๏ธ Authentication System

  • โ€”Registration: POST /api/register โ€” username, email, password (bcrypt hashed)
  • โ€”Login: POST /api/login โ€” returns JWT stored in HttpOnly cookie
  • โ€”Logout: POST /api/logout โ€” clears the cookie
  • โ€”Session: JWT token valid for 7 days
  • โ€”Protected routes: All pages except / require valid JWT cookie

Database Schema (SQLite)

sql
CREATE TABLE users (
    id             INTEGER PRIMARY KEY AUTOINCREMENT,
    username       VARCHAR(50)  UNIQUE NOT NULL,
    email          VARCHAR(100) UNIQUE NOT NULL,
    hashed_password VARCHAR(200) NOT NULL,
    created_at     DATETIME DEFAULT CURRENT_TIMESTAMP
);

๐ŸŽจ Tech Stack

LayerTechnology
BackendFastAPI (Python 3.11)
DatabaseSQLite via SQLAlchemy
AuthJWT (python-jose) + bcrypt (passlib)
TemplatesJinja2
CSS FrameworkTailwind CSS (CDN)
ReactivityAlpine.js (CDN)
FontsGoogle Fonts โ€” Cairo (Arabic)
DeploymentHugging Face Spaces (Docker)
Port7860 (HF default)

๐Ÿ“‹ API Endpoints

MethodPathDescription
GET/Login / Register page
POST/api/loginAuthenticate user
POST/api/registerCreate new account
POST/api/logoutClear session
GET/api/meCurrent user info
GET/dashboardMain dashboard
GET/module/{1-4}Module pages
GET/questionsPre-assessment
GET/questions2Post-assessment
GET/healthHealth check

๐Ÿ“– Content Flow (Pedagogical Structure)

Login/Register
    โ”‚
    โ–ผ
Dashboard
    โ”œโ”€โ”€ ๐Ÿ  Home โ€” Researcher & Supervisors intro
    โ”œโ”€โ”€ ๐ŸŽฏ Objectives โ€” Training environment goals
    โ”œโ”€โ”€ ๐Ÿ“– Guide โ€” 3-section learner guide with 16-step walkthrough
    โ”œโ”€โ”€ ๐Ÿ“… Pre-Assessment โ†’ /questions (15 Qs: MCQ + T/F)
    โ”‚
    โ”œโ”€โ”€ ๐Ÿ“š Content
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“˜ Module 1 โ€” Technology Integration Concepts (3 lessons)
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“• Module 2 โ€” Educational Video Production (3 lessons)
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“™ Module 3 โ€” Google Form Assessment (3 lessons)
    โ”‚   โ””โ”€โ”€ ๐Ÿ“— Module 4 โ€” Digital Communication (3 lessons)
    โ”‚
    โ”œโ”€โ”€ ๐Ÿ“… Post-Assessment โ†’ /questions2 (15 Qs: MCQ + T/F)
    โ””โ”€โ”€ ๐Ÿ“ฌ Contact โ€” Researcher info

Each lesson contains:

  1. 1.Introduction โ€” Context and overview
  2. 2.Objectives โ€” Learning targets (infographic)
  3. 3.Content โ€” Core material
  4. 4.Steps/Tools โ€” Practical application
  5. 5.Activity โ€” Hands-on task (submit to unlock next section)
  6. 6.Self-Evaluation โ€” 5-question quiz (โ‰ฅ50% to pass)
  7. 7.Achievement Badge โ€” Gamification reward

๐Ÿ› Troubleshooting

ProblemSolution
Build failsCheck requirements.txt โ€” all versions pinned
DB resets on restartEnable Persistent Storage in HF Space settings
Images not loadingEnsure app/static/Photo/ folder is uploaded
Port errorHF Spaces requires port 7860 โ€” Dockerfile exposes 7860
Login loopClear browser cookies and retry

๐Ÿ“„ License

MIT License โ€” Copyright (c) 2025 Khloud Gamal Abu-Bakr

Free to use, modify, and distribute with attribution.


๐Ÿ‘ฉโ€๐ŸŽ“ About

Built for the PhD research of Khloud Gamal Abu-Bakr, Teaching Assistant at the Department of Educational Technology, Faculty of Specific Education, Zagazig University, Egypt.

Research Title: The Effect of Different Challenge Patterns in a Gamification-Based Training Environment on Developing Technology Integration Skills among Faculty Members.

Supervisors:

  • โ€”Prof. Amal El-Sayed Ahmed El-Taher
  • โ€”Prof. Naglaa Saeed Mohammed
  • โ€”Dr. Lamia Mohammed El-Hadi