Training & Services
Complete workflow guide for the NP Security Certificate Management System
The NP Security Certificate Management System is a web-based application that allows administrators to:
The system serves as both a public-facing website (course listings, about info, contact) and an admin backend (student management, certificate generation).
| Component | Technology | Purpose |
|---|---|---|
| Backend | Python Flask | Web server, routing, authentication |
| Database | SQLite | Student and admin data storage |
| Frontend | HTML/CSS/JS | Responsive web interface |
| Certificate | Pillow (PIL) | Image generation and rendering |
| QR Code | qrcode library | Unique QR code per certificate |
| Auth | Werkzeug | Password hashing, session management |
| Fonts | Google Fonts | Playfair Display, Poppins, Inter |
Administrator signs in at /login with username and password. Session is secured with Flask's signed cookies.
Dashboard shows total students, active students, certificates issued, and grade distribution. Quick actions for adding and viewing students.
Navigate to Students → Add Student. Fill in the student's personal details (name, surname, ID, phone, email), course information (course name, grade level, duration), and optional notes.
The student appears in the main Students table with status "Active" and certificate status "Pending". Search, filter by grade or status.
On the student's edit page, click Generate Certificate. The system:
NP-XXXXXXXX)/verify/<CERT_ID>static/certificates/The certificate is displayed in a preview page. Administrator can download the high-resolution PNG for printing or digital distribution.
Anyone with the certificate can scan the QR code (or visit the verify URL) to confirm its authenticity. The public verification page displays the student's name, course, grade, and certificate ID in a tamper-evident layout.
Access the admin panel at /login. Default credentials:
Username: admin
Password: npadmin2026
⚠ Important: Change the default password immediately after first login. Update the password hash in production by creating a new admin user or modifying the app.py setup script.
Passwords are hashed using Werkzeug's generate_password_hash() (PBKDF2-SHA256). Sessions are managed via Flask's signed cookie system.
Click the edit icon (✎) next to any student in the table. Update field values and click "Save Changes". You can also change the student's status here (Active, Completed, Inactive).
Click the delete icon (✕) next to a student. A confirmation dialog will appear. Deletion is permanent and also removes any generated certificate file.
Use the search bar to find students by name, surname, ID number, or certificate ID. Filter by grade level or status using the dropdown menus.
NP-XXXXXXXXFormat: NP-XXXXXXXX
Example: NP-A7K2M9X1
Generated using secrets.choice() with uppercase letters and digits (8 characters). Collision check ensures uniqueness.
https://<domain>/verify/<CERT_ID>Public: https://np.marutechcafe.co.za/verify/NP-A7K2M9X1
The certificate is a 1400 × 1000 pixel PNG image rendered with the following layout (top to bottom):
+--------------------------------------------------+
| GOLD DECORATIVE BORDER (3px + 1px inner) |
| |
| [NP SECURITY LOGO] |
| NP SECURITY |
| TRAINING AND SERVICES |
| PSIRA: 3184406/T2242 | CIPC: ... |
| |
| = CERTIFICATE OF COMPLETION = |
| |
| This certifies that |
| |
| STUDENT NAME SURNAME |
| |
| has successfully completed the |
| |
| Grade X - Course Name |
| Duration: X weeks |
| Issued: DD Month YYYY |
| Certificate ID: NP-XXXXXXXX |
| |
| [QR CODE] |
| Scan to verify certificate |
| |
| NP Security Training and Services |
| PSIRA: ... | CIPC: ... | Tel: 078 460 6540 |
| This certificate is verified electronically. |
+--------------------------------------------------+
Color scheme: Dark background (#1a1a19), Gold text/accent (#d4af37), White text (#ffffff), Light gray (#cccccc), Teal detail (#4a90a4).
# Install dependencies
pip install -r requirements.txt
# Run the app
python app.py
# Access at http://localhost:5000
For production, use Gunicorn with a reverse proxy (Nginx):
# Run with gunicorn
gunicorn -w 4 -b 0.0.0.0:8000 app:app
# Recommended: Set SECRET_KEY environment variable
export SECRET_KEY="your-secure-random-key"
| Variable | Default | Description |
|---|---|---|
SECRET_KEY | np-safety-secret-key... | Flask session signing key |
PORT | 5000 | Server port |
The system uses SQLite by default. The database file (instance/npsafety.db) is created automatically on first run. For production with multiple workers, consider migrating to PostgreSQL.
Delete the database file (instance/npsafety.db) and restart the app. The default admin is re-created automatically. Alternatively, use a Python shell to update the hash directly.
Yes. Edit the utils/certificate.py file to change colors, fonts, layout, text, or add new elements. The certificate is generated entirely with Pillow.
The verification page will show "Certificate Not Found" with a warning. The invalid cert ID is displayed, and the page advises contacting NP Security at 078 460 6540.
Yes. Download the PNG from the certificate preview page and print at any standard printer. The certificate is designed at 1400x1000px at 300 DPI, suitable for A4 landscape printing.
Use the Flask shell or add a route in app.py. The default admin is created automatically if no admin exists.
Yes. Each certificate gets a cryptographically random 8-character ID. The database enforces a unique constraint, so no two certificates can have the same ID.