How v13tthnh/mini-blog works
Mini Blog is a FastAPI blog and security-training demo with vulnerable and patched modes. A visitor browses, searches, and opens posts; registered users can create posts and comments, manage profiles, and administrators manage blog content and users. Requests enter through the app’s routers, which delegate business operations to services and render Jinja templates. The README describes SQLite, but the sampled runtime database adapter connects to PostgreSQL. The map uses the shown imports and calls; unsampled route and service behavior is not inferred beyond documented capabilities.
Main entry points: database.py Database adapter · main.py FastAPI app · security.py Session and CSRF · post_service.py Posts and comments
Components 21
Web application
- FastAPI app
main.py - Authentication routes
app/routes/auth.py - Post routes
app/routes/posts.py - Profile routes
app/routes/profile.py - Admin routes
app/routes/admin.py - File routes
app/routes/files.py - Jinja pages
templates
Blog and accounts
- Account service
app/services/auth_service.py - Posts and comments
app/services/post_service.py - Profile service
app/services/profile_service.py - Admin service
app/services/admin_service.py
Security controls
- Session and CSRF
app/utils/security.py - HTML and filename checks
app/utils/sanitize.py
Persistence and files
- Upload handling
app/utils/file_upload.py - File service
app/services/file_service.py - Database adapter
database.py - PostgreSQL
- Uploaded files
static/uploads - Runtime configuration
config.py - Database initialization
setup_postgres.py
Other components
- Visitor
Connections 36
- Visitor → FastAPI app: sends requests
README.md - FastAPI app → Authentication routes: registers router
main.py - FastAPI app → Post routes: registers router
main.py - FastAPI app → Profile routes: registers router
main.py - FastAPI app → Admin routes: registers router
main.py - FastAPI app → File routes: registers router
main.py - FastAPI app → Database adapter: initializes database
main.py - Authentication routes → Account service: delegates account actions
app/routes/auth.py - Authentication routes → Session and CSRF: reads current user
app/routes/auth.py - Post routes → Posts and comments: delegates post actions
app/routes/posts.py - Post routes → Session and CSRF: reads user and CSRF
app/routes/posts.py - Profile routes → Profile service: delegates profile actions
app/routes/profile.py - Profile routes → Session and CSRF: reads current user
app/routes/profile.py - Admin routes → Admin service: delegates admin actions
app/routes/admin.py - Admin routes → Session and CSRF: reads current user
app/routes/admin.py - File routes → File service: delegates file actions
app/routes/files.py - Authentication routes → Jinja pages: renders pages
README.md - Post routes → Jinja pages: renders pages
app/routes/posts.py - Account service → Database adapter: queries accounts
app/services/auth_service.py - Account service → Session and CSRF: hashes and signs
app/services/auth_service.py - Posts and comments → Database adapter: reads and writes posts
app/services/post_service.py - Posts and comments → Session and CSRF: checks CSRF
app/services/post_service.py - Posts and comments → HTML and filename checks: cleans content
app/services/post_service.py - Posts and comments → Upload handling: saves images
app/services/post_service.py - Profile service → Database adapter: reads and updates users
app/services/profile_service.py - Profile service → Session and CSRF: checks CSRF
app/services/profile_service.py - Profile service → Upload handling: saves avatars
app/services/profile_service.py - Profile service → HTML and filename checks: cleans biography
app/services/profile_service.py - Admin service → Database adapter: manages blog records
app/services/admin_service.py - Upload handling → HTML and filename checks: checks and secures names
app/utils/file_upload.py - Upload handling → Runtime configuration: uses upload directory
app/utils/file_upload.py - Upload handling → Uploaded files: writes uploaded files
app/utils/file_upload.py - Database adapter → Runtime configuration: loads connection settings
database.py - Database adapter → PostgreSQL: opens connections
database.py - Database adapter → Database initialization: runs initialization
database.py - File service → Runtime configuration: uses file settings
app/services/file_service.py