Skip to content

dhruvpatel16120/Gas-Agency-System

Repository files navigation

πŸš€ Gas Agency System

Gas Agency System Logo

Gas Agency System

A modern, full-stack gas cylinder booking and management platform designed for agencies and customers.
Built with Next.js 15 (App Router), TypeScript, Prisma, and PostgreSQL.

Live Demo Deployed on Vercel Next.js TypeScript Prisma PostgreSQL Tailwind CSS License

πŸš€ Live Application: agani-gas-agency-system.vercel.app


πŸ› οΈ Tech Stack

Our Gas Agency System is built with cutting-edge technologies to ensure performance, security, and scalability:

Frontend Technologies

  • Next.js 15.4.7 - React framework with App Router
  • TypeScript 5.0 - Type-safe JavaScript
  • Tailwind CSS 4.0 - Utility-first CSS framework
  • React Hook Form - Form handling and validation
  • Zod - Schema validation
  • Framer Motion - Animation library
  • Lucide React - Beautiful icons

Backend & Database

  • Next.js API Routes - Server-side API endpoints
  • Prisma 6.14.0 - Database ORM
  • PostgreSQL - Multi-environment cloud or local database support
  • NextAuth.js 4.24.11 - Authentication framework
  • Nodemailer - Email service
  • Puppeteer - PDF invoice generation

Development Tools

  • ESLint - Code linting
  • Prettier - Code formatting
  • Husky - Git hooks
  • Jest - Testing framework

✨ Features

πŸ” Authentication & Security

  • Multi-role Authentication: User and Admin roles with secure session management.
  • Email Verification: Account verification with email confirmation.
  • Password Reset: Secure password reset with email tokens.
  • Session Security: NextAuth.js with secure session handling.

πŸ“± User Dashboard

  • Quota Management: Track remaining cylinder quota (12 per year).
  • Booking System: Easy cylinder booking with multiple payment options.
  • Booking History: Complete booking history with status tracking.
  • Real-time Tracking: Live delivery tracking with status updates.
  • Payment Integration: UPI and Cash on Delivery (COD) support.
  • Profile Management: Update personal information and preferences.

🏒 Admin Dashboard

  • Comprehensive Analytics: Revenue, bookings, deliveries, and user statistics.
  • User Management: View, edit, and manage user accounts.
  • Booking Management: Approve, reject, and track all bookings.
  • Inventory Management: Real-time cylinder stock monitoring.
  • Delivery Management: Assign delivery partners and track deliveries.
  • Payment Review: Review and approve UPI payments.
  • Contact Management: Handle customer support inquiries.
  • Reporting: Export data and generate reports.

πŸ“Έ Application Preview

Here's a preview of the key features and interfaces in the Gas Agency System:

Feature Preview
User Dashboard User Dashboard
Booking Form Booking Form
Payment Interface Payment Interface
Tracking Page Tracking Page
Admin Dashboard Admin Dashboard
Booking Management Booking Management
Inventory Management Inventory Management
User Management User Management

πŸ“¦ Prerequisites

Before setting up the Gas Agency System, ensure you have the following:

  • Node.js (v18.0.0 or higher) - Download here
  • npm (v9.0.0 or higher) or yarn
  • Git for version control
  • PostgreSQL Database (You can choose one of the options below):
    • Local PostgreSQL: Installed on your local machine (port 5432).
    • Supabase: Managed PostgreSQL database with built-in connection pooling.
    • Railway: Cloud PostgreSQL hosting.
    • Neon: Serverless Cloud PostgreSQL database.
  • Gmail Account: Required for email notifications (with 2-Factor Authentication enabled to generate an App Password).

πŸš€ Quick Start

1. Clone and Install

git clone https://github.com/dhruvpatel16120/Gas-Agency-System.git
cd Gas-Agency-System
npm install

2. Run Interactive Setup Script

Configure environment variables quickly and interactively by running:

npm run setup

This guided CLI will prompt you for:

  • Database Connection URLs (Pooler/Transaction and Direct URLs)
  • NextAuth configuration details (automatically generating secure secrets if needed)
  • SMTP Gmail credentials (providing steps to generate a Gmail App Password)
  • Payment gateway configurations (ADMIN_UPI_ID)

3. Database Configuration

Based on your database choice in the Prerequisites, configure your .env variables accordingly.

Important

Since Prisma migrations execute DDL commands, connecting to a pooled database in Transaction Mode (e.g. Supabase port 6543) will result in prepared statement "s1" already exists errors. You must provide a DIRECT_URL connecting to port 5432 (or direct database host) to bypass the connection pooler.

Follow the instructions below for your selected setup:

Option A: Local PC PostgreSQL Setup

  1. Make sure your local PostgreSQL service is running.
  2. In .env, set:
    DATABASE_URL="postgresql://postgres:password@localhost:5432/gas_agency?schema=public"
    DIRECT_URL="postgresql://postgres:password@localhost:5432/gas_agency?schema=public"

