# krutiknaina/employee-profilescan architecture

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

- Interactive diagram: https://gitdiagram.com/krutiknaina/employee-profilescan
- Repository: https://github.com/krutiknaina/employee-profilescan

## Overview

##### Project type and purpose
- Full-stack, monolithic Django web application for corporate employee management.
- Purpose: generate and serve unique QR-coded employee IDs, manage profiles via an admin dashboard, and provide a camera-based in-app QR scanner that routes to a mobile-friendly profile page.

##### File structure
- Top level:
- Dockerfiles and docker-compose.yml (containerized deployment)
- manage.py (Django CLI entrypoint)
- db.sqlite3 (persistent data store)
- media/ (user-uploaded profile photos and generated QR images)
- staticfiles/ (collected static assets: CSS/JS images from Django admin and front end)
- Templates/ (HTML templates for pages: login, signup, scan, profile, reports, etc.)
- Django Project directory (QR_Employee_Scanner):
- settings.py, urls.py, asgi.py, wsgi.py
- views.py and utils.py containing business logic
- Django App directory (db):
- models.py (Employee model with QR code field)
- views.py (CRUD and scan endpoint handlers)
- migrations/ (schema history)
- Requirements and license files

##### README insights
- Confirms MVT pattern: Django ORM (SQLite), HTML templates with Bootstrap, JavaScript QR scanner (html5-qrcode.js), qrcode & Pillow for server-side QR generation, optional access control via Django auth.
- Flow: Admin → create profile → QR code generated → scanner page (/scan/) → camera read → redirect to profile view.

