# kouser3485/women architecture

> Architecture diagram of the GitHub repository kouser3485/women, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kouser3485/women
- Repository: https://github.com/kouser3485/women

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with Flask (Python) on the backend and standard HTML/CSS/JavaScript on the frontend.
- Purpose: Allow women to generate, submit, and track legal complaints via an AI-powered interface, with location-based routing to police stations and an admin dashboard for police officers.

##### File Structure Analysis
- app.py: Flask application entry point.
- agents.py: AI “complaint generator” agents for natural-language → formal complaint translation.
- models/: Data layer (Complaint, PoliceStation schemas).
- routes/: HTTP endpoints (complaint submission, authentication, dashboard, tracking).
- utils/: Helpers (complaint_classifier).
- static/: Frontend assets (CSS, JS modules for auth, dashboard, emergency, mapping, tracking).
- templates/: Jinja2 HTML views (user pages, police login/dashboard, emergency, tracking, resources).
- requirements.txt: Dependencies (Flask, any ML libraries).

##### Key Architectural Patterns
- MVC-style separation:
- Models in models/
- Controllers in routes/
- Views in templates/ + static/
- Service layer for AI logic (agents.py, utils/complaint_classifier.py).
- External service integration: geolocation API or internal mapping for nearest police station.
- Single Flask app that bundles multiple functional modules (no microservices).

##### Main Components to Illustrate
A. Client Browser
– HTML/CSS/JS (templates + static assets)
– Sends HTTP(S) requests to Flask endpoints.
B. Flask Web Server
– app.py initializes Flask and registers Blueprints (routes/).
– routes/ modules handle request routing and invoke services.
C. AI Complaint Generator
– agents.py with ML/AI models in utils/complaint_classifier.py.
– Processes user input → generates complaint text.
D. Business Logic & Data Access
– models/ objects represent database schema.
– Data persistence (e.g., SQLite, PostgreSQL – not shown but implied).
E. Location & Rights Service
– Geolocation module (part of agents or utils) to find nearest police station.
– Rights lookup logic (could be a static JSON or external API).
F. Police Administration Dashboard
– Separate route modules (police_auth.py, police_dashboard.py).
– CRUD operations on complaints.
G. External Interfaces (optional)
– Email/SMS notifications.
– Map/Geolocation API.

