# eduardouio/django_base architecture

> Architecture diagram of the GitHub repository eduardouio/django_base, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eduardouio/django_base
- Repository: https://github.com/eduardouio/django_base

## Overview

1. **Overall shape**
   This is a Django 5.1 monolith organized as a single backend project under `app/backend/src`, with one primary domain app, `accounts`, and a shared support layer in `common`. The repo is opinionated around server-rendered pages first, with room to add DRF/JWT later.

2. **Project entrypoints and routing**
   `config/asgi.py`, `config/wsgi.py`, and `manage.py` define the runtime entrypoints. `config/urls.py` is the top-level router that dispatches requests into app-level URL modules, mainly `accounts/urls.py` today.

3. **Identity and account domain**
   The `accounts` app is the main functional subsystem. It owns the custom user model (`models/CustomUserModel.py`), user manager (`managers/CustomUserManager.py`), profile/edit forms, and the user-facing views for login, logout, profile, password change, and home.

4. **Authentication flow**
   Authentication is email-based rather than username-based. `common/EmailBackEndAuth.py` supports that login model, while the custom user manager creates users and superusers with email as the identifier. The `accounts` views and forms sit on top of this identity layer.

5. **Cross-cutting middleware**
   `common/LicenseValidationMiddleware.py` and `common/LoggingMiddleware.py` sit in the request pipeline. They are the main architectural cross-cuts: one enforces/monitors license validity, the other captures request/response logging centrally before the request reaches the views.

6. **Shared base model and domain support**
   `common/BaseModel.py` is the reusable persistence base for shared concerns such as audit metadata and soft-delete behavior. `accounts/models/Licence.py` shows the project also has a dedicated model for license state, which is tied to the middleware and management commands.

7. **Presentation layer**
   The current UI is Django-template based, not SPA-based. `accounts/templates/base/base.html` defines the shared shell, while page templates under `templates/pages/` and `templates/forms/` cover login, home, profile, and profile update screens. Styling is designed for rapid iteration with CDN-loaded Tailwind/DaisyUI in the template layer.

8. **Operational commands**
   `accounts/management/commands/monitor_license_validation.py` and `test_license_validation.py` provide command-line operational hooks around the licensing subsystem. This suggests license checks are not only runtime middleware logic but also something the team can inspect and validate from the CLI.

9. **Persistence and file storage**
   The repo is set up for a relational database backend, with development defaults oriented toward SQLite and an easy path to PostgreSQL. User profile images are stored under `media/accounts/pictures`, so uploads are part of the account lifecycle.

10. **Logging and runtime artifacts**
   Runtime logs live under `src/logs`, which matches the logging middleware’s role. Static assets are collected under `src/static`, and uploaded media is kept separate under `src/media`, preserving the usual Django boundary between immutable assets and user-generated content.

11. **Testing structure**
   Tests are organized by concern under `src/tests`: base utilities, common utilities, models, and per-view tests for the `accounts` app. This layout reflects the architecture: the app is primarily tested through its view layer and core model/support primitives, with Pytest as the test runner.

12. **What is intentionally not yet wired**
   The README indicates readiness for DRF, JWT, Playwright, PDF/export tooling, and a future frontend integration, but those are mostly preparation points rather than active subsystems in the tree. For an architecture diagram, the live system is best shown as Django templates + custom auth + middleware + license/audit support, with API/SPA/reporting capabilities staged for later.

