How marcoviaweb/libreria-inventario-django works
Project Type and Purpose
• This is a full-stack Django web application (“Sistema de Gestión de Inventario para Librería”) whose goal is to manage books, inventory movements, sales, suppliers, purchase orders, receptions, and generate reports.
• It follows Django’s MTV (Model-Template-View) pattern and uses Bootstrap for the frontend.
High-Level Components
a. Presentation Layer (Frontend)
• Browser clients accessing HTML templates (Bootstrap-based UI).
• Static assets served under staticfiles/ and shared templates/ (e.g., base.html, login.html).
b. Application Layer (Backend)
• Django project core (libreria_inventario/): settings, URL routing, WSGI/ASGI, middleware.
• Django apps (each a logical module):
• usuarios: roles & users
• libros: book CRUD
• inventario: stock adjustments & inventory movements
• ventas: sales processing
• proveedores: supplier management
• pedidos: purchase orders & reception
• reportes: inventory/sales reports
c. Data Layer
• Relational database (SQLite in dev; PostgreSQL/MySQL in prod).
• Django ORM models defined in each app (models.py) and migrations (migrations/).
d. External Services (optional/extension points)
• Email/SMS gateways for notifications (not in code but typical).
• Third-party analytics or reporting engines.
Relationships and Data Flows
• Users → HTTP(S) requests → Django URL router (libreria_inventario/urls.py).
• Requests → Views (app/views.py) → Forms & business logic (forms.py, models.py).
• Views → ORM queries → DB reads/writes → return context → Templates.
• Templates combine data + Bootstrap CSS/JS → rendered HTML → Browser.
• Admin tasks: superuser via Django admin.
• Static/media files served by Django in dev or by CDN/web server in prod.
Architectural Patterns & Principles
• Modular Monolith: each Django app is a cohesive module; they share the same process but have clear boundaries.
• MTV (Model-Template-View):
• Models = Data structures & DB schema.
• Templates = HTML UIs.
• Views = Controllers (request handlers).
• DRY and Single Source of Truth: settings centralized, URL patterns modular.
• Role-based Access Control: enforced in views and via User/Group models.
Technologies & Frameworks
• Python 3.x + Django 5.x
• SQLite (development)
• Bootstrap (CSS/JS)
• Django ORM, migrations, admin, built-in auth & permissions
• WSGI/ASGI for deployment