Go AutoMarket Pro

Welcome to Go AutoMarket Pro, the ultimate marketplace for vehicles, parts, and services. This project is a robust web application built with modern technologies to provide a seamless experience for buyers, sellers, agencies, and service providers in the automotive industry.

Table of Contents

Project Overview

Go AutoMarket Pro is a Next.js application designed to serve as a central hub for all things automotive. It features a public-facing marketplace for browsing listings and a secure, role-based dashboard for users to manage their activities.

Tech Stack

This project is built on a modern, powerful tech stack:

Project Structure

The project follows a standard Next.js App Router structure.

/

├── public/ # Static assets

├── src/

│ ├── app/ # Application routes

│ │ ├── (public)/ # Routes accessible to everyone (e.g., home, login)

│ │ ├── dashboard/ # Protected routes for authenticated users

│ │ ├── globals.css # Global styles

│ │ └── layout.tsx # Root layout

│ ├── components/ # Reusable components

│ │ ├── auth/ # Authentication-related components

│ │ ├── dashboard/ # Dashboard-specific components

│ │ ├── public/ # Components for public pages

│ │ └── ui/ # ShadCN UI components

│ ├── hooks/ # Custom React hooks (e.g., useToast)

│ ├── lib/ # Libraries and utility functions

│ │ ├── firebase.ts # Firebase configuration and initialization

│ │ ├── types.ts # TypeScript type definitions

│ │ └── utils.ts # Utility functions (e.g., cn for classnames)

├── ... # Configuration files (tailwind.config.ts, next.config.ts, etc.)

└── README.md

Getting Started

To get the project up and running locally, follow these steps:

1. Clone the repository:

    git clone <repository-url>

2. Install dependencies:

    npm install

3. Set up Firebase:

  • Create a Firebase project in the Firebase Console.
  • Enable Authentication (Email/Password), Firestore, and Storage.
  • Get your Firebase project configuration and add it to src/lib/firebase.ts.

4. Run the development server:

    npm run dev

The application will be available at http://localhost:3000.

Key Features

Authentication

User authentication is handled by Firebase Authentication. Users can register and log in with their email and password.

  • Registration: New users provide their full name, nickname, email, password, and select a role (BUYER, SELLER, AGENCY, PROVIDER, ADMIN).
  • Data Storage: Upon successful registration, a new user document is created in the users collection in Firestore, storing their fullName, nickname, email, and role.

User Profiles

Authenticated users have a dedicated profile page where they can view and manage their information.

  • View Information: Displays the user's photo, name (or nickname), email, role, and unique user ID (UID).
  • Edit Information: Users can update their profile picture, full name, nickname, and role. They can also manage a list of phone numbers, specifying which is primary and which is linked to WhatsApp.
  • Display Name Preference: A switch allows users to decide whether to display their nickname publicly instead of their full name.

Dashboard

The dashboard is the central hub for authenticated users. The content and navigation are tailored based on the user's role.

  • Role-Based Access: Navigation links in the header are dynamically rendered based on the user's role, ensuring they only see relevant sections (e.g., "Vehículos" for sellers, "Manage Users" for agencies).
  • Core Pages: Includes a main dashboard overview, vehicles management, settings, and the user profile page.

Admin Management Pages

For administrators, a comprehensive set of management pages are available under the "Gestión" (Management) dropdown in the dashboard header.

  • Countries (/dashboard/countries): A comprehensive interface for managing country data, including add, edit, delete, bulk operations, import/export from CSV, and real-time filtering.
  • Locations (/dashboard/locations): Manage a hierarchical tree of geographical locations (e.g., Country > State > City). Supports any level of nesting, making it adaptable to any country's address format.
  • Banks (/dashboard/banks): Manage bank information, linking each bank to a country. Includes details like SWIFT/BIC, address, and contact information.
  • Accounts (/dashboard/accounts): Manage individual bank accounts, linking them to a specific bank and defining currency, balance, and account details.
  • Brands (/dashboard/brands): Manage vehicle brands, including their name, logo (uploaded to Firebase Storage), and country of origin.
  • Vehicle Type Categories (/dashboard/vehicle-type-categories): Manage categories for vehicle types (e.g., "Passenger Cars", "Commercial Vehicles"). Supports nested subcategories.
  • Vehicle Types (/dashboard/vehicle-types): Define different classes of vehicles (e.g., Sedan, SUV, Truck) and assign them to one or more categories. Each type has a name, description, and a representative image.
  • Models (/dashboard/models): Link brands with vehicle types to create specific models (e.g., Toyota Corolla, Ford F-150). Includes a start year and an optional end year for the model.
  • General Features (/dashboard/general-features): Create custom dynamic fields for vehicle listings. Define a feature's name, field type (text, select, checkbox, radio), an optional icon, and assign it to applicable vehicle types. Allows for hierarchical option groups for select and radio fields.
  • Additional Features (/dashboard/additional-features): Manage categories of optional features (e.g., Security, Comfort) and the specific features within each category (e.g., ABS Brakes, Sunroof).
  • Special Tags (/dashboard/special-tags): Create and manage descriptive tags (e.g., Urgent, New) that can be applied to vehicle listings. Tags can have custom colors and animated text effects.
  • Subscription Plans (/dashboard/subscription-plans): Define various subscription plans for listings, specifying price, duration, and included features. Plans can be assigned to specific vehicle types.
  • Gallery Settings (/dashboard/gallery-settings): Configure the required image views for different vehicle types (e.g., a car needs a front, back, and side view, while a motorcycle might only need a front view).

