Project Overview:
Classified Ads System
Project Title:
Classified Ads System – A
Website for Posting and Browsing Classified Ads
Project Description:
The Classified
Ads System is a web-based platform developed using PHP and
MySQL that allows users to post and browse classified advertisements
across various categories, such as jobs, rentals, real estate,
automobiles, electronics, and items for sale. The system enables users to
register, create ads, search for relevant listings, and contact advertisers.
The website is designed
to be user-friendly, providing a seamless experience for both buyers
and sellers. It includes essential features such as user
authentication, ad posting, ad management, category-based searching, and an
admin panel for managing users and advertisements.
Core Features:
1. User Management
- User
Registration & Login (using PHP sessions)
- Profile
Management (update name, email, phone, and profile picture)
- Email
verification (optional)
2. Ad Posting &
Management
- Users
can create and post ads with a title, description, price, category,
location, and images
- Users
can edit or delete their ads
- Ads
expire after a certain period (e.g., 30 days)
3. Browsing &
Searching Ads
- Search
ads based on category, keyword, and location
- Filter
ads by price range, date posted, and category
- Pagination
for displaying multiple ads
4. Categories &
Subcategories
- Ads
are classified into different categories such as Jobs, Rentals, Vehicles,
Electronics, etc.
- Subcategories
for better classification (e.g., "Vehicles" → "Cars",
"Bikes")
5. Contact Advertiser
- Users
can contact ad owners via email or a built-in messaging system
- Display
seller’s contact details (if enabled)
6. Admin Panel
- Manage
users (activate/deactivate accounts)
- Manage
ads (approve, reject, or delete ads)
- Manage
categories and subcategories
- View
reports and statistics on ads and users
7. Additional Features
(Optional Enhancements)
- Featured
Ads: Allow paid promotions for highlighted ads
- Ad
Expiry & Renewal: Ads auto-expire after a
set period and users can renew them
- Rating
& Reviews: Users can rate sellers and
leave reviews
- Payment
Gateway Integration: For premium listings or
promoted ads
- Google
Maps Integration: Display ad locations on a
map
Technology Stack:
Frontend:
- HTML,
CSS, Bootstrap – For designing a responsive UI
- JavaScript,
jQuery – For dynamic interactions
Backend:
- PHP
(Core PHP or Laravel) – For server-side logic
- MySQL
– Database for storing user accounts, ads, and messages
Hosting & Deployment:
- Apache
Server (XAMPP/LAMP) – For local development
- Web
hosting with PHP & MySQL support (e.g., cPanel, AWS, DigitalOcean)
User Roles and
Permissions:
1. Regular Users (Buyers
& Sellers)
- Can
register and log in
- Can
post ads under selected categories
- Can
edit and delete their own ads
- Can
browse and search ads
- Can
contact sellers
2. Admin
- Can
manage user accounts (activate, deactivate, delete)
- Can
manage ads (approve, reject, delete)
- Can
create and manage categories
Project Workflow:
1.
User Registration/Login –
New users sign up, verify email, and log in.
2.
Post an Ad –
Users post ads with images, descriptions, and prices.
3.
Browse & Search –
Visitors browse ads by category or use search filters.
4.
Contact Seller –
Buyers can send messages or view the seller’s contact details.
5.
Admin Moderation –
Admin reviews and approves ads before publishing.
6.
Ad Expiry & Renewal –
Ads automatically expire and can be renewed.
The Classified
Ads System is a robust PHP and MySQL-based web application
designed for users to post, browse, and manage classified
advertisements. It provides a secure and user-friendly experience
for both buyers and sellers. Future enhancements like payment gateway
integration, Google Maps support, and ad promotions can further
improve functionality and user engagement.
Scope and Features of the
Classified Ads System Project
Project Scope
The Classified
Ads System is a web-based application that enables
users to post, browse, and manage classified advertisements. The system is
designed for individuals and businesses to advertise products, services, jobs,
real estate, and other categories.
Scope of the Project:
1.
User Registration &
Authentication:
·
Users can register, log in, and
manage their accounts.
·
Secure authentication with password
encryption (hashing with bcrypt).
2.
Ad Posting & Management:
·
Users can post, edit, and delete their
classified ads.
·
Ads will be categorized under specific
sections like Jobs, Rentals, Vehicles, Electronics, etc.
·
Admin can approve, reject, or
delete ads.
3.
Browsing & Searching Ads:
·
Users can search for ads using filters like category,
price range, location, and keywords.
·
Pagination for efficient ad
browsing.
4.
Ad Expiry & Renewals:
·
Ads will expire automatically after
a defined period (e.g., 30 days).
·
Users can renew expired ads.
5.
Messaging & Contacting
Advertisers:
·
Buyers can contact sellers via
an internal messaging system or email.
·
Seller contact details may be visible
based on privacy settings.
6.
Admin Panel:
·
The admin has full control over
users and ads.
·
Can approve, reject, or delete ads.
·
Can manage categories,
subcategories, and users.
7.
Payment Gateway (Optional - Future
Scope):
·
Users can pay to promote ads (featured
listings).
·
Integration with PayPal, Stripe,
or Razorpay for paid ads.
8.
Google Maps Integration (Optional -
Future Scope):
·
Users can see the location of
items on Google Maps.
9.
Ratings & Reviews (Optional -
Future Scope):
·
Buyers can rate and review sellers based
on transactions.
10.
Mobile Responsiveness:
- The
system will be mobile-friendly (Bootstrap-based UI).
Modules of the Classified
Ads System with Functionality and Database Tables
The Classified
Ads System is divided into different modules, each responsible for a
specific functionality. Below is a list of modules, their features, and the
corresponding database tables.
1. User Management Module
Functionality
- User Registration,
Login, Logout
- Profile
Management (Edit Name, Email, Phone, Profile
Picture)
- Password
Reset (Forgot Password)
- Email
Verification (Optional)
- User
Role Management (Admin, Regular User)
Database Table: users
Column Name |
Data Type |
Description |
id |
INT (PK,
AUTO_INCREMENT) |
Unique User ID |
name |
VARCHAR(255) |
Full Name |
email |
VARCHAR(255) |
Email Address (Unique) |
password |
VARCHAR(255) |
Hashed Password |
phone |
VARCHAR(15) |
Contact Number |
profile_pic |
VARCHAR(255) |
Profile Picture URL |
role |
ENUM('admin', 'user') |
User Role |
status |
ENUM('active',
'inactive') |
Account Status |
created_at |
TIMESTAMP |
Account Created Time |
updated_at |
TIMESTAMP |
Last Updated Time |
2. Classified Ads Module
Functionality
- Post
New Ads with Title, Description,
Images, Price, and Category
- Edit
& Delete Ads
- Set
Ad Expiry Date (Auto removal after expiration)
- Ad
Renewal Feature
Database Table: ads
Column Name |
Data Type |
Description |
id |
INT (PK,
AUTO_INCREMENT) |
Unique Ad ID |
user_id |
INT (FK) |
Ad Owner
(References users.id) |
category_id |
INT (FK) |
Ad Category
(References categories.id) |
title |
VARCHAR(255) |
Ad Title |
description |
TEXT |
Ad Description |
price |
DECIMAL(10,2) |
Price of the
Item/Service |
location |
VARCHAR(255) |
Ad Location |
images |
TEXT |
Image URLs
(Comma-separated) |
status |
ENUM('pending',
'approved', 'rejected', 'expired') |
Ad Status |
expiry_date |
DATE |
Auto-Remove Date |
created_at |
TIMESTAMP |
Ad Creation Date |
updated_at |
TIMESTAMP |
Last Updated Date |
3. Categories and
Subcategories Module
Functionality
- Manage Ad
Categories (Admin can create, edit, delete categories)
- Assign
ads to relevant categories and subcategories
Database Table: categories
Column Name |
Data Type |
Description |
id |
INT (PK,
AUTO_INCREMENT) |
Unique Category ID |
name |
VARCHAR(255) |
Category Name |
parent_id |
INT (FK, NULLABLE) |
Parent Category ID
(NULL if top-level) |
created_at |
TIMESTAMP |
Created Date |
updated_at |
TIMESTAMP |
Last Updated Date |
4. Ad Search and Filters
Module
Functionality
- Keyword-based
Search for ads
- Filters
by Price Range, Category, and Location
- Sort
Ads (Newest, Lowest Price, etc.)
5. Ad Contact &
Messaging Module
Functionality
- Users
can send messages to sellers via contact form
- Messages
are stored in the system for better communication
Database Table: messages
Column Name |
Data Type |
Description |
id |
INT (PK,
AUTO_INCREMENT) |
Message ID |
sender_id |
INT (FK) |
Sender User ID
(References users.id) |
receiver_id |
INT (FK) |
Receiver User ID
(References users.id) |
ad_id |
INT (FK) |
Related Ad ID
(References ads.id) |
message |
TEXT |
Message Content |
status |
ENUM('unread', 'read') |
Message Status |
created_at |
TIMESTAMP |
Sent Date |
6. Ad Review &
Ratings Module (Optional)
Functionality
- Buyers
can rate and review sellers
- Reviews
will be visible on the seller’s profile
Database Table: reviews
Column Name |
Data Type |
Description |
id |
INT (PK,
AUTO_INCREMENT) |
Review ID |
ad_id |
INT (FK) |
Ad Related to the
Review (References ads.id) |
user_id |
INT (FK) |
Reviewer
(References users.id) |
rating |
INT (1-5) |
Rating Given |
comment |
TEXT |
User Comment |
created_at |
TIMESTAMP |
Review Date |
7. Admin Panel Module
Functionality
- Manage
Users (Activate/Deactivate/Delete Users)
- Manage
Ads (Approve, Reject, or Delete Ads)
- Manage
Categories & Subcategories
- View
Reports on Ad Performance
Database Table: admin_logs (For
tracking admin actions)
Column Name |
Data Type |
Description |
id |
INT (PK,
AUTO_INCREMENT) |
Log ID |
admin_id |
INT (FK) |
Admin User
(References users.id) |
action |
VARCHAR(255) |
Action Taken (e.g.,
"Deleted Ad ID 12") |
created_at |
TIMESTAMP |
Action Time |
8. Payment & Featured
Ads Module (Future Enhancement)
Functionality
- Users
can pay to promote their ads as "Featured"
- Payment
gateway integration (PayPal, Stripe, Razorpay)
Database Table: payments
Column Name |
Data Type |
Description |
id |
INT (PK,
AUTO_INCREMENT) |
Payment ID |
user_id |
INT (FK) |
User Who Paid
(References users.id) |
ad_id |
INT (FK) |
Ad ID
(References ads.id) |
amount |
DECIMAL(10,2) |
Paid Amount |
status |
ENUM('pending',
'completed', 'failed') |
Payment Status |
transaction_id |
VARCHAR(255) |
Payment Gateway
Transaction ID |
created_at |
TIMESTAMP |
Payment Date |
Database Design for
Classified Ads System (PHP & MySQL)
The Classified
Ads System requires a well-structured relational database to
efficiently manage users, ads, categories, messages, payments, and admin
operations. Below is a complete breakdown of the database structure.
1. Database Name
classified_ads_db
2. Tables and Schema
1. Users Table (users)
Stores user information
such as login credentials and profile details.
CREATE TABLE users ( id
INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255)
UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, phone VARCHAR(15), profile_pic
VARCHAR(255), role ENUM('admin', 'user') DEFAULT 'user', status ENUM('active',
'inactive') DEFAULT 'active', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP );
2. Categories Table (categories)
Stores ad categories and
subcategories.
CREATE TABLE categories (
id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, parent_id INT
DEFAULT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at
TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, FOREIGN KEY
(parent_id) REFERENCES categories(id) ON DELETE CASCADE );
3. Ads Table (ads)
Stores details of the ads
posted by users.
CREATE TABLE ads ( id INT
AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, category_id INT NOT NULL,
title VARCHAR(255) NOT NULL, description TEXT NOT NULL, price DECIMAL(10,2) NOT
NULL, location VARCHAR(255), images TEXT, status ENUM('pending', 'approved',
'rejected', 'expired') DEFAULT 'pending', expiry_date DATE, created_at
TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT
CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES
users(id) ON DELETE CASCADE, FOREIGN KEY (category_id) REFERENCES
categories(id) ON DELETE CASCADE );
4. Messages Table (messages)
Stores messages between
users regarding an ad.
CREATE TABLE messages (
id INT AUTO_INCREMENT PRIMARY KEY, sender_id INT NOT NULL, receiver_id INT NOT
NULL, ad_id INT NOT NULL, message TEXT NOT NULL, status ENUM('unread', 'read')
DEFAULT 'unread', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY
(sender_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (receiver_id)
REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (ad_id) REFERENCES ads(id)
ON DELETE CASCADE );
5. Reviews Table (reviews)
Stores user ratings and
feedback for ads.
CREATE TABLE reviews ( id
INT AUTO_INCREMENT PRIMARY KEY, ad_id INT NOT NULL, user_id INT NOT NULL,
rating INT CHECK (rating BETWEEN 1 AND 5), comment TEXT, created_at TIMESTAMP
DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (ad_id) REFERENCES ads(id) ON DELETE
CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE );
6. Admin Logs Table (admin_logs)
Tracks administrative
actions such as approving/rejecting ads.
CREATE TABLE admin_logs (
id INT AUTO_INCREMENT PRIMARY KEY, admin_id INT NOT NULL, action VARCHAR(255)
NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY
(admin_id) REFERENCES users(id) ON DELETE CASCADE );
7. Payments Table (payments)
Stores payment details
for featured ads.
CREATE TABLE payments (
id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, ad_id INT NOT NULL,
amount DECIMAL(10,2) NOT NULL, status ENUM('pending', 'completed', 'failed')
DEFAULT 'pending', transaction_id VARCHAR(255) UNIQUE NOT NULL, created_at
TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id)
ON DELETE CASCADE, FOREIGN KEY (ad_id) REFERENCES ads(id) ON DELETE CASCADE );
8. Favorites Table (favorites)
Allows users to save ads
as favorites.
CREATE TABLE favorites (
id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, ad_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id)
REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (ad_id) REFERENCES ads(id)
ON DELETE CASCADE );
9. Reports Table (reports)
Users can report ads for
inappropriate content.
CREATE TABLE reports ( id
INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, ad_id INT NOT NULL,
reason TEXT NOT NULL, status ENUM('pending', 'reviewed') DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id)
REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (ad_id) REFERENCES ads(id)
ON DELETE CASCADE );
3. Relationships Between
Tables
- Users
(users) → Can post ads (ads), send
messages (messages), write reviews (reviews),
and make payments (payments).
- Ads
(ads) → Belongs to a category
(categories) and a user (users).
- Messages
(messages) → Sent between two
users (users) regarding an ad (ads).
- Reviews
(reviews) → A user can rate
and review an ad (ads).
- Admin
Logs (admin_logs) → Stores
admin actions on ads (ads) and users (users).
- Payments
(payments) → Tracks ad
promotion payments.
- Favorites
(favorites) → Users can save
ads they like.
- Reports
(reports) → Users can report
an ad for inappropriate content.
4. Database Queries
1. Insert a New User
INSERT INTO users (name,
email, password, phone) VALUES ('John Doe', 'john@example.com',
'hashedpassword', '1234567890');
2. Insert a New Ad
INSERT INTO ads (user_id,
category_id, title, description, price, location, images, expiry_date) VALUES
(1, 3, 'Laptop for Sale', 'Selling a brand new laptop', 500.00, 'New York',
'image1.jpg,image2.jpg', '2025-12-31');
3. Get All Ads in a
Specific Category
SELECT * FROM ads WHERE
category_id = 3 AND status = 'approved';
4. Get All Messages for a
User
SELECT * FROM messages
WHERE receiver_id = 1 ORDER BY created_at DESC;
5. Get Top 5 Ads with
Highest Reviews
SELECT ads.id, ads.title,
AVG(reviews.rating) AS avg_rating FROM ads JOIN reviews ON ads.id =
reviews.ad_id GROUP BY ads.id ORDER BY avg_rating DESC LIMIT 5;
Project Structure for
Classified Ads System (PHP & MySQL) - MVC Architecture
A Classified Ads
System using PHP & MySQL should be structured following the Model-View-Controller
(MVC) architecture to ensure scalability, maintainability, and
modularity.
📁 Project Directory
Structure
classified-ads-system/
│── app/
│ ├── controllers/
│ │ ├── HomeController.php
│ │ ├── UserController.php
│ │ ├── AdController.php
│ │ ├── MessageController.php
│ │ ├── ReviewController.php
│ │ ├── AdminController.php
│ │ ├── PaymentController.php
│ │ ├── ReportController.php
│ │
└── CategoryController.php
│ │
│ ├── models/
│ │ ├── User.php
│ │ ├── Ad.php
│ │ ├── Message.php
│ │ ├── Review.php
│ │ ├── Payment.php
│ │ ├── Report.php
│ │ ├── Category.php
│ │
└── Database.php
│ │
│ ├── views/
│ │ ├── layouts/
│ │
│ ├── header.php
│ │
│ ├── footer.php
│ │
│ ├── sidebar.php
│ │
│ ├── navbar.php
│ │ ├── home.php
│ │ ├── ads/
│ │
│ ├── create.php
│ │
│ ├── edit.php
│ │
│ ├── list.php
│ │
│ ├── details.php
│ │ ├── users/
│ │
│ ├── login.php
│ │
│ ├── register.php
│ │
│ ├── profile.php
│ │ ├── admin/
│ │
│ ├── dashboard.php
│ │
│ ├── manage_users.php
│ │
│ ├── manage_ads.php
│ │ ├── payments/
│ │
│ ├── checkout.php
│ │
│ ├── history.php
│ │ ├── reports/
│ │
│ ├── report_list.php
│ │
│ ├── report_details.php
│ │ ├── messages/
│ │
│ ├── inbox.php
│ │
│ ├── chat.php
│ │
│── public/
│ ├── assets/
│ │ ├── css/
│ │
│ ├── style.css
│ │
│ ├── responsive.css
│ │ ├── js/
│ │
│ ├── script.js
│ │ ├── images/
│ ├── index.php
│ ├── .htaccess
│
│── config/
│ ├── config.php
│ ├── routes.php
│
│── core/
│ ├── Controller.php
│ ├── Model.php
│ ├── View.php
│ ├── Router.php
│
│── storage/
│ ├── uploads/
│
│── logs/
│
│── vendor/ (For Composer dependencies)
│
│── .env
│── composer.json
│── README.md
📌 Explanation of Folders
and Files
1️⃣ app/ (Main
application logic)
- controllers/ →
Handles HTTP requests and interacts with models.
- models/ →
Represents database tables and provides methods to manipulate data.
- views/ →
Contains HTML and PHP templates for UI.
2️⃣
Controllers (app/controllers/)
Controllers handle the
request logic and call the respective model and views.
Controller |
Functionality |
HomeController.php |
Handles homepage,
featured ads, search, and latest ads. |
UserController.php |
Manages user
registration, login, profile, and authentication. |
AdController.php |
Handles posting,
editing, deleting, and displaying ads. |
MessageController.php |
Manages user
conversations and inbox. |
ReviewController.php |
Handles ad reviews and
ratings. |
AdminController.php |
Manages users, ads, and
reports for admin. |
PaymentController.php |
Handles payments and
checkout process. |
ReportController.php |
Allows users to report
ads and admin to review. |
CategoryController.php |
Manages ad categories
and subcategories. |
3️⃣
Models (app/models/)
Models represent database
tables and provide methods for CRUD operations.
Model |
Functionality |
User.php |
Handles user
registration, authentication, profile updates. |
Ad.php |
Manages ads (create,
update, delete, fetch ads). |
Message.php |
Handles message
sending, receiving, and inbox. |
Review.php |
Stores user ratings and
feedback for ads. |
Payment.php |
Handles transactions
and payments for featured ads. |
Report.php |
Manages ad reports and
review process. |
Category.php |
Stores and manages ad
categories and subcategories. |
Database.php |
Manages database
connection using PDO. |
4️⃣
Views (app/views/)
Views contain HTML/PHP
templates.
- Layouts
(layouts/) → Shared components
like header.php, footer.php, sidebar.php, navbar.php.
- Ads
(ads/) → Templates for listing,
creating, editing ads.
- Users
(users/) → Login, registration,
profile pages.
- Admin
(admin/) → Dashboard for managing
users, ads.
- Messages
(messages/) → Inbox and chat
interface.
5️⃣
Public Folder (public/)
- CSS
(css/) → Stylesheets for frontend.
- JS
(js/) → JavaScript files for dynamic
functionality.
- Images
(images/) → Stores uploaded images.
- index.php →
Entry point for the project.
- .htaccess →
URL rewriting for clean URLs.
6️⃣
Configuration (config/)
- config.php →
Stores database credentials, environment variables.
- routes.php →
Defines URL routes and maps them to controllers.
7️⃣
Core System (core/)
- Controller.php →
Base controller class with common methods.
- Model.php →
Base model class for database operations.
- View.php →
Handles rendering of views.
- Router.php →
Manages URL routing.
8️⃣
Storage (storage/)
- Uploads →
Stores user-uploaded files (images for ads).
9️⃣
Logs (logs/)
- Stores
error logs and system logs.
🔹 Workflow Example
(Posting an Ad)
1.
User submits ad form → AdController.php (store() function)
handles request.
2.
Validate form data and call Ad.php model to
insert data into ads table.
3.
Redirect user to ad listing and
show a success message.
This MVC-based
project structure ensures:
Project Structure for
Classified Ads System (PHP & MySQL) - Core PHP (Without MVC)
In this Core PHP project
structure, we will not use the MVC pattern. Instead, we will follow a functional
structure, where PHP scripts handle everything (business logic, database
interaction, and UI rendering) within the same files or separate them based on
functionality.
📁 Project Directory
Structure
classified-ads-system/
│── assets/
│ ├── css/
│ │ ├── style.css
│ │ ├── responsive.css
│ ├── js/
│ │ ├── script.js
│ ├── images/
│
│── config/
│ ├── config.php
│ ├── db_connect.php
│
│── includes/
│ ├── header.php
│ ├── footer.php
│ ├── navbar.php
│ ├── sidebar.php
│
│── admin/
│ ├── dashboard.php
│ ├── manage_users.php
│ ├── manage_ads.php
│ ├── reports.php
│
│── ads/
│ ├── create_ad.php
│ ├── edit_ad.php
│ ├── delete_ad.php
│ ├── list_ads.php
│ ├── ad_details.php
│
│── users/
│ ├── login.php
│ ├── register.php
│ ├── profile.php
│ ├── logout.php
│
│── messages/
│ ├── inbox.php
│ ├── send_message.php
│ ├── chat.php
│
│── payments/
│ ├── checkout.php
│ ├── payment_history.php
│
│── reports/
│ ├── report_ad.php
│ ├── report_list.php
│ ├── report_details.php
│
│── public/
│ ├── index.php
│
│── uploads/
│
│── .htaccess
│── README.md
📌 Explanation of Folders
and Files
1️⃣ assets/ (Static
Files)
- CSS
(css/) → Stylesheets for frontend
(style.css, responsive.css).
- JS
(js/) → JavaScript files
(script.js for interactions).
- Images
(images/) → Stores static assets like
logos, icons.
2️⃣ config/ (Configuration
& Database)
- config.php →
Stores environment variables (site settings, paths).
- db_connect.php →
Handles database connection using mysqli or PDO.
3️⃣ includes/ (Reusable
Components)
- header.php →
Contains meta tags, stylesheets, and site title.
- footer.php →
Common footer for all pages.
- navbar.php →
Navigation bar for users.
- sidebar.php →
Admin/user dashboard menu.
4️⃣ admin/ (Admin
Panel)
- dashboard.php →
Overview of site activity.
- manage_users.php →
Add, edit, delete users.
- manage_ads.php →
View, approve, delete ads.
- reports.php →
View reported ads and take action.
5️⃣ ads/ (Ad
Management)
- create_ad.php →
Form to post a new classified ad.
- edit_ad.php →
Edit an existing ad.
- delete_ad.php →
Delete an ad.
- list_ads.php →
View all ads in a category.
- ad_details.php →
Show details of a specific ad.
6️⃣ users/ (User
Management)
- login.php →
User login form.
- register.php →
User registration form.
- profile.php →
User profile page with options to edit details.
- logout.php →
Ends user session.
7️⃣ messages/ (Messaging
System)
- inbox.php →
User inbox for received messages.
- send_message.php →
Form to send a message.
- chat.php →
Chat system for user-to-user communication.
8️⃣ payments/ (Payment
System)
- checkout.php →
Payment page for featured ads.
- payment_history.php →
View past transactions.
9️⃣ reports/ (Ad
Reports & Reviews)
- report_ad.php →
Users can report inappropriate ads.
- report_list.php →
Admin view for reported ads.
- report_details.php →
Detailed report information.
🔹 Workflow Example
(Posting an Ad)
1.
User fills out ad form (ads/create_ad.php).
2.
Form data sent to db_connect.php →
Ad is stored in ads table.
3.
User is redirected to list_ads.php →
Ads are retrieved and displayed.
🔹 Technologies Used
🔥 Conclusion
This Core
PHP-based project structure ensures:
Project Structure for
Classified Ads System Using Python & Flask
Flask is a lightweight
web framework that follows the MVC-like pattern. Below is the structured
directory for building a Classified Ads System using Flask
and MySQL.
📁 Project Directory
Structure
classified_ads_system/
│── static/ # Static assets (CSS, JS,
Images)
│ ├── css/
│ │ ├── style.css
│ │ ├── responsive.css
│ ├── js/
│ │ ├── script.js
│ ├── images/
│
│── templates/ # HTML templates (Jinja2)
│ ├── base.html
│ ├── index.html
│ ├── login.html
│ ├── register.html
│ ├── profile.html
│ ├── create_ad.html
│ ├── view_ad.html
│ ├── edit_ad.html
│ ├── messages.html
│ ├── checkout.html
│
│── uploads/ # Stores uploaded images (ad images)
│
│── config.py # Configuration settings (DB,
secrets)
│
│── app.py # Main Flask application
│
│── models.py # Database models (SQLAlchemy)
│
│── forms.py # WTForms for form validation
│
│── routes/ # Contains route definitions
(Controllers)
│ ├── __init__.py
│ ├── auth_routes.py # User authentication routes
│ ├── ad_routes.py # Ad posting & management routes
│ ├── user_routes.py # User profile & settings routes
│ ├── message_routes.py # Messaging system routes
│ ├── payment_routes.py # Payment & transaction routes
│
│── services/ # Business logic (Helper
functions)
│ ├── db_service.py # Database interactions
│ ├── email_service.py # Sending emails
│ ├── payment_service.py # Handling payments
│
│── migrations/ # Database migration files
(Flask-Migrate)
│
│── requirements.txt # Python dependencies (Flask,
SQLAlchemy)
│
│── .env # Environment variables
(Secret Keys, DB Config)
│
│── .gitignore # Ignore unnecessary files
│
│── README.md # Project Documentation
📌 Explanation of Folders
and Files
1️⃣
static/ (Frontend Assets)
- CSS
(css/) → Stylesheets (style.css,
responsive.css)
- JavaScript
(js/) → Scripts for UI interactions
- Images
(images/) → Stores static assets like logos,
icons
2️⃣
templates/ (HTML Templates using Jinja2)
- base.html
→ Main layout template (Navbar, Footer)
- index.html
→ Homepage displaying classified ads
- login.html
→ User login form
- register.html
→ User signup form
- profile.html
→ User profile page
- create_ad.html
→ Ad posting form
- view_ad.html
→ Display ad details
- edit_ad.html
→ Edit an existing ad
- messages.html
→ User messaging system
- checkout.html
→ Payment & featured ads page
3️⃣
uploads/ (User-Uploaded Files)
- Stores
uploaded images related to classified ads
4️⃣
config.py (Configuration Settings)
- Stores
database connection, secret keys, and other settings.
import os
class Config:
SECRET_KEY = os.getenv('SECRET_KEY',
'your_secret_key')
SQLALCHEMY_DATABASE_URI =
'mysql+pymysql://root:password@localhost/classified_ads'
SQLALCHEMY_TRACK_MODIFICATIONS = False
5️⃣
app.py (Main Flask Application)
- Initializes
the Flask app and registers routes.
from flask import Flask
from config import Config
from routes import
auth_routes, ad_routes, user_routes
app = Flask(__name__)
app.config.from_object(Config)
# Register Blueprints
(Modular Routes)
app.register_blueprint(auth_routes.auth_bp)
app.register_blueprint(ad_routes.ad_bp)
app.register_blueprint(user_routes.user_bp)
if __name__ ==
"__main__":
app.run(debug=True)
6️⃣
models.py (Database Models - SQLAlchemy)
- Defines
the database schema for users, ads, messages, and payments.
from flask_sqlalchemy
import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
id = db.Column(db.Integer,
primary_key=True)
username = db.Column(db.String(50),
unique=True, nullable=False)
email = db.Column(db.String(120),
unique=True, nullable=False)
password = db.Column(db.String(255),
nullable=False)
class Ad(db.Model):
id = db.Column(db.Integer,
primary_key=True)
title = db.Column(db.String(200),
nullable=False)
description = db.Column(db.Text,
nullable=False)
price = db.Column(db.Float, nullable=False)
image = db.Column(db.String(200),
nullable=True)
user_id = db.Column(db.Integer,
db.ForeignKey('user.id'))
7️⃣
forms.py (Flask-WTF Forms)
- Handles
form validation.
from flask_wtf import
FlaskForm
from wtforms import
StringField, PasswordField, SubmitField
from wtforms.validators
import DataRequired, Email
class
LoginForm(FlaskForm):
email = StringField('Email',
validators=[DataRequired(), Email()])
password = PasswordField('Password',
validators=[DataRequired()])
submit = SubmitField('Login')