How vietdevsoft/stock-pro works
Stock Pro is a web-based inventory management system. Users browse product pages or register and sign in with CAPTCHA; authenticated users manage profiles, while managers and administrators use the admin area for products, categories, units, and inventory transactions. Administrators also manage users, audit logs, and site settings. FastAPI serves the pages and API routes; controllers delegate to services, which use database access for persistent state. The README documents Redis-backed CAPTCHA answers and inventory history, though those implementations were not fully sampled.
Main entry points: query_service.py Query gateway · js Browser JavaScript · product_controller.py Product and stock API · main.py FastAPI app and pages
Components 21
Web interface
- FastAPI app and pages
main.py - Page templates
templates - Browser JavaScript
static/js
Identity and profile
- Auth endpoints
controllers/auth_controller.py - Auth workflows
services/auth_service.py - CAPTCHA endpoint
controllers/captcha_controller.py - CAPTCHA service
services/captcha_service.py - Profile endpoints
controllers/profile_controller.py - Profile service
services/profile_service.py - JWT security
utils/security.py
Inventory operations
- Product and stock API
controllers/product_controller.py - Product and stock logic
services/product_service.py
System administration
- Role authorization
utils/admin_auth.py - User administration
services/product_service.py - Audit and settings
services/product_service.py
Persistence and access
- Query gateway
services/query_service.py - Database connection
services/database_service.py - PostgreSQL
database/init.sql
Other components
- Visitor / user
- Web browser
- Redis CAPTCHA store
Connections 30
- Visitor / user → Web browser: uses
- Web browser → FastAPI app and pages: requests pages
- FastAPI app and pages → Page templates: renders
- Web browser → Browser JavaScript: runs scripts
- Browser JavaScript → Auth endpoints: submits auth
- Browser JavaScript → CAPTCHA endpoint: requests image
- Browser JavaScript → Profile endpoints: calls profile
- Browser JavaScript → Product and stock API: calls inventory
- FastAPI app and pages → JWT security: verifies page token
- FastAPI app and pages → Query gateway: loads user info
- Auth endpoints → Auth workflows: delegates
- Auth endpoints → CAPTCHA service: checks answer
- Auth endpoints → JWT security: creates token
- Auth workflows → Query gateway: reads and writes
- CAPTCHA endpoint → CAPTCHA service: gets and saves answer
- CAPTCHA service → Redis CAPTCHA store: stores answers
- Profile endpoints → JWT security: verifies token
- Profile endpoints → Profile service: delegates
- Profile endpoints → Query gateway: updates user
- Profile service → Query gateway: reads and writes
- Product and stock API → Role authorization: checks access
- Product and stock API → Product and stock logic: delegates
- Product and stock logic → Query gateway: queries data
- Product and stock logic → Database connection: opens transactions
- Role authorization → JWT security: verifies token
- Role authorization → Query gateway: loads user role
- Product and stock API → User administration: routes user actions
- Product and stock API → Audit and settings: routes audit and settings
- Query gateway → Database connection: opens connection
- Database connection → PostgreSQL: connects