##### Main components and their relationships
A. Client Tier
- Browser/Mobile Device
- Renders HTML templates & serves JS/CSS from staticfiles
- Runs html5-qrcode.js on /scan/ page
B. Application Tier (Django)
- ASGI/WSGI server (QR_Employee_Scanner/asgi.py or wsgi.py)
- URL Router (QR_Employee_Scanner/urls.py)
- Views (QR_Employee_Scanner/views.py, db/views.py)
- Business utils (QR_Employee_Scanner/utils.py) for QR generation
- Admin Interface (built on Django’s admin module)
- Template engine (Templates/*.html)
C. Data Tier
- SQLite database (db.sqlite3) accessed via Django ORM (db/models.py)
- Media storage on disk (media/qr_codes, media/upload)
- Static assets directory (staticfiles/)
D. External libraries
- Python packages: Django, qrcode, Pillow
- JavaScript: html5-qrcode.js
E. Deployment infrastructure
- Docker container (defined by Dockerfile.txt, .dockerignore.txt)
- Service orchestration in docker-compose.yml

Interactions:
1. Client → HTTP GET/POST → Django URL router → appropriate view
2. View → ORM → read/write SQLite
3. View → utils → generate QR code → save to media/qr_codes
4. View → template engine → render HTML → return to client
5. Client on /scan/ loads html5-qrcode.js → camera stream → decode QR → redirect to /profile/<id> → step 1

##### Architectural patterns and principles
- Django’s Model-View-Template (MVT) layered approach
- Clear separation:
- Presentation layer: Templates + static assets + client-side JS
- Business logic layer: views.py, utils.py
- Data layer: models.py, migrations, SQLite
- Containerization boundary around the Django service

##### Essential elements
- Clear labels: component name + directory/file reference
- Container boundary if depicting Docker deployment

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Browser/Mobile Device"]:::frontend
        subgraph "HTML Templates"
            direction TB
            TemplatesDir["Templates/"]:::folder
            LoginTpl["login.html"]:::frontend
            SignupTpl["signup.html"]:::frontend
            ScanTpl["qr_scan.html\n(html5-qrcode.js)"]:::frontend
            ProfileTpl["profile.html"]:::frontend
        end
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        StaticDir["staticfiles/"]:::folder
        AdminStatic["staticfiles/admin/"]:::folder
        MediaDir["media/\n(upload, qr_codes)"]:::folder
        TemplateEngine["Django Template Engine"]:::frontend
        JSScanner["html5-qrcode.js"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        ASGI["asgi.py"]:::backend
        WSGI["wsgi.py"]:::backend
        URLRouter["urls.py"]:::backend
        GlobalViews["views.py\n(dashboard, reports)"]:::backend
        DbViews["db/views.py\n(CRUD, scan)"]:::backend
        Utils["utils.py\n(QR generation)"]:::backend
        ManageCLI["manage.py"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        AppConfig["db/apps.py"]:::backend
        Models["db/models.py\n(ORM + QR field)"]:::backend
        AdminReg["db/admin.py"]:::backend
        Migrations["db/migrations/"]:::folder
        SQLiteDB["db.sqlite3"]:::data
    end

    %% Deployment Infrastructure
    subgraph "Deployment"
        direction TB
        Dockerfile["Dockerfile.txt"]:::infra
        DockerIgnore[".dockerignore.txt"]:::infra
        Compose["docker-compose.yml"]:::infra
    end

    %% Interactions
    Browser -->|"HTTP GET /scan"| ASGI
    ASGI --> URLRouter
    URLRouter -->|"routes to Scan endpoint"| DbViews
    DbViews -->|"ORM write/read"| Models
    Models --> SQLiteDB
    DbViews --> Utils
    Utils --> MediaDir
    DbViews --> TemplateEngine
    TemplateEngine --> Browser
    Browser -->|"loads JS scanner"| JSScanner
    JSScanner -->|"camera stream decode"| URLRouter
    URLRouter -->|"redirect /profile/<id>"| ProfileTpl

    %% Static and Media serving
    Browser -->|"GET CSS/JS"| StaticDir
    Browser -->|"GET images"| MediaDir
    StaticDir --> AdminStatic

    %% Docker boundary
    Dockerfile -.-> ASGI
    Compose -.-> Dockerfile

    %% Click Events
    click TemplatesDir "https://github.com/krutiknaina/employee-profilescan/tree/main/Templates/"
    click LoginTpl "https://github.com/krutiknaina/employee-profilescan/blob/main/Templates/login.html"
    click SignupTpl "https://github.com/krutiknaina/employee-profilescan/blob/main/Templates/signup.html"
    click ScanTpl "https://github.com/krutiknaina/employee-profilescan/blob/main/Templates/qr_scan.html"
    click ProfileTpl "https://github.com/krutiknaina/employee-profilescan/blob/main/Templates/profile.html"
    click StaticDir "https://github.com/krutiknaina/employee-profilescan/tree/main/staticfiles/"
    click AdminStatic "https://github.com/krutiknaina/employee-profilescan/tree/main/staticfiles/admin/"
    click MediaDir "https://github.com/krutiknaina/employee-profilescan/tree/main/media/"
    click ASGI "https://github.com/krutiknaina/employee-profilescan/blob/main/QR_Employee_Scanner/asgi.py"
    click WSGI "https://github.com/krutiknaina/employee-profilescan/blob/main/QR_Employee_Scanner/wsgi.py"
    click URLRouter "https://github.com/krutiknaina/employee-profilescan/blob/main/QR_Employee_Scanner/urls.py"
    click GlobalViews "https://github.com/krutiknaina/employee-profilescan/blob/main/QR_Employee_Scanner/views.py"
    click Utils "https://github.com/krutiknaina/employee-profilescan/blob/main/QR_Employee_Scanner/utils.py"
    click ManageCLI "https://github.com/krutiknaina/employee-profilescan/blob/main/manage.py"
    click AppConfig "https://github.com/krutiknaina/employee-profilescan/blob/main/db/apps.py"
    click Models "https://github.com/krutiknaina/employee-profilescan/blob/main/db/models.py"
    click DbViews "https://github.com/krutiknaina/employee-profilescan/blob/main/db/views.py"
    click AdminReg "https://github.com/krutiknaina/employee-profilescan/blob/main/db/admin.py"
    click Migrations "https://github.com/krutiknaina/employee-profilescan/tree/main/db/migrations/"
    click SQLiteDB "https://github.com/krutiknaina/employee-profilescan/blob/main/db.sqlite3"
    click Dockerfile "https://github.com/krutiknaina/employee-profilescan/blob/main/Dockerfile.txt"
    click DockerIgnore "https://github.com/krutiknaina/employee-profilescan/blob/main/.dockerignore.txt"
    click Compose "https://github.com/krutiknaina/employee-profilescan/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef backend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef data fill:#ffddcc,stroke:#333,stroke-width:1px
    classDef folder fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef infra fill:#f0f0ff,stroke:#333,stroke-width:1px
```