User Roles

The application uses a role-based access control system to tailor the user experience. The available roles are:

BUYERCan browse and purchase vehicles, parts, and services.
SELLERCan list vehicles and parts for sale.
AGENCYCan manage multiple sellers and their listings.
PROVIDERCan offer automotive services like repairs and detailing.
ADMINHas full access to all platform features and settings.

Firebase Integration

Firebase is at the core of the backend functionality.

  • firebase.ts: The src/lib/firebase.ts file initializes and exports the necessary Firebase services (Auth, Firestore, Storage). It's configured to be a singleton, ensuring a single Firebase instance across the app.
  • Firestore Data Model:

users collection

Each document is keyed by the user's UID from Firebase Authentication.

Type
uidstringUser's unique ID from Firebase Authentication.
fullNamestringThe full name of the user.
nicknamestring (optional)A public-facing nickname.
useNicknamePubliclybooleanIf true, the nickname is displayed publicly instead of the full name.
emailstringThe user's email address.
rolestringUser role (e.g., BUYER, SELLER, ADMIN).
photoURLstring (optional)URL for the user's profile picture stored in Firebase Storage.
phoneNumbersarray of objectsList of phone numbers: { number: string, isPrimary: boolean, isWhatsApp: boolean }.
disabledboolean (optional)If true, the user's access to the platform is blocked.

countries collection

Each document has an auto-generated ID.

Type
commonNamestringCommon name of the country (e.g., "Costa Rica").
officialNamestringOfficial name of the country (e.g., "República de Costa Rica").
regionstringThe geographical region (e.g., "América Central").
isoCodeNumericstringThe 3-digit numeric ISO code (e.g., "188").
isoCodeAlpha2stringThe 2-letter alpha ISO code (e.g., "CR").
currencyNamestringThe name of the primary currency (e.g., "Colón Costarricense").
currencySymbolstringThe symbol for the currency (e.g., "₡").
mainLanguagestringThe primary language spoken (e.g., "Español").
vatRatenumber (optional)The Value Added Tax (VAT) rate as a percentage (e.g., 13 for 13%).
disabledboolean (optional)If true, the country is considered inactive in the application.

locations collection

Each document has an auto-generated ID.

Type
namestringThe name of the location (e.g., "Costa Rica", "San José").
levelNamestringThe name of the geographical level (e.g., "País", "Provincia", "Cantón").
childLevelNamestring (optional)The name for the level of any direct children (e.g., a "País" document might have childLevelName: "Provincia").
parentIdstring (optional)The ID of the parent location, if this is a sub-location.
disabledboolean (optional)If true, the location is considered inactive in the application.

banks collection

Each document has an auto-generated ID.

Type
countryIdstringThe ID of the country this bank belongs to (from countries collection).
bankNamestringThe name of the bank.
swiftBicstringThe SWIFT/BIC code of the bank.
routingNumberstring (optional)The bank's routing number.
addressstringThe physical address of the bank.
phonestringThe bank's contact phone number.
emailstringThe bank's contact email.
websitestringThe bank's official website.
contactPersonstringA contact person at the bank.
contactEmailstringThe email of the contact person.
bankUserstringA user associated with the bank account.
disabledboolean (optional)If true, the bank is considered inactive in the application.

accounts collection

Each document has an auto-generated ID.

Type
bankIdstringThe ID of the bank this account belongs to (from banks collection).
accountHolderNamestringThe full name of the account holder.
accountTypestringThe type of bank account (e.g., "Checking", "Savings").
accountNumberstringThe unique number identifying the bank account.
ibanstringThe International Bank Account Number.
mobilePaymentstringAssociated mobile payment identifier (if any).
currencyNamestringThe name of the currency (e.g., "US Dollar").
currencySymbolstringThe symbol for the currency (e.g., "$").
balancenumberThe current balance of the account.
disabledboolean (optional)If true, the account is considered inactive.

brands collection

Each document has an auto-generated ID.

Type
namestringThe name of the brand (e.g., "Toyota").
logoUrlstringURL for the brand's logo stored in Firebase Storage.
countryIdstringThe ID of the country of origin (from countries collection).
disabledboolean (optional)If true, the brand is considered inactive in the application.

