GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - rasmus6992/CVtoSite: CVtoSite AI — Turn Your CV into a Modern Portfolio Website

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
bootstrap
bootstrap
 
 
config
config
 
 
database
database
 
 
public
public
 
 
storage/logs
storage/logs
 
 
tools
tools
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

CV to HTML Portfolio Hub

DEMO: https://rasmus6992.com/randomaistuff/cvtohtmlv1/

A self-contained PHP 8 portal that accepts raw CV text, generates a modern Tailwind portfolio with the OpenAI Responses API, previews it inside a sandboxed iframe, synchronizes light/dark mode, and downloads the final portfolio as a standalone HTML file.

Features

  • OOP PHP 8 architecture with no third-party PHP package dependency
  • PDO/MySQL with native prepared statements
  • Concurrency-safe IP rate limiting using an InnoDB transaction and SELECT ... FOR UPDATE
  • Three accepted generation attempts per IP, followed by an absolute one-hour cooldown
  • IPv4 and IPv6 support using packed VARBINARY(16) values
  • Trusted-proxy-aware IP resolution; forwarding headers are ignored by default
  • CSRF protection, strict input validation, request-size limits, and safe error responses
  • OpenAI Responses API integration using server-side cURL
  • Prompt-injection resistance: CV text is explicitly handled as untrusted data
  • Server-side HTML allowlist sanitization
  • Sandboxed iframe preview without same-origin access
  • Synchronized application/preview dark mode
  • Desktop/mobile preview widths
  • Copy and download complete standalone HTML source
  • Audit metrics without storing the user's CV text

Requirements

  • PHP 8.1 or newer
  • MySQL 8.0+ or MariaDB 10.6+
  • PHP extensions: pdo_mysql, curl, dom, mbstring, json, openssl
  • Apache with mod_rewrite, or Nginx/PHP-FPM
  • An OpenAI API key

Project structure

cv-to-html-portfolio-hub/
├── app/
│   ├── Config/Database.php
│   ├── Exceptions/RateLimitException.php
│   ├── Http/JsonResponse.php
│   ├── Security/
│   │   ├── ClientIp.php
│   │   ├── Csrf.php
│   │   └── HtmlSanitizer.php
│   ├── Services/
│   │   ├── OpenAIClient.php
│   │   ├── PortfolioGenerator.php
│   │   ├── RateLimiter.php
│   │   ├── RateLimitResult.php
│   │   └── RequestLogger.php
│   └── Support/Env.php
├── bootstrap/app.php
├── config/app.php
├── database/schema.sql
├── public/
│   ├── api/generate.php
│   ├── assets/app.js
│   ├── .htaccess
│   └── index.php
├── storage/logs/
├── .env.example
├── .htaccess
└── README.md

Installation: Windows with XAMPP

  1. Extract the project to:

    C:\xampp\htdocs\cv-to-html-portfolio-hub
    
  2. Create a database named cv_portfolio_hub in phpMyAdmin.

  3. Import:

    database/schema.sql
    
  4. Copy .env.example to .env and update the database credentials and OpenAI key:

    DB_DATABASE=cv_portfolio_hub
    DB_USERNAME=root
    DB_PASSWORD=
    OPENAI_API_KEY=sk-your-real-key
    OPENAI_MODEL=gpt-4.1
  5. Verify these extensions are enabled in C:\xampp\php\php.ini:

    extension=curl
    extension=pdo_mysql
    extension=mbstring
    extension=dom
  6. Restart Apache and open:

    http://localhost/cv-to-html-portfolio-hub/
    

No Composer installation or vendor folder is required.

Production deployment

The recommended web root is the project's public/ directory. This keeps .env, database files, source classes, and logs outside the public document root.

For Apache shared hosting where changing the document root is impossible, the root .htaccess blocks internal directories and rewrites public requests into public/. Confirm that AllowOverride All and mod_rewrite are enabled.

For Nginx, point the server root to /path/to/cv-to-html-portfolio-hub/public and pass PHP files to PHP-FPM. Do not expose the project root directly.

Use HTTPS in production. Keep APP_DEBUG=false, restrict .env permissions, and never put the OpenAI key in JavaScript.

Reverse proxies and Cloudflare

The application uses REMOTE_ADDR unless the direct connection comes from a proxy listed in TRUSTED_PROXIES. This prevents clients from bypassing limits by spoofing X-Forwarded-For.

Example for a private load balancer:

TRUSTED_PROXIES=10.0.0.0/8,192.168.50.10

