This exercise aims to design a set of APIs that manage transactions of a company. Managing transactions include: creating transactions, viewing transactions, recording payments and generating reports.
- This application will serve two ends:
- Web
- Mobile
- There are two types of users who can access the app:
- Admin
- Customer
- Admins will have the ability to:
- Create transactions
- View transactions
- Record payments
- Generate reports
- Users will be able to:
- View their transactions
- Authentication is required
-
POST /api/login
- Authenticate users (both Admins and Customers).
- Receive a token for subsequent requests.
-
POST /api/logout
- Log out and invalidate the token.
-
POST /api/transactions
- Create a new transaction.
- Requires authentication as an admin.
-
GET /api/transactions
- View all transactions.
- Requires authentication as an admin.
-
POST /api/payments
- Record payments for a specific transaction.
- Requires authentication as an admin.
-
GET /api/reports
- Generate reports.
- Requires authentication as an admin.
- GET /api/transactions
- View transactions for the authenticated user.
- Requires authentication as a user (both Admins and Customers).
- Admin logs in using
/api/login
. - Admin creates a transaction using
/api/transactions
. - Admin views transactions using
/api/transactions
. - Admin records payments for a transaction using
/api/payments
. - Admin generates reports using
/api/reports
. - Customer logs in using
/api/login
. - Customer views their transactions using
/api/transactions
.
- PHP 7.4 or higher
- Composer
- Node.js and npm
- MySQL or another database of your choice
-
Clone the repository:
git clone git@github.com:TariqAyman/task15-11-2023.git cd task15-11-2023
-
Install PHP Dependencies:
composer install
-
Copy Environment File:
cp .env.example .env
-
Generate Application Key:
php artisan key:generate
-
Configure Database:
Update the
.env
file with your database credentials:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database_name DB_USERNAME=your_database_user DB_PASSWORD=your_database_password
-
Run Migrations:
php artisan migrate
-
Install Frontend Dependencies:
npm install
-
Compile Assets:
npm run dev
-
Serve the Application:
php artisan serve
Your application should now be running at http://127.0.0.1:8000.