Main entry points: [`app/backend/src/config/settings.py`](https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/settings.py) (Settings), [`app/backend/src/accounts/forms`](https://github.com/eduardouio/django_base/tree/main/app/backend/src/accounts/forms) (Forms), [`app/backend/src/accounts/models/CustomUserModel.py`](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/models/CustomUserModel.py) (User model), [`app/backend/src/tests`](https://github.com/eduardouio/django_base/tree/main/app/backend/src/tests) (Tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_manage_py["manage.py<br/>entrypoint<br/>[manage.py]"]
  node_asgi["ASGI<br/>runtime entrypoint<br/>[asgi.py]"]
  node_wsgi["WSGI<br/>runtime entrypoint<br/>[wsgi.py]"]
  node_urls["Router<br/>urlconf<br/>[urls.py]"]
  node_settings["Settings<br/>configuration<br/>[settings.py]"]
end

subgraph group_accounts["Accounts"]
  node_user_model[("User model<br/>domain model<br/>[CustomUserModel.py]")]
  node_user_manager["User manager<br/>model manager"]
  node_license_model[("Licence<br/>domain model<br/>[Licence.py]")]
  node_home_view["Home<br/>view<br/>[HomeTempView.py]"]
  node_login_view["Login<br/>view<br/>[LoginTempView.py]"]
  node_logout_view["Logout<br/>view<br/>[LoguoutRedView.py]"]
  node_profile_view["Profile<br/>view<br/>[ProfileTempView.py]"]
  node_profile_update_view["Profile edit<br/>view<br/>[ProfileUpdtView.py]"]
  node_password_view["Password change<br/>view"]
  node_forms["Forms<br/>form layer"]
end

subgraph group_common["Shared Core"]
  node_auth_backend["Email auth<br/>auth backend"]
  node_base_model[("Base model<br/>[BaseModel.py]")]
  node_license_mw["License check<br/>middleware"]
  node_logging_mw["Request log<br/>middleware"]
end

subgraph group_presentation["Templates"]
  node_base_template["Base shell<br/>template shell<br/>[base.html]"]
  node_pages["Pages<br/>templates"]
  node_profile_form_tpl["Profile form<br/>template"]
end

subgraph group_ops["Operations"]
  node_license_cmds["License CLI<br/>management commands"]
  node_logs["Logs<br/>runtime artifacts"]
  node_tests["Tests<br/>pytest suite"]
end

node_manage_py -->|"loads"| node_settings
node_manage_py -->|"routes"| node_urls
node_asgi -->|"uses"| node_settings
node_wsgi -->|"uses"| node_settings
node_urls -->|"dispatches"| node_login_view
node_urls -->|"dispatches"| node_home_view
node_settings -->|"configures"| node_auth_backend
node_settings -->|"enables"| node_license_mw
node_settings -->|"enables"| node_logging_mw
node_settings -->|"sets"| node_user_model
node_user_manager -->|"creates"| node_user_model
node_auth_backend -->|"authenticates"| node_user_model
node_license_mw -->|"checks"| node_license_model
node_license_cmds -->|"operates on"| node_license_model
node_base_model -->|"supports"| node_license_model
node_base_model -->|"supports"| node_user_model
node_home_view -->|"renders"| node_base_template
node_login_view -->|"renders"| node_pages
node_profile_view -->|"renders"| node_pages
node_profile_update_view -->|"renders"| node_profile_form_tpl
node_pages -->|"extends"| node_base_template
node_profile_form_tpl -->|"extends"| node_base_template
node_forms -->|"submits to"| node_profile_update_view
node_forms -->|"submits to"| node_password_view
node_login_view -->|"uses"| node_forms
node_profile_update_view -->|"uses"| node_forms
node_password_view -->|"uses"| node_forms
node_logging_mw -->|"writes"| node_logs
node_tests -.->|"covers"| node_home_view
node_tests -.->|"covers"| node_login_view
node_tests -.->|"covers"| node_profile_view
node_tests -.->|"covers"| node_user_model

click node_manage_py "https://github.com/eduardouio/django_base/blob/main/app/backend/src/manage.py"
click node_asgi "https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/asgi.py"
click node_wsgi "https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/wsgi.py"
click node_urls "https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/urls.py"
click node_settings "https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/settings.py"
click node_user_model "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/models/CustomUserModel.py"
click node_user_manager "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/managers/CustomUserManager.py"
click node_license_model "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/models/Licence.py"
click node_auth_backend "https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/EmailBackEndAuth.py"
click node_base_model "https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/BaseModel.py"
click node_license_mw "https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/LicenseValidationMiddleware.py"
click node_logging_mw "https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/LoggingMiddleware.py"
click node_home_view "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/HomeTempView.py"
click node_login_view "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/LoginTempView.py"
click node_logout_view "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/LoguoutRedView.py"
click node_profile_view "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/ProfileTempView.py"
click node_profile_update_view "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/ProfileUpdtView.py"
click node_password_view "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/ChangePassUpdtView.py"
click node_forms "https://github.com/eduardouio/django_base/tree/main/app/backend/src/accounts/forms"
click node_base_template "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/templates/base/base.html"
click node_pages "https://github.com/eduardouio/django_base/tree/main/app/backend/src/accounts/templates/pages"
click node_profile_form_tpl "https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/templates/forms/profile_update.html"
click node_license_cmds "https://github.com/eduardouio/django_base/tree/main/app/backend/src/accounts/management/commands"
click node_logs "https://github.com/eduardouio/django_base/tree/main/app/backend/src/logs"
click node_tests "https://github.com/eduardouio/django_base/tree/main/app/backend/src/tests"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manage_py,node_asgi,node_wsgi,node_urls,node_settings toneBlue
class node_user_model,node_user_manager,node_license_model,node_home_view,node_login_view,node_logout_view,node_profile_view,node_profile_update_view,node_password_view,node_forms toneAmber
class node_auth_backend,node_base_model,node_license_mw,node_logging_mw toneMint
class node_base_template,node_pages,node_profile_form_tpl toneRose
class node_license_cmds,node_logs,node_tests toneIndigo
```

## Components

### Runtime

Django entrypoints and project routing

- [manage.py](https://github.com/eduardouio/django_base/blob/main/app/backend/src/manage.py): entrypoint · Django CLI entrypoint · `app/backend/src/manage.py`
- [ASGI](https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/asgi.py): runtime entrypoint · ASGI application bootstrap · `app/backend/src/config/asgi.py`
- [WSGI](https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/wsgi.py): runtime entrypoint · WSGI application bootstrap · `app/backend/src/config/wsgi.py`
- [Router](https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/urls.py): urlconf · Top-level request router · `app/backend/src/config/urls.py`
- [Settings](https://github.com/eduardouio/django_base/blob/main/app/backend/src/config/settings.py): configuration · Project configuration and app wiring · `app/backend/src/config/settings.py`

### Accounts

Primary identity and profile domain

- [User model](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/models/CustomUserModel.py): domain model · Custom email-based user account · `app/backend/src/accounts/models/CustomUserModel.py`
- [User manager](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/managers/CustomUserManager.py): model manager · Creates users and superusers · `app/backend/src/accounts/managers/CustomUserManager.py`
- [Licence](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/models/Licence.py): domain model · License state persisted in the app · `app/backend/src/accounts/models/Licence.py`
- [Home](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/HomeTempView.py): view · Authenticated landing page · `app/backend/src/accounts/views/HomeTempView.py`
- [Login](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/LoginTempView.py): view · Email login page and flow · `app/backend/src/accounts/views/LoginTempView.py`
- [Logout](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/LoguoutRedView.py): view · Logout redirect flow · `app/backend/src/accounts/views/LoguoutRedView.py`
- [Profile](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/ProfileTempView.py): view · Profile display page · `app/backend/src/accounts/views/ProfileTempView.py`
- [Profile edit](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/ProfileUpdtView.py): view · Profile update workflow · `app/backend/src/accounts/views/ProfileUpdtView.py`
- [Password change](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/views/ChangePassUpdtView.py): view · Password update workflow · `app/backend/src/accounts/views/ChangePassUpdtView.py`
- [Forms](https://github.com/eduardouio/django_base/tree/main/app/backend/src/accounts/forms): form layer · Creation, edit, and password forms · `app/backend/src/accounts/forms`

### Shared Core

Cross-cutting auth, middleware, and base model support

- [Email auth](https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/EmailBackEndAuth.py): auth backend · Email-based authentication backend · `app/backend/src/common/EmailBackEndAuth.py`
- [Base model](https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/BaseModel.py): base model · Shared persistence concerns · `app/backend/src/common/BaseModel.py`
- [License check](https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/LicenseValidationMiddleware.py): middleware · Enforces or monitors license validity · `app/backend/src/common/LicenseValidationMiddleware.py`
- [Request log](https://github.com/eduardouio/django_base/blob/main/app/backend/src/common/LoggingMiddleware.py): middleware · Central request and response logging · `app/backend/src/common/LoggingMiddleware.py`

### Templates

Server-rendered UI shell and pages

- [Base shell](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/templates/base/base.html): template shell · Shared page layout · `app/backend/src/accounts/templates/base/base.html`
- [Pages](https://github.com/eduardouio/django_base/tree/main/app/backend/src/accounts/templates/pages): templates · Login, home, and profile screens · `app/backend/src/accounts/templates/pages`
- [Profile form](https://github.com/eduardouio/django_base/blob/main/app/backend/src/accounts/templates/forms/profile_update.html): template · Profile update form template · `app/backend/src/accounts/templates/forms/profile_update.html`

### Operations

CLI hooks, logs, and tests

- [License CLI](https://github.com/eduardouio/django_base/tree/main/app/backend/src/accounts/management/commands): management commands · Operational commands for license validation · `app/backend/src/accounts/management/commands`
- [Logs](https://github.com/eduardouio/django_base/tree/main/app/backend/src/logs): runtime artifacts · Application log output directory · `app/backend/src/logs`
- [Tests](https://github.com/eduardouio/django_base/tree/main/app/backend/src/tests): pytest suite · View, model, and common test coverage · `app/backend/src/tests`

## Connections

- manage.py → Settings: loads · Bootstraps Django using project settings
- manage.py → Router: routes · Drives project URL configuration
- ASGI → Settings: uses · ASGI bootstraps with project settings
- WSGI → Settings: uses · WSGI bootstraps with project settings
- Router → Login: dispatches · Top-level router sends requests into accounts views
- Router → Home: dispatches · Top-level router sends requests into accounts views
- Settings → Email auth: configures · Registers email authentication backend
- Settings → License check: enables · Adds license validation to the request pipeline
- Settings → Request log: enables · Adds centralized logging middleware
- Settings → User model: sets · Uses the custom user model as auth identity
- User manager → User model: creates · Factory for custom users and superusers
- Email auth → User model: authenticates · Checks credentials against email-based users
- License check → Licence: checks · Reads license state during requests
- License CLI → Licence: operates on · Command-line hooks inspect license validation state
- Base model → Licence: supports · Shared persistence base underlies domain models
- Base model → User model: supports · Shared persistence base underlies domain models
- Home → Base shell: renders · Uses shared shell for server-rendered pages
- Login → Pages: renders · Login page template
- Profile → Pages: renders · Profile page template
- Profile edit → Profile form: renders · Profile update form template
- Pages → Base shell: extends · Page templates build on the shared shell
- Profile form → Base shell: extends · Form templates build on the shared shell
- Forms → Profile edit: submits to · Forms back the profile update workflow
- Forms → Password change: submits to · Forms back the password change workflow
- Login → Forms: uses · Login flow is form-driven
- Profile edit → Forms: uses · Profile edit flow is form-driven
- Password change → Forms: uses · Password change flow is form-driven
- Request log → Logs: writes · Central request logging lands in runtime log files
- Tests → Home: covers · View tests validate the primary pages
- Tests → Login: covers · View tests validate the primary pages
- Tests → Profile: covers · View tests validate the primary pages
- Tests → User model: covers · Model tests validate core identity behavior
