Skip to content

exideys/Autorent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

139 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoRent

A full-stack car rental platform for browsing vehicles, creating bookings, managing rental orders, and running admin fleet operations.

React TypeScript Vite Tailwind CSS Go Gin MySQL Docker Vitest GitHub Actions

Overview

AutoRent combines a React/Vite frontend with a Go/Gin backend to deliver a complete rental workflow: public vehicle browsing, authenticated booking, user profiles, admin fleet management, news publishing, realtime support chat, AI-assisted vehicle search, and Ukrainian translation support.

The app is designed to run locally during development, ship through Docker, and publish the static frontend through GitHub Pages when configured.

Features

Area What it includes
Showroom Public vehicle listings, vehicle details, image browsing, and booking actions.
Booking Pickup/return validation, date/time checks, and protected rental order creation.
Accounts Email/password auth, optional Google sign-in, profile editing, and rental history.
Admin Fleet CRUD, image uploads, customer ratings, rental order visibility, news tools, and support tools.
Support Realtime chat, attachments, Enter-to-send, multiline messages, and admin/customer conversations.
Content Public news page with admin-managed published articles.
AI and i18n Gemini-powered car recommendations and optional DeepL Ukrainian translations.
Quality Go tests, Vitest component tests, linting, build checks, CodeQL, and dependency review.

Tech Stack

Layer Tools
Frontend React, TypeScript, Vite, Tailwind CSS, Framer Motion, lucide-react
Backend Go, Gin, MySQL driver, JWT
Database MySQL-compatible database with TiDB-style TLS defaults
Integrations Google OAuth, Google Drive storage, Gemini, DeepL
Testing Go test, Vitest, React Testing Library, jsdom
Delivery Docker, Docker Compose, Nginx, GitHub Actions, GitHub Pages

Project Structure

.
|- Backend/
|  |- internal/          # API handlers, services, repositories, auth, storage
|  |- migrations/        # SQL schema migrations
|  |- Dockerfile
|  `- main.go
|- Frontend/
|  |- src/               # React app, components, data, API client, tests
|  |- Dockerfile
|  |- nginx.conf
|  `- vite.config.js
|- docs/screenshots/     # Public README screenshots
|- .github/workflows/    # CI, CodeQL, dependency review, Pages deploy
`- compose.yml

Environment Variables

Create a root .env file for Docker Compose and backend runtime settings. The values below are examples only.

# Backend server
PORT=8080
CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000

# Database
DB_USER=root
DB_PASSWORD=
DB_HOST=localhost
DB_PORT=4000
DB_NAME=autorent
DB_TLS=tidb

# Auth
JWT_SECRET=change-this-secret
JWT_TOKEN_TTL=24h
ADMIN_SETUP_TOKEN=change-this-admin-setup-token

# Optional AI and translation
GEMINI_API_KEY=
GEMINI_MODEL=gemini-2.5-flash
DEEPL_API_KEY=
DEEPL_API_URL=https://api-free.deepl.com

# Optional Google auth
GOOGLE_AUTH_CLIENT_ID=
VITE_GOOGLE_AUTH_CLIENT_ID=

# Optional Google Drive storage
GOOGLE_DRIVE_OAUTH_CLIENT_ID=
GOOGLE_DRIVE_OAUTH_CLIENT_SECRET=
GOOGLE_DRIVE_OAUTH_REFRESH_TOKEN=
GOOGLE_DRIVE_CARS_FOLDER_ID=
GOOGLE_DRIVE_NEWS_FOLDER_ID=
GOOGLE_DRIVE_SUPPORT_FOLDER_ID=

# Upload limits
IMAGE_UPLOAD_MAX_BYTES=10485760
SUPPORT_ATTACHMENT_MAX_BYTES=10485760

# Frontend build/runtime
VITE_API_BASE_URL=http://localhost:8080
VITE_BASE_PATH=/
FRONTEND_PORT=3000

Security notes:

  • Do not commit real API keys, JWT secrets, OAuth client secrets, database passwords, refresh tokens, or admin setup tokens.
  • .env, Backend/.env, Frontend/.env, credential folders, service account JSON files, and Google Drive credential JSON files are ignored by git.
  • DB_TLS=tidb is the backend default. Use DB_TLS=false for a local MySQL server without TLS.
  • GEMINI_API_KEY, DEEPL_API_KEY, Google auth, and Google Drive settings are optional. The app disables those integrations when they are missing.

Database Setup

Apply migrations in order against your MySQL-compatible database:

mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p "$DB_NAME" < Backend/migrations/001_create_users.sql
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p "$DB_NAME" < Backend/migrations/002_create_cars_and_images.sql
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p "$DB_NAME" < Backend/migrations/003_create_rental_orders.sql
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p "$DB_NAME" < Backend/migrations/004_create_news.sql
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p "$DB_NAME" < Backend/migrations/005_create_support_messages.sql

Local Development

Start the backend:

cd Backend
go mod download
go run .

Start the frontend in another terminal:

cd Frontend
npm ci
npm run dev

The Vite dev server proxies /api requests to http://localhost:8080.

Docker

Run both services with Docker Compose:

docker compose up --build

The frontend is served by Nginx on http://localhost:3000 by default, and the backend listens on http://localhost:8080.

This Compose file expects an external MySQL-compatible database configured through .env; it does not start a database container.

Testing and Checks

Backend:

cd Backend
go test ./...

Frontend:

cd Frontend
npm run test
npm run lint
npm run build

On Windows PowerShell, if npm is blocked by execution policy, use npm.cmd:

npm.cmd run test
npm.cmd run build

API Overview

Area Endpoint
Health GET /health
Auth /api/auth
Cars /api/cars
Rental orders /api/rental-orders
News /api/news
Support /api/support
AI recommendation /api/ai/car-recommendation
Translation /api/translate
Admin /api/admin

Admin APIs require an admin JWT.

Deployment Notes

  • The frontend Docker image builds static assets and serves them through Nginx.
  • The backend Docker image runs the compiled Go API on port 8080.
  • GitHub Actions include CI checks, Docker build smoke tests, CodeQL, dependency review, and GitHub Pages deployment for the frontend.
  • For GitHub Pages deployments, configure VITE_API_BASE_URL so the static frontend can reach the deployed backend API.

About

A modern car rental web app for browsing vehicles, creating bookings, managing rental orders, and handling admin fleet operation.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages