Skip to content

mohammadsofan/Smart-Parking-Lot-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Smart Parking System

A simple yet extensible C# console application simulating a smart parking lot management system. It supports vehicle check-in/check-out, data persistence, filtering, and event-driven notifications.


Features

  • Check-In / Check-Out vehicles
  • Persistent storage using JSON files (checked-in and checked-out vehicles stored separately)
  • Filter parked vehicles by type (Car, Truck, Motorcycle)
  • Polymorphic deserialization using System.Text.Json
  • Strong validation using {CustomeValidation}
  • Custom exception handling via ParkingLotException
  • Event triggered on full parking lot
  • Well-structured DTOs and services
  • Easily testable and extensible architecture
  • Logging with serilog

Menu Options

===================== Menu =======================
Please Choose one of the following options:
1. Check-In Vehicle
2. Check-Out Vehicle
3. View Parked Vehicles
4. View Checked Out Vehicles
5. Filter by Vehicle Type
6. Exit
==================================================

Project Structure

SmartParkingSystem/
│
├── Models/
│   ├── Vehicle.cs             # Base abstract class
│   ├── Car.cs, Truck.cs, Motorcycle.cs
│
├── Enums/
│   ├── ConsoleOperationEnum.cs          
│   ├── VehicleTypeEnum.cs
│
├── Dtos/
│   ├── GetVehiclesResultDto.cs          
│   ├── ParkingLotResultDto.cs
│ 
├── Interfaces/
|   ├── IFileService  # Interface for file storage
│   ├── IBillable.cs           # Interface for fee calculation
│   ├── IVehicleStorageService.cs
│   ├── INotifiable.cs         # For event subscribers
│
├── Services/
│   ├── ParkingLotManager.cs   # Main business logic
│   ├── FullLotNofificationService.cs # Notification service for triggered events
│   ├── FileService.cs  # file storage service
│   ├── VehicleFileStorageService.cs
│
├── Events/
│   └── FullLotEventArgs.cs
│
├── Validators/
│   └── VehicleValidator.cs    # CustomValidation implementation
│
├── Exceptions/
│   └── ParkingLotException.cs
│
├── Utils/
│   ├── ConsoleInputHelper.cs
│   ├── ConsoleOutputHelper.cs
│   ├── SmartParkingAppMenu.css
│
└── Program.cs                 # Entry point

Technologies

  • C# .NET
  • System.Text.Json
  • Event Handling
  • LINQ and Expressions
  • Console UI
  • Serilog
  • ...

Validation

Vehicle validation is enforced before check-in:

  • License plate must be at least 5 characters.
  • Duplicates are rejected based on license plate, with a raised ParkingLotException.
  • Capacity limit enforced, with a raised ParkingLotException if full.

Event Handling

When the last available slot is filled, an event (FullLotEvent) is triggered. Subscribers can be notified with a custom message (e.g., " The parking lot is now full.").


Logging

The application uses Serilog for structured and multi-sink logging. All system events, operations, and errors are logged to:

  • log.txt → plain text log file

  • log.json → structured JSON log file

  • Seq → centralized log management and live dashboard for querying and visualization

Example log entries include:

  • Vehicle check-in and check-out operations

  • Validation failures and custom exceptions

  • Parking lot full events and notifications

Storage

All vehicle data is persisted in separate JSON files:

  • checkedin.json → active vehicles in the lot.
  • checkedout.json → vehicles that already exited.

Files are updated on every operation.


Contact

Project by: Mohammad Sofan


📄 License

This project is for educational purposes only. Use freely and modify as needed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages