# atharvamanchalkar/bynx architecture

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

- Interactive diagram: https://gitdiagram.com/atharvamanchalkar/bynx
- Repository: https://github.com/atharvamanchalkar/bynx

## Overview

##### Project type and purpose
- This is a full-stack web application called “Bynx,” designed to manage waste collection operations (bins, routes, maintenance, complaints, tasks, reports, etc.).
- Frontend: React (CRA)
- Backend: Python 3.8+ with FastAPI (via Uvicorn)
- Datastores: MySQL (relational data) and MongoDB (document data)

##### File structure
- Top‐level splits into `bynx-backend/` and `bynx-frontend/`.
- Backend organizes code by feature:
- `app/auth` for authentication handlers
- `app/crud` for data‐access functions per entity
- `app/routes` for HTTP endpoints grouped by resource
- `app/schemas` for Pydantic models
- `app/database` for MySQL and MongoDB connectors
- Frontend follows a standard React directory layout:
- `src/pages/` for route‐based views (Dashboard, Login, BinManagement, etc.)
- `src/components/` for reusable UI elements (Navbar, Sidebar, Announcements)
- `src/api/axios.js` to centralize HTTP client configuration

##### README for additional insights
- Two terminal processes: one for backend (`uvicorn app.main:app --reload`), one for frontend (`npm start`).
- Relational (MySQL) and document (MongoDB) databases run locally.
- Environment variables configure DB credentials.

##### Detailed guidance
- For each feature area (bins, complaints, tasks), show how the React page calls a specific route, how that maps to a CRUD module, and which database is touched
- Shared cross‐cutting concerns like authentication (JWT issuance and validation middleware)
- Startup configuration: .env → Uvicorn launch → DB connections established

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        User["User's Browser"]:::external
        ReactSPA["React SPA"]:::frontend
        StaticServer["Dev Server (npm start)"]:::frontend
        EntryPoint["SPA Entry Point"]:::frontend
        Axios["HTTP Client (Axios)"]:::frontend
        Pages["Route-based Views"]:::frontend
        Components["Reusable UI Components"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        FastAPI["FastAPI Server"]:::backend
        APILayer["API Layer (Routes)"]:::backend
        AuthRoutes["Auth Routes"]:::backend
        AuthService["Auth Service"]:::backend
        CRUD["CRUD Modules"]:::backend
        Schemas["Pydantic Schemas"]:::backend
        Persistence["Persistence Layer"]
        direction TB
        MySQLConn["MySQL Connector"]:::db
        MongoConn["MongoDB Connector"]:::db
    end

    %% Database Layer
    subgraph "Databases"
        direction TB
        MySQLDB["MySQL Server"]:::db
        MongoDB["MongoDB Server"]:::db
    end

    %% Other Backend Components
    Env["Environment Config (.env)"]:::note
    DBInit["Database Init Script"]:::backend
    SampleData["Sample Data (Seeding)"]:::backend
    CI["CI Workflow"]:::misc
    ReqBackend["Backend Dependencies"]:::misc
    ReqFrontend["Frontend Dependencies"]:::misc

    %% Connections Client
    User -->|uses| ReactSPA
    ReactSPA -->|served by| StaticServer
    ReactSPA -->|entry| EntryPoint
    ReactSPA -->|uses| Pages
    ReactSPA -->|uses| Components
    ReactSPA -->|HTTP REST| FastAPI
    ReactSPA -->|calls| Axios

    %% Connections Server
    FastAPI -->|routes| APILayer
    APILayer -->|includes| AuthRoutes
    APILayer -->|calls| CRUD
    APILayer -->|uses| Schemas
    AuthRoutes -->|uses| AuthService
    CRUD -->|injects| MySQLConn
    CRUD -->|injects| MongoConn
    MySQLConn -->|connects to| MySQLDB
    MongoConn -->|connects to| MongoDB
    Env -.-> FastAPI
    DBInit -->|initializes| MySQLConn
    DBInit -->|initializes| MongoConn
    SampleData -->|seeds| MySQLDB
    SampleData -->|seeds| MongoDB
    ReqBackend -->|dependencies| FastAPI
    ReqFrontend -->|dependencies| ReactSPA
    CI -->|tests/lints| ReactSPA
    CI -->|tests/lints| FastAPI

    %% Click Events
    click ReactSPA "https://github.com/atharvamanchalkar/bynx/tree/main/bynx-frontend/src"
    click StaticServer "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-frontend/package.json"
    click Axios "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-frontend/src/api/axios.js"
    click Pages "https://github.com/atharvamanchalkar/bynx/tree/main/bynx-frontend/src/pages"
    click Components "https://github.com/atharvamanchalkar/bynx/tree/main/bynx-frontend/src/components"
    click EntryPoint "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-frontend/src/index.js"
    click FastAPI "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-backend/app/main.py"
    click AuthService "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-backend/app/auth/auth_handler.py"
    click AuthRoutes "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-backend/app/routes/auth.py"
    click CRUD "https://github.com/atharvamanchalkar/bynx/tree/main/bynx-backend/app/crud"
    click APILayer "https://github.com/atharvamanchalkar/bynx/tree/main/bynx-backend/app/routes"
    click Schemas "https://github.com/atharvamanchalkar/bynx/tree/main/bynx-backend/app/schemas"
    click MySQLConn "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-backend/app/database/mysql.py"
    click MongoConn "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-backend/app/database/mongodb.py"
    click DBInit "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-backend/init_db.py"
    click SampleData "https://github.com/atharvamanchalkar/bynx/tree/main/bynx-backend/sample_data"
    click ReqBackend "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-backend/requirements.txt"
    click ReqFrontend "https://github.com/atharvamanchalkar/bynx/blob/main/bynx-frontend/package.json"
    click CI "https://github.com/atharvamanchalkar/bynx/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef frontend fill:#C3E8FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#D4F8C4,stroke:#28A745,color:#28A745
    classDef db fill:#FFE4B5,stroke:#D2691E,color:#D2691E
    classDef external fill:#F0F0F0,stroke:#999999,color:#333333
    classDef note fill:#FFFACD,stroke:#F0E68C,color:#B8860B
    classDef misc fill:#E8E8E8,stroke:#AAAAAA,color:#555555
```