Configure only proxy addresses or CIDR ranges you control. For Cloudflare, use the current official Cloudflare proxy ranges rather than trusting all sources.

Cooling-period behavior

The rate limiter reserves an attempt before calling OpenAI:

  1. First accepted request: count becomes 1; two attempts remain.
  2. Second accepted request: count becomes 2; one attempt remains.
  3. Third accepted request: count becomes 3; the generation is allowed and cooldown_until is set to database UTC time plus one hour.
  4. Any further request during that hour receives HTTP 429 and a Retry-After header.
  5. The first request after expiry atomically resets the cycle and becomes attempt 1.

Every accepted submission counts as a try, including a submission for which the upstream AI request later fails. This protects API spend and prevents repeated upstream-failure abuse.

Database tables

ip_rate_limits

Stores one locked rate-limit state row per packed IP address. The unique IP index and row-level transaction lock prevent simultaneous requests from exceeding three attempts.

generation_requests

Stores operational metrics such as status, model, duration, and error code. Raw CV text and generated HTML are deliberately not stored.

To inspect rate-limit state:

SELECT
    INET6_NTOA(ip_address) AS ip,
    request_count,
    cooldown_until,
    last_request_at
FROM ip_rate_limits
ORDER BY updated_at DESC;

To manually reset one IP:

UPDATE ip_rate_limits
SET request_count = 0,
    cooldown_until = NULL,
    window_started_at = UTC_TIMESTAMP(6),
    updated_at = UTC_TIMESTAMP(6)
WHERE ip_address = INET6_ATON('203.0.113.10');

OpenAI integration

app/Services/OpenAIClient.php calls:

POST https://api.openai.com/v1/responses

The API key remains server-side. The system instruction requires:

  • only a raw <main>...</main> HTML fragment
  • no Markdown fences or explanatory text
  • standard Tailwind utility classes only
  • complete dark: variants
  • no scripts, styles, forms, images, SVG, external resources, or invented CV facts
  • instructions embedded in CV content to be ignored

The response is still sanitized server-side; prompt instructions are never treated as the only security boundary.

Preview and downloaded source security

The AI fragment passes through an HTML element/attribute allowlist. Unsafe tags, inline event handlers, inline styles, scripts, forms, embeds, iframes, SVG, arbitrary Tailwind values, unsafe URLs, and unknown attributes are removed.

The preview uses:

<iframe sandbox="allow-scripts">

allow-same-origin is intentionally omitted. Scripts are allowed only because the trusted preview wrapper loads the Tailwind CDN; AI-returned scripts are stripped before rendering.

The downloaded file includes a small trusted theme-toggle script and Tailwind CDN setup. For a high-traffic production service, consider compiling and self-hosting a fixed Tailwind stylesheet instead of using the browser CDN compiler.

Changing the model

Set the model alias in .env:

OPENAI_MODEL=gpt-4.1

The code uses the Responses API and reads either the flattened output_text field or the nested output content as a defensive fallback.

Troubleshooting

Database connection failed

Check .env, verify MySQL is running, and confirm the database user can access cv_portfolio_hub.

Class DOMDocument not found

Enable/install the PHP DOM/XML extension and restart the web server.

Call to undefined function curl_init()

Enable/install the PHP cURL extension and restart the web server.

Preview has no Tailwind styling

Confirm the browser/server Content Security Policy allows https://cdn.tailwindcss.com and that outbound access to the CDN is available.

Every visitor has the same IP

Your app is behind a proxy. Add only that trusted proxy's address/range to TRUSTED_PROXIES; do not blindly trust forwarded headers.

Suggested hardening for a larger deployment

  • Replace IP-only limiting with authenticated account limits plus IP/device risk signals.
  • Add CAPTCHA or bot detection before expensive generations.
  • Queue OpenAI jobs and apply account-level spend caps.
  • Compile Tailwind CSS and host it locally.
  • Add centralized structured logs and alerting.
  • Add automated retention cleanup for metrics tables.
  • Apply database least-privilege credentials.

Enhanced portfolio output

The generator is instructed to produce a premium, continuous one-page portfolio rather than a plain resume layout. The final downloaded HTML includes Tailwind CDN styling, dark/light mode, scroll-reveal motion, a reading-progress indicator, generated section navigation, smooth anchor scrolling, and a back-to-top control. AI markup remains server-side sanitized; interactive behavior is added by the trusted application wrapper.

About

CVtoSite AI — Turn Your CV into a Modern Portfolio Website

Resources

Readme
GPL-3.0 license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.