vehicleTypeCategories collection

Each document has an auto-generated ID.

Type
namestringThe name of the category (e.g., "Passenger Cars").
descriptionstringA short description of the category.
parentIdstring (optional)The ID of the parent category, if this is a subcategory.
disabledboolean (optional)If true, the category is considered inactive in the application.

vehicleTypes collection

Each document has an auto-generated ID.

Type
namestringThe name of the vehicle type (e.g., "Sedan").
descriptionstringA short description of the vehicle type.
imageUrlstringURL for the type's image stored in Firebase Storage.
categoryIdsarray of stringsAn array of IDs from the vehicleTypeCategories collection.
disabledboolean (optional)If true, the type is considered inactive in the application.

vehicleFeatures collection

Each document has an auto-generated ID.

Type
namestringThe name of the feature (e.g., "Color", "Transmission").
descriptionstring (optional)A short description of the feature.
groupstringUsed to group mutually exclusive radio buttons. E.g., multiple features can have the group "Transmission" (Manual, Auto), but a user can only select one.
fieldTypestringThe type of form field: TEXT, SELECT_SIMPLE, SELECT_GROUPED, CHECKBOX, RADIO.
iconstring (optional)The name of the Lucide icon to display next to the field label.
optionGroupsarray of objectsAn array of option groups for SELECT and RADIO fields: { label?: string, options: [{value: string}] }.
applicableVehicleTypeIdsarray of stringsAn array of IDs from the vehicleTypes collection to which this feature applies.
disabledboolean (optional)If true, the feature is considered inactive in the application.

models collection

Each document has an auto-generated ID.

Type
namestringThe name of the model (e.g., "Corolla", "F-150").
brandIdstringThe ID of the brand this model belongs to (from brands collection).
vehicleTypeIdstringThe ID of the vehicle type this model belongs to (from vehicleTypes collection).
startYearnumberThe year the model's manufacturing started.
endYearnumber (optional)The year the model's manufacturing ended.
hasEndYearboolean (optional)A flag to indicate if the model has a defined end year.
disabledboolean (optional)If true, the model is considered inactive in the application.

specialTags collection

Each document has an auto-generated ID.

Type
namestringThe name of the tag (e.g., "Urgente").
pricenumberThe cost associated with using this tag on a listing.
bgColorstringA Tailwind CSS class for the background color (e.g., "bg-red-500").
textColorstringA Tailwind CSS class for the text color (e.g., "text-white").
animatedMessagesarray of stringsAn array of up to 3 strings for animated text effects.
disabledboolean (optional)If true, the tag is considered inactive in the application.

subscriptionPlans collection

Each document has an auto-generated ID.

Type
namestringThe name of the subscription plan (e.g., "Basic", "Premium").
pricenumberThe base price of the plan in USD.
periodstringThe billing period: DIA, SEMANA, MES.
durationnumberThe duration of the period (e.g., 30 for a monthly plan).
isDefaultbooleanIf true, this plan is selected by default for new users or listings.
descriptionstringA detailed description of what the plan includes.
featuresarray of objectsA list of features, each with a name and a price.
applicableVehicleTypeIdsarray of stringsAn array of IDs from the vehicleTypes collection to which this plan applies.
disabledboolean (optional)If true, the plan is considered inactive in the application.

featureCategories collection

Each document has an auto-generated ID.

Type
namestringThe name of the category (e.g., "Seguridad").
descriptionstring (optional)A short description of the category.
disabledboolean (optional)If true, the category is considered inactive in the application.

additionalFeatures collection

Each document has an auto-generated ID.

Type
categoryIdstringThe ID of the category this feature belongs to (from featureCategories collection).
namestringThe name of the feature (e.g., "Frenos ABS").
descriptionstring (optional)A short description of the feature.
disabledboolean (optional)If true, the feature is considered inactive in the application.

galleryViews collection

Each document has an auto-generated ID.

Type
namestringThe name of the gallery view (e.g., "Vista Frontal").
descriptionstring (optional)A short description of what the view should capture.
ordernumberA number to control the display order of the views.
applicableVehicleTypeIdsarray of stringsAn array of IDs from the vehicleTypes collection to which this view applies.
disabledboolean (optional)If true, the view is considered inactive in the application.

settings collection

A single document site_config holds site-wide settings.

Type
siteNamestringThe public name of the website.
logoUrlstringThe URL of the site logo stored in Firebase Storage.
  • Firebase Storage:
  • Profile pictures are stored in the profile-pictures/ directory, with each file named after the user's UID to ensure uniqueness and easy retrieval.
  • Brand logos are stored in the brand-logos/ directory.
  • Vehicle type images are stored in the vehicle-type-images/ directory.
  • The site logo is stored at site/logo.