Skip to content

ElTimoYT/user-app-frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ› ๏ธ User Management App - Frontend

This project is a modern frontend application designed for managing users, developed using Angular, a powerful framework for building dynamic and scalable single-page applications (SPAs). The application acts as the user interface layer of a larger system, seamlessly integrating with a backend server and a database for full functionality.

๐ŸŒŸ Overview of Features

The application offers a comprehensive interface for performing a variety of operations, including:

  • ๐Ÿ” User Authentication: Provides secure login and session management using JWT (JSON Web Tokens), ensuring user credentials are safely transmitted and stored.
  • โœ๏ธ CRUD Operations: Enables administrators or authorized users to create, read, update, and delete user profiles effortlessly.
  • ๐Ÿ“Š State Management: Utilizes NgRx, a library inspired by Redux, to handle application state predictably and efficiently. NgRx helps to centralize the state, ensuring that the UI reflects data changes consistently.
  • ๐ŸŽจ Elegant Design: Styled with Bootstrap, the application features a responsive layout that works seamlessly across different screen sizes and devices.
  • โš ๏ธ Interactive Alerts: Integrated with SweetAlert2, providing polished and intuitive alerts for success, error, and confirmation messages.

โš™๏ธ Technical Requirements

This frontend application works in conjunction with:

1. ๐Ÿ–ฅ๏ธ A Backend Server

  • The backend is responsible for handling authentication, API endpoints, and business logic. It communicates with the frontend through RESTful APIs.
  • The backend must be configured to accept JWT tokens for secure user authentication and role-based access control (RBAC).
  • Detailed instructions for setting up the backend server, including API documentation, are available in the corresponding backend repository.

2. ๐Ÿ—„๏ธ A Database

  • The backend connects to a database (e.g., MySQL, PostgreSQL, or MongoDB) to persist user data, authentication credentials, and other records.
  • A properly structured schema is required to store user information and manage relationships, such as roles and permissions.

3. ๐Ÿ“ฆ Node.js and npm

  • Node.js provides the runtime for building and running the application.
  • npm (Node Package Manager) is required to manage dependencies and development tools.
  • Minimum version requirements should be verified in the package.json file.

4. ๐ŸŒ Browser Compatibility

  • The application is designed to be compatible with modern browsers such as Google Chrome, Mozilla Firefox, Microsoft Edge, and Safari.

๐Ÿ› ๏ธ Development Tools and Libraries

The application leverages a variety of tools and libraries to enhance its functionality and streamline development:

  • Angular CLI: For project scaffolding, serving, and building the application.
  • RxJS: A library for managing asynchronous data streams, which is integral to Angular and NgRx for handling user interactions and API responses.
  • NgRx: A state management library that provides a predictable way to manage application state using actions, reducers, effects, and selectors.
  • Bootstrap: Ensures the UI is clean, responsive, and visually appealing with pre-built components and styles.
  • SweetAlert2: Enhances user experience with customizable popups and modals for alerts and confirmations.
  • TypeScript: Provides strong typing to JavaScript, enhancing code quality and reducing runtime errors.

๐Ÿ”— Integration with Backend

  • The application communicates with the backend server using HTTP requests via Angularโ€™s HttpClientModule.
  • All API endpoints, authentication logic, and database interactions are defined in the backend. The backend repository includes:
    • API documentation for setting up the server.
    • Environment configuration for connecting to the database.
    • Middleware for token validation and error handling.

๐Ÿงฉ Key Considerations

๐Ÿ” Authentication

  • The app relies on a secure backend API for user login. Upon successful login, a JWT token is issued and stored in the browser's localStorage or sessionStorage. This token is appended to subsequent API requests for secure access.

๐Ÿ‘ฎ Role-Based Access Control

  • Different user roles (e.g., Admin, User) determine access to specific routes and features. Guards implemented in Angular ensure that unauthorized users are redirected appropriately.

๐ŸŒ Environment Configuration

  • The application uses environment-specific settings to define the backend API URL, ensuring smooth deployment in different environments (development, staging, production).

๐Ÿ”ง Extensibility

  • The project is modular and adheres to Angular best practices, making it easy to extend with additional features, such as:
    • Adding dashboards or analytics.
    • Integrating third-party APIs for advanced functionality.

๐Ÿ“ฑResponsive and User-Friendly Design

The application ensures an intuitive user experience by:

  • Offering a mobile-first responsive design powered by Bootstrap.
  • Providing instant feedback to user actions with dynamic alerts and loading indicators.
  • Optimizing performance by leveraging lazy loading and efficient state management.

๐Ÿ”ฎ Further Enhancements

