-
Notifications
You must be signed in to change notification settings - Fork 1
Frontend1 #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Frontend1 #7
Changes from all commits
8944580
6160c0c
24403b1
cd4483b
9d8fed8
ee8c165
2c8a2f5
668a3ae
4bc3b4b
24fd57d
fa7b1eb
0628f78
c8eec05
54ab6c0
2b318d5
d5147f4
8305ca5
e13634b
085c6a1
8c8d981
3edd958
b3bf46e
3cf80f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| backend/Docker/deploy_key | ||
| backend/Docker/deploy_key.pub | ||
| *.pyc |
| 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 | ||
|  | ||
|
|
||
|  |
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there a zip file ? Remove. |
| 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"] |
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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. |
There was a problem hiding this comment.
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