# bahaamohamed98/eco-dispose architecture

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

- Interactive diagram: https://gitdiagram.com/bahaamohamed98/eco-dispose
- Repository: https://github.com/bahaamohamed98/eco-dispose

## Overview

##### Project Type and Purpose
- Eco-Dispose is a full-stack web application for e-waste management and recycling.
- Frontend: Vue.js single-page application (SPA) built with Vite.
- Backend: Flask REST API serving device evaluation, user authentication, and offer management.
- Data persistence via a relational database (SQLAlchemy models in backend/app/models.py).
- Users submit devices via web UI, track status, and admins review submissions.

##### File Structure
- Top-level directories:
- frontend/ – Vue.js SPA code, components, views, router, Vuex stores.
- backend/ – Flask API server, .env configuration, app package (auth.py, devices.py, models.py, util.py, config.py).
- assets/ – project-level images and preview screenshots.
- Key files:
- backend/app.py – entry point for Flask application.
- backend/requirements.txt – Python dependencies.
- frontend/src/main.js – Vue app bootstrap.
- frontend/src/router/routes.js – client-side routing.
- frontend/src/store/* – Vuex modules for user, devices, toasts, API interactions.
- Patterns:
- Client–Server separation (Vue.js UI ↔ Flask REST API).
- RESTful endpoints for auth and device workflows (see docs/api/auth.md and devices.md).
- MVC-like structure in Flask (views/controllers in auth.py & devices.py, models in models.py).

##### README for Additional Insights
- Describes user flows: registration, login, device upload with photos, status tracking, admin dashboard.
- Indicates environment-driven configuration for database, secret keys, file storage.

##### Main Components
a. Frontend (Vue.js SPA)
- Browser clients render App.vue, navigate via router, manage state in Vuex stores (userStore, deviceStore).
- Static assets (photos, CSS) served from frontend/public/assets.
b. Backend (Flask API)
- app.py initializes Flask, loads config, registers auth and device blueprints.
- Controllers handle HTTP requests, invoke models and utility functions (util.py).
c. Database
- Relational database (e.g., PostgreSQL or SQLite) accessed via SQLAlchemy ORM.
- Core entities: Users, Devices, Offers, StatusHistory.
d. File Storage
- Local or cloud‐based storage for uploaded images (configured via .env).
e. External Services (if any)
- Email/SMS for notifications (possible future extension, not explicit in code).
f. Admin Dashboard
- A protected SPA view accessing admin endpoints for device evaluation and offer management.

##### Relationships and Data Flows
- User’s browser → HTTP(S) → Frontend SPA
- Frontend SPA dispatches REST calls to Flask API (Auth, Devices, Offers endpoints).
- Flask API ↔ Database for CRUD operations on Users and Devices.
- Flask API ↔ File Storage for image uploads and retrieval.
- Admin user uses SPA admin views → API → Database/Storage.

##### Architectural Patterns and Principles
- Layered architecture: Presentation (SPA) → Application (Flask controllers) → Persistence (ORM + DB).
- RESTful design: clearly separated endpoints in backend/app/auth.py and devices.py.
- State management on client using Vuex (separation of UI and business logic).
- Configuration-driven deployment (via .env).

##### Essential Elements
- Labels on each component (e.g., “Vue.js SPA”, “Flask Auth API”, “Device Service”).
- Annotations for security (JWT tokens in headers), file upload workflow, and admin-only endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["User Browser"]:::client
        IndexHTML["index.html"]:::client
        MainJS["main.js"]:::client
        AppVue["App.vue"]:::client
        Router["routes.js"]:::client
        subgraph "Vuex Stores"
            direction TB
            APIStore["api.js"]:::client
            UserStore["userStore.js"]:::client
            DeviceStore["deviceStore.js"]:::client
            ToastStore["toastStore.js"]:::client
            Links["links.js"]:::client
        end
        subgraph "Components"
            direction TB
            NavBar["NavBar.vue"]:::client
            Footer["Footer.vue"]:::client
            ToastContainer["ToastContainer.vue"]:::client
        end
        subgraph "Views"
            direction TB
            HomePage["HomePage.vue"]:::client
            Register["Register.vue"]:::client
            Login["Login.vue"]:::client
            Profile["Profile.vue"]:::client
            EditProfile["EditProfile.vue"]:::client
            Listings["Listings.vue"]:::client
            Upload["Upload.vue"]:::client
            AdminDash["AdminDashBoard.vue"]:::client
            About["About.vue"]:::client
            NotFound["NotFound.vue"]:::client
        end
    end

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        AppPy["app.py"]:::server
        ConfigPy["config.py"]:::server
        AuthPy["auth.py"]:::server
        DevicesPy["devices.py"]:::server
        ModelsPy["models.py"]:::server
        UtilPy["util.py"]:::server
        ReqTxt["requirements.txt"]:::server
    end

    %% Persistence and Storage
    Database[(Database)]:::database
    Storage["File Storage"]:::storage

    %% Docs (External)
    subgraph "Documentation"
        direction TB
        AuthDoc["auth.md"]:::docs
        DevicesDoc["devices.md"]:::docs
        ERDDiagram["erd.dbml"]:::docs
    end

    %% Flows
    Browser -->|"GET|index.html"| IndexHTML
    IndexHTML -->|"loads"| MainJS
    MainJS -->|"bootstraps"| AppVue
    AppVue -->|"uses"| Router
    AppVue -->|"uses"| APIStore
    APIStore -->|"REST calls"| AuthPy
    APIStore -->|"REST calls"| DevicesPy
    UserStore --> APIStore
    DeviceStore --> APIStore
    ToastStore --> APIStore
    Links --> APIStore

    AuthPy -->|"validates config"| ConfigPy
    DevicesPy --> ConfigPy
    AuthPy -->|"CRUD Users"| ModelsPy
    DevicesPy -->|"CRUD Devices"| ModelsPy
    ModelsPy -->|"SQL queries"| Database
    AuthPy -->|"file ops"| UtilPy
    DevicesPy -->|"file ops"| UtilPy
    UtilPy -->|"uploads/downloads"| Storage

    Browser -->|"admin UI"| AdminDash
    AdminDash -->|"REST calls"| AuthPy
    AdminDash -->|"REST calls"| DevicesPy

    %% Documentation links
    AuthPy --> AuthDoc
    DevicesPy --> DevicesDoc
    Database --> ERDDiagram

    %% Click Events
    click MainJS "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/main.js"
    click AppVue "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/App.vue"
    click IndexHTML "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/index.html"
    click Router "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/router/routes.js"
    click APIStore "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/store/api.js"
    click UserStore "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/store/userStore.js"
    click DeviceStore "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/store/deviceStore.js"
    click ToastStore "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/store/toastStore.js"
    click Links "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/store/links.js"
    click NavBar "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/components/NavBar.vue"
    click Footer "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/components/Footer.vue"
    click ToastContainer "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/components/ToastContainer.vue"
    click HomePage "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/HomePage.vue"
    click Register "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/Register.vue"
    click Login "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/Login.vue"
    click Profile "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/Profile.vue"
    click EditProfile "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/EditProfile.vue"
    click Listings "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/Listings.vue"
    click Upload "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/Upload.vue"
    click AdminDash "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/AdminDashBoard.vue"
    click About "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/About.vue"
    click NotFound "https://github.com/bahaamohamed98/eco-dispose/blob/main/frontend/src/views/NotFound.vue"
    click AppPy "https://github.com/bahaamohamed98/eco-dispose/blob/main/backend/app.py"
    click ConfigPy "https://github.com/bahaamohamed98/eco-dispose/blob/main/backend/app/config.py"
    click AuthPy "https://github.com/bahaamohamed98/eco-dispose/blob/main/backend/app/auth.py"
    click DevicesPy "https://github.com/bahaamohamed98/eco-dispose/blob/main/backend/app/devices.py"
    click ModelsPy "https://github.com/bahaamohamed98/eco-dispose/blob/main/backend/app/models.py"
    click UtilPy "https://github.com/bahaamohamed98/eco-dispose/blob/main/backend/app/util.py"
    click ReqTxt "https://github.com/bahaamohamed98/eco-dispose/blob/main/backend/requirements.txt"
    click AuthDoc "https://github.com/bahaamohamed98/eco-dispose/blob/main/docs/api/auth.md"
    click DevicesDoc "https://github.com/bahaamohamed98/eco-dispose/blob/main/docs/api/devices.md"
    click ERDDiagram "https://github.com/bahaamohamed98/eco-dispose/blob/main/docs/diagrams/erd.dbml"

    %% Styles
    classDef client fill:#D0E7FF,stroke:#036,stroke-width:1px;
    classDef server fill:#DFF5D0,stroke:#360,stroke-width:1px;
    classDef database fill:#FFE3B8,stroke:#C66,stroke-width:1px;
    classDef storage fill:#F3D0FF,stroke:#63C,stroke-width:1px;
    classDef docs fill:#F0F0F0,stroke:#888,stroke-width:1px,stroke-dasharray: 2 2;
```
