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
- Tech Stack
- Project Structure
- Getting Started
- Key Features
- Authentication
- User Profiles
- Dashboard
- Admin Management Pages
- User Roles
- Firebase Integration
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:
- Framework: Next.js (with App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- UI Components: ShadCN UI
- Backend & Database: Firebase (Authentication, Firestore, Storage)
- Form Management: React Hook Form & Zod for validation
- Icons: Lucide React
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
userscollection in Firestore, storing theirfullName,nickname,email, androle.
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:
BUYER | Can browse and purchase vehicles, parts, and services. |
SELLER | Can list vehicles and parts for sale. |
AGENCY | Can manage multiple sellers and their listings. |
PROVIDER | Can offer automotive services like repairs and detailing. |
ADMIN | Has full access to all platform features and settings. |
Firebase Integration
Firebase is at the core of the backend functionality.
firebase.ts: Thesrc/lib/firebase.tsfile 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 | ||
|---|---|---|
uid | string | User's unique ID from Firebase Authentication. |
fullName | string | The full name of the user. |
nickname | string (optional) | A public-facing nickname. |
useNicknamePublicly | boolean | If true, the nickname is displayed publicly instead of the full name. |
email | string | The user's email address. |
role | string | User role (e.g., BUYER, SELLER, ADMIN). |
photoURL | string (optional) | URL for the user's profile picture stored in Firebase Storage. |
phoneNumbers | array of objects | List of phone numbers: { number: string, isPrimary: boolean, isWhatsApp: boolean }. |
disabled | boolean (optional) | If true, the user's access to the platform is blocked. |
countries collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
commonName | string | Common name of the country (e.g., "Costa Rica"). |
officialName | string | Official name of the country (e.g., "República de Costa Rica"). |
region | string | The geographical region (e.g., "América Central"). |
isoCodeNumeric | string | The 3-digit numeric ISO code (e.g., "188"). |
isoCodeAlpha2 | string | The 2-letter alpha ISO code (e.g., "CR"). |
currencyName | string | The name of the primary currency (e.g., "Colón Costarricense"). |
currencySymbol | string | The symbol for the currency (e.g., "₡"). |
mainLanguage | string | The primary language spoken (e.g., "Español"). |
vatRate | number (optional) | The Value Added Tax (VAT) rate as a percentage (e.g., 13 for 13%). |
disabled | boolean (optional) | If true, the country is considered inactive in the application. |
locations collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the location (e.g., "Costa Rica", "San José"). |
levelName | string | The name of the geographical level (e.g., "País", "Provincia", "Cantón"). |
childLevelName | string (optional) | The name for the level of any direct children (e.g., a "País" document might have childLevelName: "Provincia"). |
parentId | string (optional) | The ID of the parent location, if this is a sub-location. |
disabled | boolean (optional) | If true, the location is considered inactive in the application. |
banks collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
countryId | string | The ID of the country this bank belongs to (from countries collection). |
bankName | string | The name of the bank. |
swiftBic | string | The SWIFT/BIC code of the bank. |
routingNumber | string (optional) | The bank's routing number. |
address | string | The physical address of the bank. |
phone | string | The bank's contact phone number. |
email | string | The bank's contact email. |
website | string | The bank's official website. |
contactPerson | string | A contact person at the bank. |
contactEmail | string | The email of the contact person. |
bankUser | string | A user associated with the bank account. |
disabled | boolean (optional) | If true, the bank is considered inactive in the application. |
accounts collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
bankId | string | The ID of the bank this account belongs to (from banks collection). |
accountHolderName | string | The full name of the account holder. |
accountType | string | The type of bank account (e.g., "Checking", "Savings"). |
accountNumber | string | The unique number identifying the bank account. |
iban | string | The International Bank Account Number. |
mobilePayment | string | Associated mobile payment identifier (if any). |
currencyName | string | The name of the currency (e.g., "US Dollar"). |
currencySymbol | string | The symbol for the currency (e.g., "$"). |
balance | number | The current balance of the account. |
disabled | boolean (optional) | If true, the account is considered inactive. |
brands collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the brand (e.g., "Toyota"). |
logoUrl | string | URL for the brand's logo stored in Firebase Storage. |
countryId | string | The ID of the country of origin (from countries collection). |
disabled | boolean (optional) | If true, the brand is considered inactive in the application. |
vehicleTypeCategories collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the category (e.g., "Passenger Cars"). |
description | string | A short description of the category. |
parentId | string (optional) | The ID of the parent category, if this is a subcategory. |
disabled | boolean (optional) | If true, the category is considered inactive in the application. |
vehicleTypes collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the vehicle type (e.g., "Sedan"). |
description | string | A short description of the vehicle type. |
imageUrl | string | URL for the type's image stored in Firebase Storage. |
categoryIds | array of strings | An array of IDs from the vehicleTypeCategories collection. |
disabled | boolean (optional) | If true, the type is considered inactive in the application. |
vehicleFeatures collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the feature (e.g., "Color", "Transmission"). |
description | string (optional) | A short description of the feature. |
group | string | Used to group mutually exclusive radio buttons. E.g., multiple features can have the group "Transmission" (Manual, Auto), but a user can only select one. |
fieldType | string | The type of form field: TEXT, SELECT_SIMPLE, SELECT_GROUPED, CHECKBOX, RADIO. |
icon | string (optional) | The name of the Lucide icon to display next to the field label. |
optionGroups | array of objects | An array of option groups for SELECT and RADIO fields: { label?: string, options: [{value: string}] }. |
applicableVehicleTypeIds | array of strings | An array of IDs from the vehicleTypes collection to which this feature applies. |
disabled | boolean (optional) | If true, the feature is considered inactive in the application. |
models collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the model (e.g., "Corolla", "F-150"). |
brandId | string | The ID of the brand this model belongs to (from brands collection). |
vehicleTypeId | string | The ID of the vehicle type this model belongs to (from vehicleTypes collection). |
startYear | number | The year the model's manufacturing started. |
endYear | number (optional) | The year the model's manufacturing ended. |
hasEndYear | boolean (optional) | A flag to indicate if the model has a defined end year. |
disabled | boolean (optional) | If true, the model is considered inactive in the application. |
specialTags collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the tag (e.g., "Urgente"). |
price | number | The cost associated with using this tag on a listing. |
bgColor | string | A Tailwind CSS class for the background color (e.g., "bg-red-500"). |
textColor | string | A Tailwind CSS class for the text color (e.g., "text-white"). |
animatedMessages | array of strings | An array of up to 3 strings for animated text effects. |
disabled | boolean (optional) | If true, the tag is considered inactive in the application. |
subscriptionPlans collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the subscription plan (e.g., "Basic", "Premium"). |
price | number | The base price of the plan in USD. |
period | string | The billing period: DIA, SEMANA, MES. |
duration | number | The duration of the period (e.g., 30 for a monthly plan). |
isDefault | boolean | If true, this plan is selected by default for new users or listings. |
description | string | A detailed description of what the plan includes. |
features | array of objects | A list of features, each with a name and a price. |
applicableVehicleTypeIds | array of strings | An array of IDs from the vehicleTypes collection to which this plan applies. |
disabled | boolean (optional) | If true, the plan is considered inactive in the application. |
featureCategories collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the category (e.g., "Seguridad"). |
description | string (optional) | A short description of the category. |
disabled | boolean (optional) | If true, the category is considered inactive in the application. |
additionalFeatures collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
categoryId | string | The ID of the category this feature belongs to (from featureCategories collection). |
name | string | The name of the feature (e.g., "Frenos ABS"). |
description | string (optional) | A short description of the feature. |
disabled | boolean (optional) | If true, the feature is considered inactive in the application. |
galleryViews collection
Each document has an auto-generated ID.
| Type | ||
|---|---|---|
name | string | The name of the gallery view (e.g., "Vista Frontal"). |
description | string (optional) | A short description of what the view should capture. |
order | number | A number to control the display order of the views. |
applicableVehicleTypeIds | array of strings | An array of IDs from the vehicleTypes collection to which this view applies. |
disabled | boolean (optional) | If true, the view is considered inactive in the application. |
settings collection
A single document site_config holds site-wide settings.
| Type | ||
|---|---|---|
siteName | string | The public name of the website. |
logoUrl | string | The 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.