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.
- 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.
- 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).
-
Clone the repository:
git clone <repository-url> cd student-portfolio-generator
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Environment Variables: Copy the example environment file:
cp .env.example .env
Open
.envand 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).
-
Google Credentials:
- Place your Google Service Account JSON key file in the project root.
- Ensure the filename matches
GOOGLE_SERVICE_ACCOUNT_FILEin your.env. - Important: Share your Google Sheet with the email address found in your
service_account.jsonfile (client_email).
Before running the app for the first time, initialize the Google Sheet headers:
python setup_sheet.pyThis will create the necessary columns in your configured Google Sheet.
You need to run both the FastAPI backend and the Telegram bot. It's recommended to run them in separate terminal windows.
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000.
- Swagger Documentation:
http://localhost:8000/docs - Health Check:
http://localhost:8000/health
python telegram_bot/bot.pyThe bot will start polling for messages.
- Start the bot:
/start - Generate a portfolio:
/generate <student_id>- Example:
/generate kido1001
- Example:
- The bot will reply with a link to the generated portfolio.
You can also trigger generation manually via curl:
curl -X POST http://localhost:8000/generate/kido1001app/: 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.