# rowanb141/projectdatabasewebapp architecture

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

- Interactive diagram: https://gitdiagram.com/rowanb141/projectdatabasewebapp
- Repository: https://github.com/rowanb141/projectdatabasewebapp

## Overview

##### Project type and purpose
- This is a full-stack web application (“ProjectDatabaseWebApp”) that lets authenticated users view/check-in/check-out hardware and manage projects.
- Frontend: React (via Vite) with Tailwind CSS.
- Backend: Flask (Python) exposing a JSON REST API.
- Data store: MongoDB.

##### File structure
- Top-level:
– backend/ (Flask app, API routes, static “dist” folder)
– frontend/ (React + Vite source & configs)
- backend/app/routes/ splits concerns into auth.py, hardware.py, projects.py.
- backend/dist/ holds the production build of the frontend (index.html + JS/CSS assets) to be served by Flask.
- Configuration/deployment: Procfile (Heroku), .env.example, requirements.txt, postman_collection.json.
- frontend uses vite.config.js, tailwind.config.js, ESLint, and has pages/components structured in src/.

##### Extract README insights
- Dev setup requires running two servers: Vite for frontend, Flask for backend.
- JWT-based auth and protected endpoints.
- MongoDB runs locally or remotely (Compass optional).
- Deployment uses Heroku (git subtree push).

##### Main components
a. Client Layer
– Browser (React app)
– Dev: Vite Dev Server (localhost:5173)
– Prod: Static files served by Flask at / (backend/dist)
b. API Layer
– Flask application (run.py)
– Routes:
- /api/auth (register, login → issues JWT)
- /api/hardware (GET, PUT checkout/checkin)
- /api/projects (CRUD)
– Extensions: JWT manager, PyMongo connector
c. Data Layer
– MongoDB (local or hosted)
– Collections: users, hardware, projects
d. External/devops
– Postman (postman_collection.json)
– Smoke tests (backend/smoke_test.py)
– Heroku (Procfile)

##### Relationships & interactions
- Browser ↔ Frontend: user interacts via React UI → sends API requests (with JWT in Authorization header).
- Frontend → Flask API: REST calls over HTTP → JSON payloads.
- Flask API → MongoDB: queries/updates via PyMongo.
- Build pipeline:
– npm run build → dist/ → copied into backend/dist → Flask serves static.
- Auth flow: login/register → token issued → stored in browser localStorage → subsequent calls include token header.

##### Architectural patterns & design principles
- Separation of concerns: UI layer vs business/API layer vs data layer.
- Component-based UI (React).
- Modular backend routes (each resource in its own module).
- Environment-driven configuration (.env) for secrets and URIs.
- Testability: test directory, smoke tests, Postman.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["Browser"]:::frontend
        ReactApp["React App"]:::frontend
        ViteDev["Vite Dev Server"]:::frontend
        Tailwind["Tailwind CSS Config"]:::frontend
        PostCSS["PostCSS Config"]:::frontend
        Static["Static Files (Prod Build)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        Run["Flask Entry (run.py)"]:::backend
        Ext["Extensions (JWT, PyMongo)"]:::backend
        Auth["Auth Routes (/api/auth)"]:::backend
        HW["Hardware Routes (/api/hardware)"]:::backend
        Proj["Projects Routes (/api/projects)"]:::backend
        Procfile["Procfile (Heroku)"]:::backend
        Env["Env Example (.env)"]:::backend
        Req["Requirements.txt"]:::backend
        DistAssets["Prod Assets (dist/assets/)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        MongoDB["MongoDB"]:::database
    end

    %% Dev/Test Layer
    subgraph "Dev/Test & External"
        Postman["Postman Collection"]:::tools
        Smoke["Smoke Tests"]:::tools
        Tests["Test Suite"]:::tools
        TestAPI["API Tests"]:::tools
        Heroku["Heroku"]:::external
    end

    %% Relationships
    Browser --> ReactApp
    Browser -.-> ViteDev
    ViteDev --> ReactApp
    ReactApp -->|npm run build| Static
    Static --> Run
    Browser --> Static

    ReactApp -->|"HTTP API (JSON, JWT)"| Run
    Run --> Auth
    Run --> HW
    Run --> Proj
    Run --> Ext
    Ext --> MongoDB
    Run --> DistAssets

    Postman -->|API Requests| Run
    Smoke -->|Smoke Tests| Run
    Tests -->|Conftest Fixtures| Run
    TestAPI -->|API Testing| Run
    Procfile --> Run
    Env --> Run
    Req --> Run
    Heroku --> Run

    %% Click Events
    click ReactApp "https://github.com/rowanb141/projectdatabasewebapp/tree/main/frontend/src"
    click ViteDev "https://github.com/rowanb141/projectdatabasewebapp/blob/main/frontend/vite.config.js"
    click Tailwind "https://github.com/rowanb141/projectdatabasewebapp/blob/main/frontend/tailwind.config.js"
    click PostCSS "https://github.com/rowanb141/projectdatabasewebapp/blob/main/frontend/postcss.config.js"
    click Static "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/dist/index.html"
    click Run "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/run.py"
    click Ext "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/app/extensions.py"
    click Auth "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/app/routes/auth.py"
    click HW "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/app/routes/hardware.py"
    click Proj "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/app/routes/projects.py"
    click Procfile "https://github.com/rowanb141/projectdatabasewebapp/tree/main/backend/Procfile"
    click Env "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/.env.example"
    click Req "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/requirements.txt"
    click Postman "https://github.com/rowanb141/projectdatabasewebapp/blob/main/postman_collection.json"
    click Smoke "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/smoke_test.py"
    click Tests "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/tests/conftest.py"
    click TestAPI "https://github.com/rowanb141/projectdatabasewebapp/blob/main/backend/tests/test_api.py"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085
    classDef backend fill:#d4edda,stroke:#155724
    classDef database fill:#d1ecf1,stroke:#0c5460
    classDef tools fill:#fff3cd,stroke:#856404
    classDef external fill:#f8d7da,stroke:#721c24
```
