├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Muhammad Yahaya 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Backend-Engineering-Projects 2 | This repository provides a curated collection of tasks, challenges, and projects designed to help upcoming backend engineers hone their skills and gain practical experience in backend development. Each task includes detailed instructions, database structures, model designs, and API endpoints to implement. 3 | 4 | ## Tasks 5 | - [Task 1: REST API for a Library Management System](#task-1-rest-api-for-a-library-management-system) 6 | - [Task 2: News Aggregator API](#task-2-news-aggregator-api) 7 | - [Task 3: Automated Email Notification System with Cron Jobs](#task-3-automated-email-notification-system-with-cron-jobs) 8 | - [Task 4: Travel Agency API](#task-4-travel-agency-api) 9 | - [Task 5: URL Shortening Service](#task-5-url-shortening-service) 10 | 11 | --- 12 | 13 | ## Task 1: REST API for a Library Management System 14 | 15 | ### Objective 16 | Build a RESTful API for a library management system that manages books, authors, and users. It should also handle borrowing and returning books, with additional features like role-based access control, search, and caching. 17 | 18 | ### Requirements 19 | 20 | 1. **Environment** 21 | - Use a relational database (e.g., MySQL, PostgreSQL, SQLite). 22 | 23 | 2. **Entities** 24 | - **Book** 25 | - `id`: Integer, primary key 26 | - `isbn`: String, required, unique 27 | - `published_date`: Date 28 | - `author_id`: Foreign key to Author 29 | - `status`: Enum [Available, Borrowed], required 30 | - **Author** 31 | - `id`: Integer, primary key 32 | - `name`: String, required 33 | - `bio`: Text, optional 34 | - `birthdate`: Date, optional 35 | - **User** 36 | - `id`: Integer, primary key 37 | - `name`: String, required 38 | - `email`: String, required, unique 39 | - `password`: String, required 40 | - `role`: Enum [Admin, Librarian, Member], required 41 | - **BorrowRecord** 42 | - `id`: Integer, primary key 43 | - `user_id`: Foreign key to User 44 | - `book_id`: Foreign key to Book 45 | - `borrowed_at`: DateTime, required 46 | - `due_at`: DateTime, required 47 | - `returned_at`: DateTime, optional 48 | 49 | 3. **API Endpoints** 50 | - **Books** 51 | - `GET /books`: Retrieve all books. 52 | - `GET /books/{id}`: Retrieve specific book by ID. 53 | - `POST /books`: Create a book (Admin/Librarian). 54 | - `PUT /books/{id}`: Update a book by ID (Admin/Librarian). 55 | - `DELETE /books/{id}`: Delete a book by ID (Admin). 56 | - `POST /books/{id}/borrow`: Borrow a book (Member, if available). 57 | - `POST /books/{id}/return`: Return a borrowed book (Member). 58 | - **Authors** 59 | - Similar CRUD operations for authors. 60 | - **Users** 61 | - Admin-only access to view and manage users. 62 | - `POST /login`: Authenticate and return a JWT/sanctum token. 63 | - **BorrowRecords** 64 | - View borrow records (Admin/Librarian). 65 | 66 | 4. **Additional Requirements** 67 | - Implement RBAC, search, pagination, validation, error handling, feature tests, and rate limiting. 68 | 69 | --- 70 | 71 | ## Task 2: News Aggregator API 72 | 73 | ### Objective 74 | Build a RESTful API for a news aggregator service that fetches articles from various sources and provides endpoints for a frontend application to consume. 75 | 76 | ### Requirements 77 | 78 | 1. **User Authentication** 79 | - User registration and login with JWT/Sanctum. 80 | - API token authentication and password reset. 81 | 82 | 2. **Article Management** 83 | - Fetch articles with pagination, search/filter by keyword, date, category, and source. 84 | 85 | 3. **User Preferences** 86 | - Allow users to set and retrieve preferences (news sources, categories, authors). 87 | 88 | 4. **Data Aggregation** 89 | - Fetch articles from at least 3 APIs (e.g., NewsAPI, The Guardian, BBC News) and store locally. 90 | 91 | 5. **API Documentation** 92 | - Provide documentation using Swagger/OpenAPI. 93 | 94 | --- 95 | 96 | ## Task 3: Automated Email Notification System with Cron Jobs 97 | 98 | ### Objective 99 | Build a system that allows users to schedule automated email notifications to be sent at a future date using cron jobs. 100 | 101 | ### Requirements 102 | 103 | 1. **User Authentication** 104 | - Implement registration and login with sessions. 105 | - Logged-in users can schedule email notifications. 106 | 107 | 2. **Email Scheduling** 108 | - Allow users to schedule emails with recipient, subject, body, and send date/time. 109 | - Use OOP principles (e.g., `Email` class with `scheduleEmail()`, `sendEmail()` methods). 110 | 111 | 3. **Cron Job** 112 | - Check for pending emails and send them at the scheduled time using SMTP. 113 | - Implement retries for failed email attempts. 114 | 115 | 4. **Database Design** 116 | - Tables: `users`, `scheduled_emails` with fields like recipient_email, subject, body, scheduled_time, status, attempts. 117 | 118 | 5. **Code Structure** 119 | - Use an MVC structure for organizing the code. 120 | 121 | --- 122 | 123 | ## Task 4: Travel Agency API 124 | 125 | ### Objective 126 | Develop a RESTful API for managing travels and tours. Users can browse public travels and book tours. 127 | 128 | ### Requirements 129 | 130 | 1. **Models** 131 | - **User** 132 | - Fields: `ID`, `Email`, `Password` 133 | - **Roles** (Many-to-Many with Users) 134 | - **Travels** 135 | - Fields: `ID`, `IsPublic`, `Slug`, `Name`, `Description`, `NumberOfDays` 136 | - **Tours** 137 | - Fields: `ID`, `TravelID`, `Name`, `StartingDate`, `EndingDate`, `Price` 138 | 139 | 2. **Endpoints** 140 | - Private (admin) endpoint for creating travels, tours, and users. 141 | - Public endpoint for browsing travels and tours with filtering and sorting options. 142 | 143 | 3. **Note** 144 | - Use UUIDs as primary keys if possible. 145 | - Use integer values for tour prices (e.g., 99900 for €999.00). 146 | 147 | 148 | 149 | ## Task 5: URL Shortening Service 150 | 151 | ### Objective 152 | Build a URL Shortener API that helps shorten long URLs. 153 | 154 | ### Requirements 155 | 1. **Models** 156 | - **Url** 157 | - Fields: `ID`, `original_url`, `short_url`, `created_at`, `usage_count` 158 | 2. **Basic Endpoint** 159 | - **POST** `/shorten` 160 | - Request body 161 | ``` 162 | { 163 | "originalUrl": "" 164 | } 165 | ``` 166 | - Response body 167 | ``` 168 | { 169 | "shortUrl": "" 170 | } 171 | ``` 172 | - **GET** `/shorten/short_url` 173 | - Gets the base url and then redirects to the base url 174 | 175 | - **GET** `/stats/short_url 176 | - Returns usage statistics for a given shortened URL (e.g., number of times accessed). --------------------------------------------------------------------------------