Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8944580
Add files via upload
ASROYAL Feb 22, 2026
6160c0c
updated branch variable
ASROYAL Feb 22, 2026
24403b1
frontend integration with backend is added
ASROYAL Feb 25, 2026
cd4483b
Update docker-compose.yml
ASROYAL Mar 2, 2026
9d8fed8
Add passphrase instruction for SSH key generation
someRandomDude-a Mar 2, 2026
ee8c165
Merge branch 'main' into frontend
someRandomDude-a Mar 2, 2026
2c8a2f5
fixed comments
someRandomDude-a Mar 2, 2026
668a3ae
Update docker-compose.yml
someRandomDude-a Mar 2, 2026
4bc3b4b
updated db code to be more secure handling wise
someRandomDude-a Mar 2, 2026
24fd57d
added openSSL libraries to python
someRandomDude-a Mar 2, 2026
fa7b1eb
Update requirements.txt
someRandomDude-a Mar 2, 2026
0628f78
Update requirements.txt
someRandomDude-a Mar 2, 2026
c8eec05
Update requirements.txt
someRandomDude-a Mar 2, 2026
54ab6c0
added api to create new package
someRandomDude-a Mar 2, 2026
2b318d5
updated authentication code to be indexed, renamed variable to be mor…
someRandomDude-a Mar 2, 2026
d5147f4
added API documentation for Create New Package
someRandomDude-a Mar 2, 2026
8305ca5
fixed documentation to be representative of current state
someRandomDude-a Mar 18, 2026
e13634b
Merge branch 'main' into frontend2
someRandomDude-a Mar 18, 2026
085c6a1
squash commit for frontend1 branch
someRandomDude-a Mar 21, 2026
8c8d981
implemented updated docker build steps from main, for testing purposes
someRandomDude-a Mar 25, 2026
3edd958
Update .gitignore
someRandomDude-a Mar 26, 2026
b3bf46e
Merge branch 'frontend1' of https://github.com/someRandomDude-a/VAT-G…
someRandomDude-a Mar 26, 2026
3cf80f4
Delete Dockerfile
someRandomDude-a Apr 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
backend/Docker/deploy_key
backend/Docker/deploy_key.pub
*.pyc
148 changes: 84 additions & 64 deletions README.md
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change, the one on main is upto date

Original file line number Diff line number Diff line change
@@ -1,71 +1,91 @@
# VAT-Gate

A web based tool too allow senders to easily compare delivery routes based on cost and time parameters.
Front end will be basically let user choose to and from places then calulate the best route showing him time and route also mode of transport and tracking options

## How To Run?

### This project uses docker to run