Option B: Supabase Setup

  1. Go to Supabase Console and provision a new project.
  2. Under Project Settings β†’ Database, get your connection strings.
  3. Select Transaction Mode (port 6543) for DATABASE_URL (requires ?pgbouncer=true parameter).
  4. Select Session Mode or use the direct connection (port 5432) for DIRECT_URL.
    DATABASE_URL="postgresql://postgres.ref:password@aws-0-ap-southeast-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
    DIRECT_URL="postgresql://postgres.ref:password@aws-0-ap-southeast-1.pooler.supabase.com:5432/postgres"

Option C: Railway Setup

  1. Go to Railway and create a new project with PostgreSQL.
  2. Under variables, copy the DATABASE_PUBLIC_URL (or DATABASE_URL).
  3. If not using a pooler, you can point both variables to the same connection URL:
    DATABASE_URL="postgresql://postgres:password@host:port/railway"
    DIRECT_URL="postgresql://postgres:password@host:port/railway"

Option D: Neon Setup

  1. Go to Neon Console and create a database project.
  2. In your connection details, choose the pooled connection URL for DATABASE_URL (for transaction handling).
  3. Choose the unpooled direct connection URL for DIRECT_URL.
    DATABASE_URL="postgresql://user:password@ep-pooled-instance.aws.neon.tech/neondb?sslmode=require"
    DIRECT_URL="postgresql://user:password@ep-direct-instance.aws.neon.tech/neondb?sslmode=require"

4. Apply Database Schema & Seed Data

You can easily handle this step interactively by running:

npm run setup:db

This CLI tool allows you to:

  1. Generate the Prisma Client
  2. Run migrations (npm run db:migrate / npm run db:push)
  3. Reset Database (⚠️ Destructive)
  4. Seed Sample Data (npm run db:seed)
  5. Launch Prisma Studio (npm run db:studio)

5. Create Admin Account

Create and manage your administrator account interactively:

npm run admin

Select Create or Update Admin User from the menu and follow the prompts.

6. Run Development Server

npm run dev

Visit http://localhost:3000 in your browser!


πŸ›‘οΈ Admin CLI Operations

Our system comes with a built-in admin utility to manage roles, credentials, and user deletion. Run:

npm run admin

Available Commands in Menu:

  • Create or Update Admin User: Register new administrators or promote existing users.
  • List Admin Users: Quickly view all admin emails and identifiers.
  • Change Admin Password: Prompt to securely change password with validation checks.
  • Delete Admin User: Permanently remove administrator users from the database.

πŸ“ Project Structure

gas-agency-system/
β”œβ”€β”€ πŸ“ prisma/                    # Database schema and migrations
β”‚   β”œβ”€β”€ πŸ“ migrations/           # Database migration files
β”‚   └── schema.prisma           # Database schema definition
β”œβ”€β”€ πŸ“ public/                   # Static assets
β”œβ”€β”€ πŸ“ scripts/                  # Setup and utility scripts
β”‚   β”œβ”€β”€ utils.js                # Core interactive prompts utilities
β”‚   β”œβ”€β”€ setup-project.js        # Master setup orchestrator
β”‚   β”œβ”€β”€ setup-env.js            # Environment setup module
β”‚   β”œβ”€β”€ setup-db.js             # Database command manager
β”‚   └── admin-ops.js            # Unified Admin operations CLI
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ app/                 # Next.js App Router pages & API
β”‚   β”œβ”€β”€ πŸ“ components/          # Reusable UI & Context providers
β”‚   └── πŸ“ lib/                 # Auth, DB, email, security, validation
β”œβ”€β”€ package.json                # Dependencies and scripts
└── tsconfig.json              # TypeScript configuration

πŸ”§ Available Scripts

Command Description
npm run dev Starts Next.js development server in Turbopack mode
npm run build Builds the application for production (includes client generation)
npm run start Starts Next.js production server
npm run setup Launches master interactive project setup menu
npm run setup:env Launches interactive environment config builder
npm run setup:db Launches interactive database migrations and commands utility
npm run admin Launches interactive administrator account manager
npm run db:generate Manually generates the Prisma Client
npm run db:push Syncs schema changes directly with the database
npm run db:migrate Runs database migrations safely via Prisma Migrate
npm run db:reset Wipes and resets database schema and data (⚠️ Destructive)
npm run db:seed Runs seed script to populate sample cylinders and data
npm run db:studio Opens Prisma Studio GUI in your browser
npm run lint Runs ESLint analysis for code quality
npm run format Formats codebase with Prettier

🀝 Contributing

We welcome contributions! Please see our Contributing Guide and adhere to our Code of Conduct.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

Dhruv Patel


πŸ“ž Support

If you have questions or need support:

  1. Refer to our Technical Documentation
  2. Open an Issue on our repository
  3. Star this project if you find it helpful! ⭐

About

modern, full-stack gas cylinder booking and management platform designed for agencies and customers. Built with Next.js 15, TypeScript, Prisma, and PostgreSQL.

Topics

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages