# vannguyen799/nutrition_web architecture

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

- Interactive diagram: https://gitdiagram.com/vannguyen799/nutrition_web
- Repository: https://github.com/vannguyen799/nutrition_web

## Overview

##### Main Components

A. Backend (Django) Layer:
- Admin Module
- admin_auth (Authentication)
- dashboard
- dishmanage
- foodmanage
- food_article_manage
- nutrientmanage
- peoplegroupmanage
- usermanage

- User Module
- user_auth
- home
- foodarticle

- Core Configuration
- nutrition_web (main Django project)
- settings, URLs, and configurations

B. Database Layer:
- MySQL Database (evident from mysql_database folder)
- Models for different modules

C. Static Assets Layer:
- Admin Interface Assets
- User Interface Assets
- JavaScript Components
- CSS Styles

D. Media Storage:
- Image Storage
- Upload Management

E. Data Collection Component:
- Web Crawler (data_crawl module)

##### Relationship Flows to Illustrate

- User requests → Django URLs → Views → Models → Database
- Authentication flows for both admin and user areas
- Static/Media file serving paths
- Data crawling process to database storage

- [Client Layer]
- ↕️
- [Web Server Layer (Django)]
- ↕️
- [Application Logic Layer]
- ↕️
- [Data Storage Layer]

##### Additional Elements

- Security layers (authentication/authorization)
- Template rendering flow
- Static/Media file serving
- Data crawling pipeline
- Database interaction patterns

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UA[User Access]
        AA[Admin Access]
    end

    subgraph "Django Core"
        DC["Django Configuration"]:::core
        DU["URL Router"]:::core
        click DC "https://github.com/vannguyen799/nutrition_web/blob/master/nutrition_web/settings.py"
        click DU "https://github.com/vannguyen799/nutrition_web/blob/master/nutrition_web/urls.py"
    end

    subgraph "Admin Interface"
        direction TB
        AA1["Admin Authentication"]:::admin
        AD["Dashboard"]:::admin
        DM["Dish Management"]:::admin
        FM["Food Management"]:::admin
        FAM["Food Article Management"]:::admin
        NM["Nutrient Management"]:::admin
        PGM["People Group Management"]:::admin
        UM["User Management"]:::admin
        click AA1 "https://github.com/vannguyen799/nutrition_web/tree/master/admin/admin_auth/"
        click AD "https://github.com/vannguyen799/nutrition_web/tree/master/admin/dashboard/"
        click DM "https://github.com/vannguyen799/nutrition_web/tree/master/admin/dishmanage/"
        click FM "https://github.com/vannguyen799/nutrition_web/tree/master/admin/foodmanage/"
        click FAM "https://github.com/vannguyen799/nutrition_web/tree/master/admin/food_article_manage/"
        click NM "https://github.com/vannguyen799/nutrition_web/tree/master/admin/nutrientmanage/"
        click PGM "https://github.com/vannguyen799/nutrition_web/tree/master/admin/peoplegroupmanage/"
        click UM "https://github.com/vannguyen799/nutrition_web/tree/master/admin/usermanage/"
    end

    subgraph "User Interface"
        direction TB
        UA1["User Authentication"]:::user
        UH["Home Interface"]:::user
        UF["Food Article Interface"]:::user
        click UA1 "https://github.com/vannguyen799/nutrition_web/tree/master/user/user_auth/"
        click UH "https://github.com/vannguyen799/nutrition_web/tree/master/user/home/"
        click UF "https://github.com/vannguyen799/nutrition_web/tree/master/user/foodarticle/"
    end

    subgraph "Templates"
        AT["Admin Templates"]:::template
        UT["User Templates"]:::template
        BT["Base Templates"]:::template
        click AT "https://github.com/vannguyen799/nutrition_web/tree/master/templates/admin/"
        click UT "https://github.com/vannguyen799/nutrition_web/tree/master/templates/user/"
        click BT "https://github.com/vannguyen799/nutrition_web/blob/master/templates/base.html"
    end

    subgraph "Static Assets"
        AIS["Admin Interface Assets"]:::static
        UIS["User Interface Assets"]:::static
        JS["JavaScript Components"]:::static
        CSS["CSS Styles"]:::static
        click AIS "https://github.com/vannguyen799/nutrition_web/tree/master/static/admin/"
        click UIS "https://github.com/vannguyen799/nutrition_web/tree/master/static/user/"
        click JS "https://github.com/vannguyen799/nutrition_web/tree/master/static/js/"
        click CSS "https://github.com/vannguyen799/nutrition_web/tree/master/static/css/"
    end

    subgraph "Media Storage"
        AM["Admin Media"]:::media
        GM["General Media"]:::media
        click AM "https://github.com/vannguyen799/nutrition_web/tree/master/media/admin/"
        click GM "https://github.com/vannguyen799/nutrition_web/tree/master/media/media/"
    end

    subgraph "Data Collection"
        WC["Web Crawler"]:::datacollect
        US["URL Storage"]:::datacollect
        click WC "https://github.com/vannguyen799/nutrition_web/blob/master/data_crawl/cetedu.py"
        click US "https://github.com/vannguyen799/nutrition_web/blob/master/data_crawl/food_article_url.txt"
    end

    subgraph "Database Layer"
        DB[(MySQL Database)]:::database
        DS["Database Schema"]:::database
        ID["Initial Data"]:::database
        click DS "https://github.com/vannguyen799/nutrition_web/blob/master/mysql_database/database.sql"
        click ID "https://github.com/vannguyen799/nutrition_web/blob/master/mysql_database/prepare_data.sql"
    end

    %% Connections
    UA --> DU
    AA --> DU
    DU --> DC

    %% Admin Connections
    DU --> AA1
    AA1 --> AD
    AD --> DM
    AD --> FM
    AD --> FAM
    AD --> NM
    AD --> PGM
    AD --> UM

    %% User Connections
    DU --> UA1
    UA1 --> UH
    UA1 --> UF

    %% Template Connections
    AD & DM & FM & FAM & NM & PGM & UM --> AT
    UH & UF --> UT
    AT & UT --> BT

    %% Static and Media Connections
    AT --> AIS
    UT --> UIS
    AT & UT --> JS
    AT & UT --> CSS
    FAM --> AM
    UF --> GM

    %% Data Collection Flow
    WC --> US
    WC --> DB
    
    %% Database Connections
    DS --> DB
    ID --> DB
    DM & FM & FAM & NM & PGM & UM --> DB
    UF & UH --> DB

    %% Styling
    classDef core fill:#3498db
    classDef admin fill:#e74c3c
    classDef user fill:#2ecc71
    classDef template fill:#9b59b6
    classDef static fill:#f1c40f
    classDef media fill:#e67e22
    classDef database fill:#34495e
    classDef datacollect fill:#1abc9c
```