##### Relationships and Data Flows
- User submits complaint form → HTTP POST to /complaint route → Flask controller invokes complaint_classifier → output complaint data.
- Flask controller queries models/ database to look up nearest police station → persists complaint record.
- Confirmation returned to user; status view polls /track endpoint to fetch updates.
- Police officer logs in → views all complaints via /police-dashboard → updates status → triggers notification back to user.
- Static and template files served directly by Flask for the UI.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["Client Browser"]:::frontend
        subgraph "Static Assets"
            CSS["static/css/style.css"]:::frontend
            AuthJS["auth.js"]:::frontend
            DashboardJS["dashboard.js"]:::frontend
            EmergencyJS["emergency.js"]:::frontend
            MainJS["main.js"]:::frontend
            NavJS["nav.js"]:::frontend
            SafeLocJS["safelocation.js"]:::frontend
            TrackJS["track.js"]:::frontend
        end
        subgraph "Templates"
            Index["index.html"]:::frontend
            Community["community.html"]:::frontend
            EmergencyT["emergency.html"]:::frontend
            Received["received.html"]:::frontend
            Resources["resources.html"]:::frontend
            Settings["settings.html"]:::frontend
            TrackT["track.html"]:::frontend
            NavT["nav.html"]:::frontend
            PoliceLogin["police-login.html"]:::frontend
            PoliceDashboardT["police-dashboard.html"]:::frontend
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        FlaskApp["Flask App (app.py)"]:::backend
        ComplaintOps["complaint_operations.py"]:::backend
        PoliceAuth["police_auth.py"]:::backend
        PoliceDash["police_dashboard.py"]:::backend
        Agents["agents.py"]:::ai
        Classifier["complaint_classifier.py"]:::ai
    end

    %% Data Layer
    subgraph "Data Layer"
        ComplaintModel["complaint.py"]:::backend
        PoliceStationModel["police_station.py"]:::backend
        ComplaintDB["Complaint DB"]:::db
    end

    %% External Services
    subgraph "External Services"
        GeoAPI["Geolocation API"]:::external
        Notification["Notification Service"]:::external
    end

    %% Connections
    Browser -->|"loads CSS/JS/HTML"| CSS
    Browser --> CSS
    Browser --> AuthJS
    Browser --> DashboardJS
    Browser --> EmergencyJS
    Browser --> MainJS
    Browser --> NavJS
    Browser --> SafeLocJS
    Browser --> TrackJS
    Browser --> Index
    Browser --> Community
    Browser --> EmergencyT
    Browser --> Received
    Browser --> Resources
    Browser --> Settings
    Browser --> TrackT
    Browser --> NavT
    Browser --> PoliceLogin
    Browser --> PoliceDashboardT

    Browser -->|"HTTP(S) request"| FlaskApp
    FlaskApp --> ComplaintOps
    FlaskApp --> PoliceAuth
    FlaskApp --> PoliceDash

    ComplaintOps -->|"invoke AI"| Agents
    Agents -->|"use classifier"| Classifier

    ComplaintOps -->|"DB query"| ComplaintModel
    ComplaintOps -->|"DB query"| PoliceStationModel
    ComplaintOps --> ComplaintDB

    ComplaintOps -->|"call Geolocation"| GeoAPI
    SafeLocJS -->|"client-side locate"| GeoAPI

    PoliceDash --> ComplaintDB
    PoliceDash --> Notification
    PoliceAuth --> ComplaintDB

    %% Click Events
    click CSS "https://github.com/kouser3485/women/blob/main/static/css/style.css"
    click AuthJS "https://github.com/kouser3485/women/blob/main/static/js/auth.js"
    click DashboardJS "https://github.com/kouser3485/women/blob/main/static/js/dashboard.js"
    click EmergencyJS "https://github.com/kouser3485/women/blob/main/static/js/emergency.js"
    click MainJS "https://github.com/kouser3485/women/blob/main/static/js/main.js"
    click NavJS "https://github.com/kouser3485/women/blob/main/static/js/nav.js"
    click SafeLocJS "https://github.com/kouser3485/women/blob/main/static/js/safelocation.js"
    click TrackJS "https://github.com/kouser3485/women/blob/main/static/js/track.js"
    click Index "https://github.com/kouser3485/women/blob/main/templates/index.html"
    click Community "https://github.com/kouser3485/women/blob/main/templates/community.html"
    click EmergencyT "https://github.com/kouser3485/women/blob/main/templates/emergency.html"
    click Received "https://github.com/kouser3485/women/blob/main/templates/received.html"
    click Resources "https://github.com/kouser3485/women/blob/main/templates/resources.html"
    click Settings "https://github.com/kouser3485/women/blob/main/templates/settings.html"
    click TrackT "https://github.com/kouser3485/women/blob/main/templates/track.html"
    click NavT "https://github.com/kouser3485/women/blob/main/templates/nav.html"
    click PoliceLogin "https://github.com/kouser3485/women/blob/main/templates/police-login.html"
    click PoliceDashboardT "https://github.com/kouser3485/women/blob/main/templates/police-dashboard.html"
    click FlaskApp "https://github.com/kouser3485/women/blob/main/app.py"
    click ComplaintOps "https://github.com/kouser3485/women/blob/main/routes/complaint_operations.py"
    click PoliceAuth "https://github.com/kouser3485/women/blob/main/routes/police_auth.py"
    click PoliceDash "https://github.com/kouser3485/women/blob/main/routes/police_dashboard.py"
    click Agents "https://github.com/kouser3485/women/blob/main/agents.py"
    click Classifier "https://github.com/kouser3485/women/blob/main/utils/complaint_classifier.py"
    click ComplaintModel "https://github.com/kouser3485/women/blob/main/models/complaint.py"
    click PoliceStationModel "https://github.com/kouser3485/women/blob/main/models/police_station.py"

    %% Styling
    classDef frontend fill:#ccf,stroke:#333,stroke-width:1px
    classDef backend fill:#cfc,stroke:#333,stroke-width:1px
    classDef ai fill:#fcf,stroke:#333,stroke-width:1px
    classDef db fill:#ccc,stroke:#333,stroke-width:1px
    classDef external fill:#eee,stroke:#333,stroke-width:1px
```
