How heybuddy-nsk/nkblog works
Project type and purpose
• NKBlog is a full-stack social blogging application built with Flask (Python) on the backend and HTML/CSS on the frontend.
• Users can register/login, create and manage blog posts, comment, and receive email notifications.
File structure
• Top-level files:
• nkblog.py (entry point)
• Dockerfile, boot.sh (deployment)
• config.py (Flask configuration)
• requirements/ (dependencies for dev/prod/docker)
• app/ package:
• app/__init__.py: creates Flask app, registers Blueprints
• Blueprints:
– app/auth (registration/login views & forms)
– app/main (public views, index, post pages)
– app/api (JSON API endpoints for users, posts, comments, authentication)
• app/models.py: ORM models (User, Post, Comment, Follow, etc.)
• app/email.py: email-sending helper
• app/decorators.py & app/api/decorators.py: request guards (login-required, rate limiting)
• app/templates/ & app/static/: Jinja2 HTML templates and CSS
• migrations/: Alembic migration scripts and config
Key insights from README
• Stack: Flask + SQLite + Jinja2 + HTML/CSS
• Features: user auth, posts CRUD, comments, responsive design, user profiles, email confirmations
• Run process: set env vars → python nkblog.py
• Client (Browser/Mobile)
• Web Server / WSGI (Gunicorn/uWSGI or Flask’s built-in dev server)
• Flask Application (single container/service)
– Blueprints: Auth, Main (MVC views), API
– Business logic: forms, decorators, email module
– ORM layer: SQLAlchemy models
• Database (SQLite file)
• Migration Service (Alembic)
• External SMTP Mail Server
• (Optional) Reverse proxy / load balancer (Nginx, if Dockerized)
1. Client → HTTP → Reverse Proxy (Nginx) → WSGI Server
2. WSGI Server → Flask App
– URL routes dispatch to Blueprints
– Views process forms, call models, render templates or return JSON
3. Flask App ↔ SQLite (via SQLAlchemy)
4. Flask App → Alembic (for db schema migrations, invoked via CLI or at startup)
5. Flask App → SMTP Server (via app/email.py) → Client email inbox
c. Architectural patterns & principles
• Blueprint-based modularization: separates auth, main UI, and API layers
• MVC (views/templates/models) for HTML pages
• RESTful JSON API under /api for programmatic access
• Single-process service (could be scaled horizontally behind a load balancer)
• Configuration via config.py and environment variables
d. Key technologies & libraries
• Flask, Flask-Blueprints, Flask-Mail
• Jinja2 templating, HTML/CSS (static assets)
• SQLAlchemy ORM & Alembic migrations
• Docker (via Dockerfile) for containerization
• Requirements files to control dev/prod/docker deps
Elements
• Clear, descriptive labels for each component (e.g., “Flask: Auth Blueprint”)
• Client (light blue)
• Web server/WGSI (gray)
• Database & migrations (orange)
• External services (SMTP in yellow)
Detailed capture of essential elements
• How nkblog.py bootstraps the Flask app with config.py
• Blueprint registration (auth, main, api)
• Location of static files vs. templates vs. dynamic routes
• Optional Docker layer: Dockerfile → container → exposed ports