Future improvements to the application may include:

  • Internationalization (i18n): Support for multiple languages.
  • Offline Functionality: Using Service Workers and caching strategies for PWA capabilities.
  • Advanced Analytics: Integration with tools like Google Analytics for user tracking and reporting.

โœจ Key Features

๐Ÿ” Authentication

  • ๐Ÿ›ก๏ธ JWT Authentication: Secure login and session management using JSON Web Tokens (JWT). The tokens are stored in localStorage or sessionStorage depending on user preference.
  • ๐Ÿšช Guards: Route protection for unauthorized access.
  • ๐Ÿ‘ค Role-Based Access Control (RBAC): Allows different user roles (e.g., admin, editor, viewer) to access specific features.
  • โŒ Logout: Securely log out by clearing session tokens.

๐Ÿ‘ฅ User Management

  • ๐Ÿ“‹ User List: Paginated view of all users.
  • ๐Ÿ“„ User Details: Detailed view of individual user data.
  • โž• Add/Edit User: Create or update user profiles.
  • ๐Ÿ—‘๏ธ Delete User: Remove users with confirmation alerts.

๐Ÿ“Š State Management with NgRx

  • ๐Ÿ”„ Auth State: Manage authentication actions like login, logout, and error handling.
  • ๐Ÿ—‚๏ธ User State: Handle user-related actions such as fetching, adding, updating, and deleting users.
  • ๐Ÿงฉ Reducers and Effects: Ensure seamless state updates and side effects handling.

๐ŸŽจ UI & Alerts

  • ๐Ÿ“ฑ Responsive Design: Built with Bootstrap for mobile-friendly layouts.
  • ๐ŸŒ‘ Dark Theme: Default dark mode styling.
  • โš ๏ธ SweetAlert2: Elegant alerts for success, error, and confirmation messages.

๐Ÿ—บ๏ธ Routing

  • ๐Ÿ“ Dynamic Routes: Protect routes with guards and facilitate navigation:
  • /users: List all users.
  • /users/create: Add a new user (protected).
  • /users/edit/:id: Edit user details (protected).
  • /users/page/:page: Navigate user pages.
  • /login: Login page.
  • /forbidden: Access denied page.

๐Ÿงฑ Project Structure

๐Ÿงฉ Components

  • ๐Ÿ  AppComponent: Root component of the application.
  • ๐Ÿ’ผ UserAppComponent: Main container, includes navigation and router outlet.
  • ๐Ÿ“Œ NavbarComponent: Displays navigation links and authentication options.
  • ๐Ÿ” AuthComponent: User login form.
  • ๐Ÿšซ Forbidden403Component: Access denied page.
  • ๐Ÿ“œ PaginatorComponent: Handles pagination.
  • ๐Ÿ‘ฅ UserComponent: Displays a list of users with options for editing and deleting.
  • โœ๏ธ UserFormComponent: Form for creating or editing user details.

๐Ÿ› ๏ธ Services

  • ๐Ÿ”’ AuthService: Manages authentication (login, logout, token storage).
  • ๐Ÿ“‹ UserService: Performs CRUD operations for users.
  • ๐Ÿ”— SharingDataService: Shares data between components using EventEmitter.

๐Ÿ›ก๏ธ Guards

  • ๐Ÿ›ก๏ธ AuthGuard: Protects routes from unauthorized access and verifies user roles.

๐Ÿ“ฅ HTTP Interceptors

  • ๐Ÿ”— TokenInterceptor: Appends authentication tokens to HTTP requests.

โš™๏ธ Installation and Setup

Prerequisites

  • Node.js and npm installed.
  • Angular CLI globally installed:
    npm install -g @angular/cli
    

Steps to Setup

  • Clone the Repository:
    git clone https://github.com/yourusername/user-management-app.git
    cd user-management-app
    
  • Install Dependencies:
    npm install
    
  • Backend Configuration: Configure the backend API URL in the config.ts file:
    export const BACKEND_URL = 'http://your-backend-api-url';
    
  • Run the Application:
    ng serve
    

The app will be available at http://localhost:4200.


๐Ÿ”„ NgRx State Management

โšก Actions

๐Ÿ” Auth Actions

  • login
  • loginSuccess
  • loginError
  • logout

๐Ÿ‘ฅ User Actions

  • findAll
  • findAllPageable
  • add
  • update
  • remove
  • load
  • setPaginator

๐ŸŒŸ Effects

  • Auth Effects: Manages side effects for login and logout.
  • User Effects: Handles user-related actions like fetching, adding, and updating users.

๐Ÿงฉ Reducers

  • Auth Reducer: Manages authentication state.
  • User Reducer: Manages user data state.

๐Ÿ“œ License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published