Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/abdulrahmanaymann/imdbclone-restfulapi

IMDB Clone RESTful API.
https://github.com/abdulrahmanaymann/imdbclone-restfulapi

asp-net-core asp-net-core-web-api auto-mapper caching csharp dotnet dtos ef-core filtering identity jwt-authentication n-tier-architecture pagination refresh-token repository-pattern restful-api sql-server swagger tmdb-api unit-of-work-pattern

Last synced: 16 days ago
JSON representation

IMDB Clone RESTful API.

Awesome Lists containing this project

README

        

![Logo](https://i.imgur.com/srymhmQ.png)

# ๐ŸŽฌ IMDBClone RESTful API

## ๐Ÿ“ Description

The **IMDBClone RESTful API** is a backend application that replicates key features of IMDb, managing movie-related data, user authentication, ratings, reviews, and watchlists. It supports secure authentication and role-based access controls, allowing for flexible management of users and interactions.

---

## ๐Ÿš€ Technologies

- **Programming Language**: C#
- **Framework**: ASP.NET Core
- **Database**: SQL Server
- **ORM**: Entity Framework Core
- **Authentication**: JWT (JSON Web Tokens)
- **Caching**: IMemoryCache
- **Web Scraping**: Python
- **External API**: TMDB API

---

## ๐ŸŒ Data Integration

- **Web Scraping**: Uses Python scripts to gather additional movie data from external sources, enhancing the database with up-to-date information.
- **TMDB API**: Integrates with The Movie Database (TMDB) API for real-time movie data fetching, ensuring users always have access to the latest information.

---

## ๐Ÿ— Architecture

The API follows a layered architecture that promotes modularity and separation of concerns, utilizing Unit of Work and Repository patterns for efficient data handling.

- **Business Layer**: Contains services and mapping profiles for business logic and DTO mappings.
- **Common Layer**: Stores constants, enums, settings, and utility classes.
- **Core Layer**: Defines data models, DTOs, and validation attributes.
- **Data Access Layer**: Manages database operations with Repository and Unit of Work patterns.
- **Web API Layer**: Exposes RESTful endpoints to handle client interactions.

---

## ๐Ÿ“‚ Backend Structure

### **Project Modules**

- **IMDbClone.Business**
- **Services**: Interfaces and implementations for application functionalities like authentication, caching, and data management.
- **Mapper**: Configures mappings between DTOs and models.

- **IMDbClone.Common**
- **Constants**: Defines roles, HTTP status codes, and cache keys.
- **Settings**: Manages configurations for caching and other settings.

- **IMDbClone.Core**
- **DTOs**: Data transfer objects for movies, users, ratings, reviews, and watchlists.
- **Models**: Entity models defining the application's data structure.
- **Utilities**: Provides pagination, expression handling, and validation.

- **IMDbClone.DataAccess**
- **Repository**: Implements data operations using Unit of Work for transactional integrity.

- **IMDbClone.WebAPI**
- **Controllers**: Exposes API endpoints to handle requests and responses.

---

## ๐ŸŽฎ Controllers Overview

### 1. **AuthController** ๐Ÿ”’
Handles user authentication and profile management operations.

| Endpoint | Method | Description | Auth Required |
|---------------------------|--------|--------------------------------------------|---------------|
| `/api/auth/register` | POST | Register a new user | โŒ |
| `/api/auth/login` | POST | Login and receive JWT tokens | โŒ |
| `/api/auth/refresh-token` | POST | Refresh access tokens | โœ… |
| `/api/auth/profile` | GET | Retrieve profile of the logged-in user | โœ… |
| `/api/auth/profile` | PUT | Update profile of the logged-in user | โœ… |

### 2. **MovieController** ๐ŸŽฌ
Manages movie data, including addition, retrieval, updating, and deletion.

| Endpoint | Method | Description |
|-------------------------|--------|-----------------------------------------------------|
| `/api/movies` | GET | Retrieve all movies with optional filters |
| `/api/movies/{id}` | GET | Retrieve details for a specific movie |
| `/api/movies` | POST | Add a new movie to the database |
| `/api/movies/{id}` | PUT | Update existing movie details |
| `/api/movies/{id}` | DELETE | Remove a movie from the database |

### 3. **RatingController** โญ
Controls movie ratings, allowing users to add, view, update, and delete ratings.

| Endpoint | Method | Description |
|-------------------------|--------|----------------------------------------|
| `/api/ratings` | GET | Retrieve all ratings |
| `/api/ratings/{id}` | GET | Retrieve a specific rating |
| `/api/ratings` | POST | Submit a new rating |
| `/api/ratings/{id}` | PUT | Update an existing rating |
| `/api/ratings/{id}` | DELETE | Delete a rating |

### 4. **ReviewController** ๐Ÿ“
Manages user reviews for movies, including retrieval, creation, updating, and deletion.

| Endpoint | Method | Description |
|-------------------------|--------|-----------------------------------------------------|
| `/api/review` | GET | Retrieve all reviews |
| `/api/review/{id}` | GET | Retrieve a specific review |
| `/api/review` | POST | Create a new review |
| `/api/review/{id}` | PUT | Update an existing review |
| `/api/review/{id}` | DELETE | Delete a review |

### 5. **WatchlistController** ๐ŸŽฅ
Handles watchlists for users, allowing them to manage their movie collections.

| Endpoint | Method | Description |
|-------------------------|--------|-----------------------------------------------------|
| `/api/watchlist` | GET | Retrieve all movies in the userโ€™s watchlist |
| `/api/watchlist/{id}` | GET | Retrieve details of a specific movie in watchlist |
| `/api/watchlist` | POST | Add a movie to the userโ€™s watchlist |
| `/api/watchlist/{id}` | DELETE | Remove a movie from the userโ€™s watchlist |

### 6. **UserController** ๐Ÿ‘ค
Manages user profiles, roles, and administrative account operations.

| Endpoint | Method | Description | Auth Required |
|------------------------------|--------|------------------------------------------------|---------------|
| `/api/users` | GET | Retrieve all registered users with filtering | โœ… |
| `/api/users/{userId}` | GET | Retrieve a specific user profile by ID | โœ… |
| `/api/users/{userId}` | DELETE | Delete a specific user from the system | โœ… |
| `/api/users/{userId}/roles` | GET | Retrieve roles assigned to a specific user | โœ… |
| `/api/users/{userId}/roles` | POST | Assign a role to a specific user | โœ… |
| `/api/users/{userId}/roles` | PUT | Update roles assigned to a specific user | โœ… |
| `/api/users/{userId}/roles` | DELETE | Remove a role from a specific user | โœ… |
| `/api/users/roles` | GET | Retrieve all available roles | โœ… |

---

## ๐Ÿ“ Project Structure

```
IMDbClone
โ”‚
โ”œโ”€โ”€ IMDbClone.Business
โ”‚ โ”œโ”€โ”€ Mapper
โ”‚ โ”‚ โ””โ”€โ”€ MappingProfile.cs
โ”‚ โ”œโ”€โ”€ Services
โ”‚ โ”‚ โ”œโ”€โ”€ IServices
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ IUserService.cs
โ”‚ โ”‚ โ”œโ”€โ”€ auth
โ”‚ โ”‚ โ”œโ”€โ”€ cache
โ”‚ โ”‚ โ”œโ”€โ”€ movie
โ”‚ โ”‚ โ”œโ”€โ”€ rating
โ”‚ โ”‚ โ”œโ”€โ”€ review
โ”‚ โ”‚ โ”œโ”€โ”€ watchlist
โ”‚ โ”‚ โ””โ”€โ”€ token
โ”‚ โ”‚ โ””โ”€โ”€ user
โ”‚ โ”‚ โ””โ”€โ”€ UserService.cs
โ”‚
โ”œโ”€โ”€ IMDbClone.Common
โ”‚ โ”œโ”€โ”€ Constants
โ”‚ โ”‚ โ”œโ”€โ”€ Roles.cs
โ”‚ โ”‚ โ”œโ”€โ”€ HttpStatusCodes.cs
โ”‚ โ”‚ โ””โ”€โ”€ CacheKeys.cs
โ”‚ โ””โ”€โ”€ Settings
โ”‚ โ””โ”€โ”€ CacheSettings.cs
โ”‚
โ”œโ”€โ”€ IMDbClone.Core
โ”‚ โ”œโ”€โ”€ DTOs
โ”‚ โ”‚ โ”œโ”€โ”€ AuthDTOs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ LoginRequestDTO.cs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ LoginResponseDTO.cs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ RefreshTokenRequestDTO.cs
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ RegistrationRequestDTO.cs
โ”‚ โ”‚ โ”œโ”€โ”€ MovieDTOs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ CreateMovieDTO.cs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ MovieDTO.cs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ MovieSummaryDTO.cs
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ UpdateMovieDTO.cs
โ”‚ โ”‚ โ”œโ”€โ”€ RatingDTOs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ CreateRatingDTO.cs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ RatingDTO.cs
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ UpdateRatingDTO.cs
โ”‚ โ”‚ โ”œโ”€โ”€ ReviewDTOs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ CreateReviewDTO.cs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ReviewDTO.cs
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ UpdateReviewDTO.cs
โ”‚ โ”‚ โ”œโ”€โ”€ UserDTOs
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ UserDTO.cs
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ UserProfileDTO.cs
โ”‚ โ”‚ โ””โ”€โ”€ WatchlistDTOs
โ”‚ โ”‚ โ”œโ”€โ”€ CreateWatchlistDTO.cs
โ”‚ โ”‚ โ””โ”€โ”€ WatchlistDTO.cs
โ”‚ โ”œโ”€โ”€ Enums
โ”‚ โ”‚ โ””โ”€โ”€ Genre.cs
โ”‚ โ”œโ”€โ”€ Exceptions
โ”‚ โ”‚ โ””โ”€โ”€ ApiException.cs
โ”‚ โ”œโ”€โ”€ Models
โ”‚ โ”‚ โ”œโ”€โ”€ ApplicationUser.cs
โ”‚ โ”‚ โ”œโ”€โ”€ Movie.cs
โ”‚ โ”‚ โ”œโ”€โ”€ Rating.cs
โ”‚ โ”‚ โ”œโ”€โ”€ Review.cs
โ”‚ โ”‚ โ””โ”€โ”€ Watchlist.cs
โ”‚ โ”œโ”€โ”€ Responses
โ”‚ โ”‚ โ””โ”€โ”€ APIResponse.cs
โ”‚ โ”œโ”€โ”€ Utilities
โ”‚ โ”‚ โ”œโ”€โ”€ PaginatedResult.cs
โ”‚ โ”‚ โ””โ”€โ”€ ExpressionUtilities.cs
โ”‚ โ””โ”€โ”€ Validation
โ”‚ โ”œโ”€โ”€ FullNameAttribute.cs
โ”‚ โ””โ”€โ”€ ValidCastAttribute.cs
โ”‚
โ”œโ”€โ”€ IMDbClone.DataAccess
โ”‚ โ”œโ”€โ”€ Data
โ”‚ โ”‚ โ””โ”€โ”€ ApplicationDbContext.cs
โ”‚ โ”œโ”€โ”€ DbInitializer
โ”‚ โ”‚ โ””โ”€โ”€ DBInitializer.cs
โ”‚ โ”œโ”€โ”€ Migrations
โ”‚ โ””โ”€โ”€ Repository
โ”‚ โ”œโ”€โ”€ IRepository
โ”‚ โ”œโ”€โ”€ WatchlistRepository.cs
โ”‚ โ”œโ”€โ”€ UserRepository.cs
โ”‚ โ”œโ”€โ”€ UnitOfWork.cs
โ”‚ โ”œโ”€โ”€ ReviewRepository.cs
โ”‚ โ”œโ”€โ”€ Repository.cs
โ”‚ โ”œโ”€โ”€ RatingRepository.cs
โ”‚ โ””โ”€โ”€ MovieRepository.cs
โ”‚
โ”œโ”€โ”€ IMDbClone.WebAPI
โ”‚ โ”œโ”€โ”€ Controllers
โ”‚ โ”‚ โ”œโ”€โ”€ AuthController.cs
โ”‚ โ”‚ โ”œโ”€โ”€ MovieController.cs
โ”‚ โ”‚ โ”œโ”€โ”€ RatingController.cs
โ”‚ โ”‚ โ”œโ”€โ”€ ReviewController.cs
โ”‚ โ”‚ โ”œโ”€โ”€ UserController.cs
โ”‚ โ”‚ โ””โ”€โ”€ WatchlistController.cs
โ”‚ โ”œโ”€โ”€ Program.cs
โ”‚ โ””โ”€โ”€ appsettings.json
```
---

## ๐Ÿ“Œ Getting Started

1. Clone the repository.
```bash
git clone https://github.com/yourusername/IMDbClone-API.git
```
2. Install dependencies and set up the database.
3. Configure environment variables for database connection, JWT, TMDB API keys, and any other required settings.
4. Run the application using your preferred IDE or command line.

---