- Step 1:
Install docker on your deployment location. For installation, refer to [Docker Desktop](https://docs.docker.com/get-started/get-docker/) or [Docker Engine](https://docs.docker.com/engine/install/)
- Step 2:
create a `docker-compose.yaml` file

```yaml
services:
# PHP Service
python:
image: ghcr.io/somerandomdude-a/vat-gate:main
container_name: python-container
ports:
- "8080:80"
depends_on:
- db
environment:
MYSQL_HOST: db
MYSQL_USER: root
MYSQL_PASSWORD: example
MYSQL_DATABASE: VAT_database
restart: unless-stopped

phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin-container
environment:
PMA_HOST: db
PMA_USER: root
PMA_PASSWORD: example
ports:
- "8081:80"
depends_on:
- db
restart: unless-stopped

# MariaDB Service
db:
image: mariadb:latest
container_name: mariadb-container
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: VAT_database
ports:
- "3306:3306"
volumes:
- VAT_database:/var/lib/mysql
restart: unless-stopped

volumes:
VAT_database:
driver: local
A web-based tool that lets senders compare delivery routes based on cost and time. Users select origin and destination locations, and the system calculates the optimal route — showing estimated time, cost, mode of transport, and package tracking.

## Architecture

| Service | Technology | Port |
|---------|-----------|------|
| Frontend | React 18 + TypeScript + Vite | `5173` |
| Backend | Python 3.11 + Flask + SQLAlchemy | `8080` |
| Database | MariaDB 10.11 | `3306` |
| DB Admin | PHPMyAdmin | `8081` |

The backend uses Dijkstra's algorithm for route optimization and a blockchain-style SHA-256 event chain for tamper-evident package tracking.

---

## Running with Docker (Recommended)

### Prerequisites

- [Docker Desktop](https://docs.docker.com/get-started/get-docker/) or [Docker Engine](https://docs.docker.com/engine/install/) with the Compose plugin

### Steps

1. Clone the repository:
```bash
git clone https://github.com/someRandomDude-a/VAT-Gate.git
cd VAT-Gate
```

2. Start all services:
```bash
docker compose up --build
```

3. Open your browser:
- **App:** http://localhost:5173
- **API:** http://localhost:8080
- **PHPMyAdmin:** http://localhost:8081

To stop: `Ctrl+C`, then `docker compose down`

To reset the database: `docker compose down -v` (removes the `db_data` volume)

---

## Default Credentials

| Role | Email | Password |
|------|-------|----------|
| Admin | `admin@vatguard.com` | `admin@vatguard.com` |
| User | `user@vatguard.com` | `user@vatguard.com` |
| PHPMyAdmin | `root` | `example` |

---

## Running Locally (Without Docker)

### Backend

```bash
cd backend
pip install -r requirements.txt
# Set environment variables for your local MariaDB instance:
export MYSQL_USER=root
export MYSQL_PASSWORD=example
export MYSQL_HOST=localhost
export MYSQL_DATABASE=VAT_database
python init_db.py
python main.py
```

- Step 3:
Run `docker compose up --build`
### Frontend

- Step 5:
Open a web browser and navigate to `localhost:8080` for the website itself.<br>
Navigate to `localhost:8081` to access PHPmyadmin portal
```bash
cd frontend
npm install
npm run dev
```

The frontend reads the API URL from `frontend/.env`:
```
VITE_API_BASE_URL=http://localhost:8080
```

---

## Database Design
![Database Designer](./backend/Database%20design.png)

![Database Design](./backend/Database%20design.png)
Binary file added backend.zip
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a zip file ? Remove.

Binary file not shown.
44 changes: 31 additions & 13 deletions backend/Docker/customPython.dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
# Use Python 3.9 Slim base image
FROM python:3.9-slim
# ---- Frontend build stage ----
FROM node:20-alpine AS frontend-builder

# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends git openssh-client\
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app/frontend

# Copy only package files first
COPY frontend/package*.json ./
RUN npm install

# Copy the rest of the frontend source
COPY frontend/ ./

# Build the TSX app
RUN npm run build

# --------------- backend build stage ------------------
FROM python:3.14-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libssl-dev \
libffi-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy the local repository into the container during build
COPY backend/requirements.txt /app/backend/
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r /app/backend/requirements.txt

COPY . /app

# Install Python dependencies
RUN pip install --no-cache-dir -r /app/backend/requirements.txt
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist

# Expose port
EXPOSE 80

# Set the default command to run the app
CMD ["gunicorn", "-w", "1", "--threads", "2", "-b", "0.0.0.0:80", "backend.main:app"]
WORKDIR /app/backend

CMD ["gunicorn", "-w", "1", "--threads", "2", "-b", "0.0.0.0:80", "main:app"]
32 changes: 26 additions & 6 deletions backend/Docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
services:
# Python Service
python:
image: ghcr.io/somerandomdude-a/vat-gate:main
build:
context: ../../
dockerfile: backend/Docker/customPython.dockerfile
container_name: python-container
ports:
- "8080:80"
depends_on:
- db
db:
condition: service_healthy
environment:
MYSQL_HOST: db
MYSQL_USER: root
MYSQL_PASSWORD: example
MYSQL_DATABASE: VAT_database
restart: unless-stopped
networks:
- backend

# PHP myadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin-container
Expand All @@ -24,7 +30,11 @@ services:
ports:
- "8081:80"
depends_on:
- db
db:
condition: service_healthy
networks:
- backend

restart: unless-stopped

# MariaDB Service
Expand All @@ -34,12 +44,22 @@ services:
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: VAT_database
ports:
- "3306:3306"
volumes:
- VAT_database:/var/lib/mysql
restart: unless-stopped
networks:
- backend
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
start_period: 10s
interval: 10s
timeout: 5s
retries: 3

volumes:
VAT_database:
driver: local
driver: local

networks:
backend:
driver: bridge
6 changes: 6 additions & 0 deletions backend/db.py
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not rename variables, verbose names are for clarity.

Do not use default argument with datetime.now
This argument is evaluated ONCE at initialisation and will not be updated before every run.

Justify the changes in length for the character arrays in token hash etc. these have been turned for their respective hashing algorithm and should not be changed unless the underlying code has been changed

User.id should be an index. We search our database mainly using user id.

Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class Package(db.Model):
)

created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
value = db.Column(db.Numeric(precision=10, scale=2), nullable=True, default=0.0)
name = db.Column(db.String(255), nullable=True, default="")

current_node = db.relationship('Node', foreign_keys=[current_node_id])
origin_node = db.relationship('Node', foreign_keys=[origin_node_id])
destination_node = db.relationship('Node', foreign_keys=[destination_node_id])

class PackageEvent(db.Model):
__tablename__ = "package_events"
Expand Down
Loading