# chriswinjoseph/srfu-opportunity-system architecture

> Architecture diagram of the GitHub repository chriswinjoseph/srfu-opportunity-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chriswinjoseph/srfu-opportunity-system
- Repository: https://github.com/chriswinjoseph/srfu-opportunity-system

## Overview

Safe Roads For Us is a Django application combining email-based authentication and role-based user administration with an outreach-management workflow. Users sign in, manage organisations and opportunities, prepare and review email drafts, then record outreach and outcomes. Outreach also includes data-import and scraping tools. The graph preserves these major areas; unsampled modules are represented by their exact file or enclosing directory paths. Some links rely on the SOURCE INDEX or README rather than inspected implementation, so uncertain relationships are omitted.

Main entry points: [`outreach/views.py`](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/views.py) (Outreach views), [`accounts/views.py`](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/views.py) (Sign-in and reset), [`accounts/models.py`](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/models.py) (User and roles), [`accounts/user_views.py`](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/user_views.py) (User management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_accounts["Accounts and access"]
  node_auth["Sign-in and reset<br/>[views.py]"]
  node_authforms["Auth forms<br/>[forms.py]"]
  node_identity["User and roles<br/>[models.py]"]
  node_rolepolicy["Role permissions<br/>[roles.py]"]
  node_useradmin["User management<br/>[user_views.py]"]
  node_accountops["Account operations<br/>[services.py]"]
  node_firstadmin["First-admin setup"]
end

subgraph group_outreach["Outreach operations"]
  node_outreachviews["Outreach views<br/>[views.py]"]
  node_orgdata["Organisations and opportunities<br/>[models.py]"]
  node_outreachforms["Outreach forms<br/>[forms.py]"]
  node_transitions["Status transitions"]
end

subgraph group_email["Email workflow"]
  node_approvals["Approval checks<br/>[approvals.py]"]
  node_emailui["Email workflow UI<br/>[email_ui.py]"]
  node_emailops["Draft generation and validation<br/>[services.py]"]
  node_templates["Approved templates and drafts<br/>[models.py]"]
end

subgraph group_data["Data and integrations"]
  node_db[("SQLite database")]
  node_imports["Data import commands"]
  node_scraper["Scraper<br/>[scraper.py]"]
  node_scrapecommand["Scraper command<br/>[run_scraper.py]"]
end

node_user(("User"))
node_openai{{"OpenAI API"}}
node_smtp{{"Email delivery"}}

node_user -->|"signs in"| node_auth
node_auth -->|"validates with"| node_authforms
node_auth -->|"authenticates"| node_identity
node_user -->|"manages users"| node_useradmin
node_useradmin -->|"invokes operations"| node_accountops
node_useradmin -->|"uses forms"| node_authforms
node_accountops -->|"updates accounts"| node_identity
node_identity -->|"checks permissions"| node_rolepolicy
node_firstadmin -->|"creates invitation"| node_accountops
node_auth -.->|"sends reset email"| node_smtp
node_user -->|"uses outreach"| node_outreachviews
node_outreachviews -->|"validates with"| node_outreachforms
node_outreachviews -->|"reads and updates"| node_orgdata
node_outreachviews -->|"delegates transitions"| node_transitions
node_outreachviews -->|"checks approvals"| node_approvals
node_outreachviews -->|"uses presentation"| node_emailui
node_outreachviews -->|"requests generation"| node_emailops
node_emailui -.->|"presents draft state"| node_templates
node_emailops -->|"generates email"| node_openai
node_orgdata -->|"stores records"| node_db
node_identity -->|"stores accounts"| node_db
node_templates -->|"stores drafts"| node_db
node_imports -->|"imports records"| node_orgdata
node_scrapecommand -->|"runs scraper"| node_scraper

click node_auth "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/views.py"
click node_authforms "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/forms.py"
click node_identity "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/models.py"
click node_rolepolicy "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/roles.py"
click node_useradmin "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/user_views.py"
click node_accountops "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/services.py"
click node_firstadmin "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/management/commands/create_first_admin.py"
click node_outreachviews "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/views.py"
click node_orgdata "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/models.py"
click node_outreachforms "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/forms.py"
click node_transitions "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/status_transitions.py"
click node_approvals "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/approvals.py"
click node_emailui "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/email_ui.py"
click node_emailops "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/services.py"
click node_templates "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/models.py"
click node_imports "https://github.com/chriswinjoseph/srfu-opportunity-system/tree/main/outreach/management/commands"
click node_scraper "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/scraper.py"
click node_scrapecommand "https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/management/commands/run_scraper.py"

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_auth,node_authforms,node_identity,node_rolepolicy,node_useradmin,node_accountops,node_firstadmin,node_user toneBlue
class node_outreachviews,node_orgdata,node_outreachforms,node_transitions toneAmber
class node_approvals,node_emailui,node_emailops,node_templates,node_openai toneMint
class node_db,node_imports,node_scraper,node_scrapecommand toneRose
class node_smtp toneIndigo
```

## Components

### Accounts and access

- [Sign-in and reset](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/views.py): `accounts/views.py`
- [Auth forms](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/forms.py): `accounts/forms.py`
- [User and roles](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/models.py): `accounts/models.py`
- [Role permissions](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/roles.py): `accounts/roles.py`
- [User management](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/user_views.py): `accounts/user_views.py`
- [Account operations](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/services.py): `accounts/services.py`
- [First-admin setup](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/accounts/management/commands/create_first_admin.py): `accounts/management/commands/create_first_admin.py`

### Outreach operations

- [Outreach views](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/views.py): `outreach/views.py`
- [Organisations and opportunities](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/models.py): `outreach/models.py`
- [Outreach forms](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/forms.py): `outreach/forms.py`
- [Status transitions](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/status_transitions.py): `outreach/status_transitions.py`

### Email workflow

- [Approval checks](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/approvals.py): `outreach/approvals.py`
- [Email workflow UI](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/email_ui.py): `outreach/email_ui.py`
- [Draft generation and validation](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/services.py): `outreach/services.py`
- [Approved templates and drafts](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/models.py): `outreach/models.py`

### Data and integrations

- **SQLite database**
- [Data import commands](https://github.com/chriswinjoseph/srfu-opportunity-system/tree/main/outreach/management/commands): `outreach/management/commands`
- [Scraper](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/scraper.py): `outreach/scraper.py`
- [Scraper command](https://github.com/chriswinjoseph/srfu-opportunity-system/blob/main/outreach/management/commands/run_scraper.py): `outreach/management/commands/run_scraper.py`

### Other components

- **User**
- **OpenAI API**
- **Email delivery**

## Connections

- User → Sign-in and reset: signs in (evidence: `README.md`)
- Sign-in and reset → Auth forms: validates with (evidence: `accounts/views.py`)
- Sign-in and reset → User and roles: authenticates (evidence: `accounts/views.py`)
- User → User management: manages users (evidence: `README.md`)
- User management → Account operations: invokes operations (evidence: `accounts/user_views.py`)
- User management → Auth forms: uses forms (evidence: `accounts/user_views.py`)
- Account operations → User and roles: updates accounts (evidence: `accounts/services.py`)
- User and roles → Role permissions: checks permissions (evidence: `accounts/models.py`)
- First-admin setup → Account operations: creates invitation (evidence: `accounts/management/commands/create_first_admin.py`)
- Sign-in and reset → Email delivery: sends reset email (evidence: `README.md`)
- User → Outreach views: uses outreach (evidence: `outreach/views.py`)
- Outreach views → Outreach forms: validates with (evidence: `outreach/views.py`)
- Outreach views → Organisations and opportunities: reads and updates (evidence: `outreach/views.py`)
- Outreach views → Status transitions: delegates transitions (evidence: `outreach/views.py`)
- Outreach views → Approval checks: checks approvals (evidence: `outreach/views.py`)
- Outreach views → Email workflow UI: uses presentation (evidence: `outreach/views.py`)
- Outreach views → Draft generation and validation: requests generation (evidence: `outreach/views.py`)
- Email workflow UI → Approved templates and drafts: presents draft state
- Draft generation and validation → OpenAI API: generates email (evidence: `outreach/services.py`)
- Organisations and opportunities → SQLite database: stores records (evidence: `README.md`)
- User and roles → SQLite database: stores accounts (evidence: `README.md`)
- Approved templates and drafts → SQLite database: stores drafts (evidence: `outreach/models.py`)
- Data import commands → Organisations and opportunities: imports records (evidence: `outreach/management/commands/import_bank_contacts.py`)
- Scraper command → Scraper: runs scraper (evidence: `outreach/management/commands/run_scraper.py`)
