You are tasked with implementing a food ordering system using object-oriented programming principles. The system will manage users, meals, and bills, and include authentication functionality. The project is structured into several key components, and your objective is to develop and integrate these components according to the provided file structure.
-
services
Folderbill_service.py
: Contains theBillService
class responsible for managing bill-related operations. Implement methods for listing all bills, adding a new bill, removing an existing bill, and updating a bill.user_service.py
: Contains theUserService
class responsible for managing user-related operations. Implement methods for listing all users, adding a new user, removing an existing user, and updating user information.meal_service.py
: Contains theMealService
class responsible for managing meal-related operations. Implement methods for listing all meals, adding a new meal, removing an existing meal, and updating meal information.auth_service.py
: Contains theAuthService
class responsible for handling authentication operations such as signing in, signing out, and hashing passwords.
-
database
Folderbills.txt
: A text file containing bill data in CSV format. Each record has a UUID as its ID.users.txt
: A text file containing user data in CSV format. Each record has a UUID as its ID.meals.txt
: A text file containing meal data in CSV format. Each record has a UUID as its ID.
-
utilities
Folderbase_service.py
: Contains theBaseService
abstract class, which provides a common interface for all services. This class will define abstract methods that must be implemented by concrete service classes.utils.py
: Contains utility functions such asverify_password
,hash_password
, andgenerate_id
.data_utils.py
: Contains functions for data management, includingsave_data
andload_data
, which handle reading from and writing to the CSV files in thedatabase
folder.
-
models
Folderbill.py
: Contains theBill
class with attributes for bill information. This class will define the structure of a bill object.user.py
: Contains theUser
class with attributes for user information. This class will define the structure of a user object.meal.py
: Contains theMeal
class with attributes for meal information. This class will define the structure of a meal object.
-
main.py
: The entry point of the application. This file will handle user interactions, display choices based on user roles, and invoke methods from the service classes to perform operations.
food_ordering_system/
โ
โโโ main.py
โโโ models/
โ โโโ bill.py
โ โโโ user.py
โ โโโ meal.py
โโโ services/
โ โโโ bill_service.py
โ โโโ user_service.py
โ โโโ meal_service.py
โ โโโ auth_service.py
โโโ utilities/
โ โโโ base_service.py
โ โโโ utils.py
โ โโโ data_utils.py
โโโ database/
โโโ bills.json
โโโ users.json
โโโ meals.json
-
Implement Service Methods:
- List All: Implement a method to list all records (bills, users, meals) in each corresponding service class.
- Add: Implement a method to add a new record to each corresponding service class.
- Remove: Implement a method to remove an existing record from each corresponding service class.
- Update: Implement a method to update an existing record in each corresponding service class.
-
Implement Data Utilities:
load_data
: Implement the function to read data from text files in thedatabase
folder and return a list of dictionaries.save_data
: Implement the function to write data to text files in thedatabase
folder from a list of dictionaries.
-
Implement Authentication Methods:
signin
: Implement the method for signing in a user, including password validation and session management.signup
: Implement the method for signing up a new user, including password hashing and default role assignment.signout
: Implement the method for signing out a user and handling session invalidation.- Note: You can use the implementation from the previous task as a reference for these methods.
- Data Files: You can use different file formats for data storage such as CSV or JSON. Choose the format that best fits your implementation and is easiest to handle with the
load_data
andsave_data
functions. - Handling Data: Feel free to edit and adjust the code as necessary to meet the requirements. Ensure that your implementations for data reading and writing are robust and handle errors gracefully.
- UUIDs: Ensure that each record in your data files has a unique UUID as its ID. You can use the Python
uuid
module to generate these IDs.
- One week from today: All tasks should be completed by August 30, 2024 12:00 AM.
- Create a
testing
folder. - Implement unit tests for each service class to ensure that all methods work correctly.
- Include tests for edge cases and invalid inputs.
- Please submit your completed project by sending the entire project folder to the assistant. Ensure that all files are included and that the project runs without errors. You can submit your task through the designated submission platform or method as instructed.
Feel free to reach out if you have any questions or need further clarifications. Good luck!