Skip to content

Ahmed-Tawfik94/student-portfolio

Repository files navigation

Student Portfolio Generator

A complete system to automate the creation and hosting of student portfolio websites. This project integrates Google Sheets for data management, a FastAPI backend for page generation, and a Telegram bot for easy interaction.

Features

  • Automated Portfolio Generation: Generates static HTML portfolios based on student data.
  • Google Sheets Integration: Fetches student information directly from a configured Google Sheet.
  • Telegram Bot Interface: Allows users (admins/teachers) to trigger generation and receive links via Telegram.
  • Local Hosting: Serves generated portfolios via FastAPI for immediate preview.

Prerequisites

  • Python 3.8 or higher
  • A Google Cloud Project with the following APIs enabled:
    • Google Sheets API
    • Google Drive API
  • A Google Service Account with access to the above APIs.
  • A Telegram Bot Token (from @BotFather).

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd student-portfolio-generator
  2. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt

Configuration

  1. Environment Variables: Copy the example environment file:

    cp .env.example .env

    Open .env and fill in the required values:

    • GOOGLE_SHEETS_ID: The ID of your Google Sheet.
    • GOOGLE_SERVICE_ACCOUNT_FILE: Path to your service account JSON key (e.g., service_account.json).
    • TELEGRAM_BOT_TOKEN: Your Telegram Bot token.
    • API_BASE_URL: URL where the backend is running (default: http://localhost:8000).
    • OUTPUT_DIR: Directory to store generated sites (default: output).
  2. Google Credentials:

    • Place your Google Service Account JSON key file in the project root.
    • Ensure the filename matches GOOGLE_SERVICE_ACCOUNT_FILE in your .env.
    • Important: Share your Google Sheet with the email address found in your service_account.json file (client_email).

Initialization

Before running the app for the first time, initialize the Google Sheet headers:

python setup_sheet.py

This will create the necessary columns in your configured Google Sheet.

Running the Application

You need to run both the FastAPI backend and the Telegram bot. It's recommended to run them in separate terminal windows.

1. Start the Backend API

uvicorn app.main:app --reload

The API will be available at http://localhost:8000.

  • Swagger Documentation: http://localhost:8000/docs
  • Health Check: http://localhost:8000/health

2. Start the Telegram Bot

python telegram_bot/bot.py

The bot will start polling for messages.

Usage

Via Telegram Bot

  • Start the bot: /start
  • Generate a portfolio: /generate <student_id>
    • Example: /generate kido1001
  • The bot will reply with a link to the generated portfolio.

Via API

You can also trigger generation manually via curl:

curl -X POST http://localhost:8000/generate/kido1001

Project Structure

  • app/: FastAPI application code.
    • api/: API routes.
    • services/: Core logic (Sheets, Drive, Building HTML).
    • templates/: HTML templates for portfolios.
  • telegram_bot/: Telegram bot logic.
  • output/: Generated static websites.
  • setup_sheet.py: Script to initialize Google Sheet structure.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors