Live App: https://hsynkmkstutorialapp.netlify.app/
Educator: [email protected]
Password: Educator1.
Student: [email protected]
Password: Student1.
This repository contains a web application built with ASP.NET Core and React following the principles of Clean Architecture. The project is designed to be modular, scalable, and maintainable, utilizing various modern patterns and libraries. Below is a detailed overview of the technologies and approaches used in the project.
- Clean Architecture: Ensures a separation of concerns by organizing the code into layers:
Domain
,Application
,Infrastructure
, andAPI
. - Repository Pattern: Provides a flexible abstraction layer for data access.
- Unit of Work: Manages transactions across multiple repositories.
- DTOs (Data Transfer Objects): Ensures data transfer between layers while maintaining encapsulation.
- AutoMapper: Simplifies object-to-object mapping.
- FluentValidation: Provides robust validation for input models.
- Global Exception Handling: Handles exceptions using a middleware.
- JWT Authentication: Implements secure authentication and role-based authorization.
- Swagger Documentation: Documents the API and provides an interactive interface for testing endpoints.
- Seeding: Seeds initial data into the database for development purposes.
- Pagination: Handles efficient pagination for endpoints.
- CORS Support: Allows secure cross-origin requests.
- ASP.NET Core: Core framework for building the API.
- Entity Framework Core: ORM for database access.
- FluentValidation: Validates incoming requests with custom rules.
- AutoMapper: Handles object mapping between models and DTOs.
- ASP.NET Identity: Manages user authentication and authorization.
- Swashbuckle: Integrates Swagger UI for API documentation.
- Repository Pattern: Encapsulates data access logic into reusable repository classes.
- Unit of Work: Ensures atomicity when working with multiple repositories.
- Clean Architecture: Ensures separation of concerns and enforces dependency inversion.
- Error Handling Middleware: Centralized error handling for exceptions like validation errors, not found exceptions, and server errors.
App.API
├── Controllers # API controllers to handle HTTP requests
├── Middlewares # Custom middleware for error handling
├── Properties
├── appsettings.json # Application configuration
App.Application
├── Common # Shared classes (e.g., pagination)
├── DTOs # Data transfer objects
├── Extensions # Service registration extensions
├── Interfaces # Service and repository interfaces
├── Mappings # AutoMapper profiles
├── Services # Business logic implementations
├── Validators # FluentValidation classes
App.Domain
├── Entities # Core entities
├── Exceptions # Custom exception classes
App.Infrastructure
├── Extensions # Infrastructure-level service registration
├── Migrations # EF Core migrations
├── Repositories # Repository implementations
├── Seeders # Database seeders
Centralized exception handling is implemented through the ErrorHandlingMiddleware
class. It manages various exception types like:
ValidationException
NotFoundException
FailedOperationException
- Unhandled exceptions (500 Internal Server Error)
Implemented using ASP.NET Identity and JWT Authentication. The application supports role-based authorization, ensuring that only authorized users can access certain endpoints.
Swagger UI includes an Authorize
button for testing endpoints requiring JWT tokens.
The AutoMapper
library is used for mapping entities to DTOs and vice versa, reducing boilerplate code in services.
FluentValidation
is used to define validation rules for DTOs. Examples:
public class CourseDtoValidator : AbstractValidator<CourseDto>
{
public CourseDtoValidator()
{
RuleFor(course => course.Name)
.NotEmpty().WithMessage("Course name is required.")
.MaximumLength(50).WithMessage("Course name must be less than 50 characters.");
RuleFor(course => course.Description)
.MaximumLength(500).WithMessage("Description must be less than 500 characters.");
RuleFor(course => course.Price)
.GreaterThan(0).WithMessage("Price must be greater than zero.");
}
}
Repositories provide abstract data access logic. The UnitOfWork
pattern coordinates multiple repositories, ensuring consistency and encapsulating transaction management.
HTTP Method | Endpoint | Description | Authorization Required | Parameters |
---|---|---|---|---|
GET | /api/orders/user |
Get all orders for the current user. | Yes | None |
GET | /api/orders |
Get all orders. | Yes (Educator Role) | None |
POST | /api/orders |
Create a new order. | Yes | Request Body: CreateOrderDto |
- The Educator Role is required for accessing all orders.
- Users can create orders or fetch their own orders.
HTTP Method | Endpoint | Description | Authorization Required | Parameters |
---|---|---|---|---|
POST | /api/users/login |
Log in to the application. | No | Request Body: LoginDto |
POST | /api/users/register |
Register a new user. | No | Request Body: RegisterDto |
PUT | /api/users/profile |
Update the current user’s profile. | Yes | Request Body: UpdateProfileDto |
GET | /api/users |
Get all users with pagination. | Yes (Educator Role) | pageNumber (int, optional, default: 1), pageSize (int, optional, default: 10) |
PUT | /api/users/{userId}/role |
Update a user’s role. | Yes | userId (string, required), Request Body: newRole (string, required) |
PUT | /api/users/{userId} |
Update a user’s details. | Yes (Educator Role) | userId (string, required), Request Body: UpdateUserDto |
DELETE | /api/users/{userId} |
Delete a user by ID. | Yes (Educator Role) | userId (string, required) |
GET | /api/users/currentUser |
Get details of the current authenticated user. | Yes | None |
- Role management requires appropriate permissions (Educator Role).
- Users can only update their own profiles unless they have Educator access.
-
Clone the repository:
git clone https://github.com/hsynkmk/Tutorial-App.git
-
Navigate to the project directory:
cd Tutorial-App cd Backend
-
Update the
appsettings.json
file with your database, AllowedOrigins and JWT configuration. -
Apply migrations:
dotnet ef database update
-
Run the application:
dotnet run
-
Access Swagger UI at:
https://localhost:{port}/swagger
- Implement unit tests and integration tests.
- Add caching for frequently accessed data.
- Support file uploads for course materials.
This is the frontend of the TutorialApp, a learning platform designed for users to explore, purchase, and manage courses. The application supports both learners and educators, with role-based functionalities such as managing courses and users. The frontend is built with Vite, React, and several modern web development tools.
- Learner: Browse courses, view course details, add courses to the cart, and checkout.
- Educator: Manage courses, publish courses, and manage users (for admin-level access).
- Authentication (Login/Logout/Register) with JWT
- Light/Dark mode support using a custom theme context
- Responsive design using Bootstrap
- Dynamic routing with React Router
- API integration with Axios for backend communication
- Toast notifications for a better user experience
- Role-based access control for private routes
- Vite: Build tool for fast development
- React: Library for building the UI
- React Router: For routing and navigation
- Axios: For HTTP requests and API communication
- React Bootstrap: For responsive and mobile-friendly design
- React Icons: For reusable icons
- React Toastify: For toast notifications
- PropTypes: For type-checking React props
- JWT Decode: To decode JWT tokens for authentication
- Bootstrap: CSS framework for styling
- Context:
AuthContext
manages user authentication and role-based access. - JWT token is stored in
localStorage
for session persistence. - Decoded JWT token provides user details (name, email, role).
- Context:
ThemeContext
toggles between light and dark themes. - Components dynamically adjust styles based on the current theme.
- Context:
CartContext
manages the shopping cart, providing functions to add, remove, and clear cart items.
- Axios interceptors ensure that authenticated requests include a valid JWT token in the
Authorization
header. - Separate services (
authService
,userService
,courseService
,orderService
) organize API calls for clarity and reuse.
- Private routes restrict access to pages based on user roles (e.g., Educator-only pages).
- Unauthorized access redirects users to the login page or home.
- Node.js
- npm or yarn
- Clone the repository:
git clone https://github.com/hsynkmk/Tutorial-App.git cd Tutorial-App cd Frontend
- Install dependencies:
npm install
- Start the development server:
npm run dev
This project is licensed under the MIT License. See the LICENSE
file for details.