# mustafaemresahin/post-office-database architecture

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

- Interactive diagram: https://gitdiagram.com/mustafaemresahin/post-office-database
- Repository: https://github.com/mustafaemresahin/post-office-database

## Overview

##### Project Type and Purpose
- This is a full-stack web application for managing postal services (the “Post Office Database Application”).
- Frontend: A React single-page application (SPA) under client/
- Backend: A Node.js/Express server under server/
- Database: MySQL (SQL dump provided)
- Purpose: Enable Admins, Employees, and Customers to register, send/track packages, manage inventory, and view reports.

##### File Structure
- Top-level:
- client/ (React app with src/, public/, build/)
- server/ (Express entry point index.js, package.json)
- Procfile (Heroku deployment)
- sql dump file.sql (MySQL schema and seed data)
- client/src/: Organized into components/, pages/, context/ (AuthContext, shop-context), CSS, and assets
- server/: Contains Express server code, middleware likely imported from node_modules
- Build and deployment files: Procfile, package.json scripts for dev, build, prod

##### README for Additional Insights
- Tech stack: React, Node.js, MySQL
- Key features: user roles, package status updates, vehicle & employee assignment, automated notifications, inventory alerts, multiple report types
- Deployment: Supports both development (npm run dev) and production (npm run build + npm run prod) with Heroku integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Clients
    subgraph "User Clients" 
        direction TB
        Admin["Admin"]:::user
        Employee["Employee"]:::user
        Customer["Customer"]:::user
    end

    %% Frontend Layer
    subgraph "Frontend (React SPA)" 
        direction TB
        SRC["React Frontend (client/src/)"]:::frontend
        BUILD["Built Frontend (client/build/)"]:::frontend
        PUBLIC["Public Static Files (client/public/)"]:::frontend
        CONTEXT1["AuthContext"]:::frontend
        CONTEXT2["ShopContext"]:::frontend
        COMP_HEADER["Header Component"]:::frontend
        PAGES["React Pages (client/src/pages/)"]:::frontend

        SRC -->|build process| BUILD
        SRC -->|serves static| PUBLIC
        SRC --> CONTEXT1
        SRC --> CONTEXT2
        SRC --> COMP_HEADER
        SRC --> PAGES
    end

    %% Backend Layer
    subgraph "Backend (Node.js/Express)" 
        direction TB
        SERVER["Express API Server\n(server/index.js)"]:::backend
        ROUTES["Route Handlers"]:::backend
        CONTROLLERS["Controllers → Services → Models"]:::backend
        PKG_SERVER["Server Config & Scripts\n(server/package.json)"]:::backend
    end

    %% Database
    subgraph "Database" 
        direction TB
        DB["MySQL Database\n(sql dump file.sql)"]:::database
    end

    %% External Services
    subgraph "External Services" 
        direction TB
        NOTIF["Notification Service\n(Email/SMS Gateway)"]:::external
    end

    %% Hosting & CI/CD
    subgraph "Hosting & CI/CD" 
        direction TB
        GITHUB["GitHub Repo"]:::infra
        HEROKU["Heroku (Procfile)"]:::infra
        PKG_CLIENT["Client Config & Scripts\n(client/package.json)"]:::infra
    end

    %% Connections
    Admin -->|uses| SRC
    Employee -->|uses| SRC
    Customer -->|uses| SRC

    BUILD -->|deployed to| HEROKU
    PUBLIC -->|served by| HEROKU

    SRC -->|REST API calls| SERVER
    SERVER -->|uses| ROUTES
    ROUTES -->|invoke| CONTROLLERS
    CONTROLLERS -->|query| DB
    CONTROLLERS -->|trigger| NOTIF

    GITHUB -->|deploys via CI/CD| HEROKU

    %% Click Events
    click SRC "https://github.com/mustafaemresahin/post-office-database/tree/main/client/src/"
    click BUILD "https://github.com/mustafaemresahin/post-office-database/tree/main/client/build/"
    click PUBLIC "https://github.com/mustafaemresahin/post-office-database/tree/main/client/public/"
    click CONTEXT1 "https://github.com/mustafaemresahin/post-office-database/blob/main/client/src/context/AuthContext.js"
    click CONTEXT2 "https://github.com/mustafaemresahin/post-office-database/blob/main/client/src/context/shop-context.jsx"
    click COMP_HEADER "https://github.com/mustafaemresahin/post-office-database/blob/main/client/src/components/Header.jsx"
    click PAGES "https://github.com/mustafaemresahin/post-office-database/tree/main/client/src/pages/"
    click SERVER "https://github.com/mustafaemresahin/post-office-database/blob/main/server/index.js"
    click PKG_SERVER "https://github.com/mustafaemresahin/post-office-database/blob/main/server/package.json"
    click DB "https://github.com/mustafaemresahin/post-office-database/blob/main/sql dump file.sql"
    click HEROKU "https://github.com/mustafaemresahin/post-office-database/tree/main/Procfile"
    click PKG_CLIENT "https://github.com/mustafaemresahin/post-office-database/blob/main/client/package.json"

    %% Styles
    classDef user fill:#D6E9FE,stroke:#5B9BD5,color:#0B3D91
    classDef frontend fill:#E8F1FD,stroke:#4A90E2,color:#1E3A8A
    classDef backend fill:#E8F8F5,stroke:#2CC28F,color:#0B3A33
    classDef database fill:#FFF4E5,stroke:#F5A623,color:#A65400
    classDef external fill:none,stroke-dasharray: 5 5,stroke:#888888,color:#888888
    classDef infra fill:#F4F4F4,stroke:#CCCCCC,color:#666666
```
