Skip to content

Robotic1804/CRUD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ CRUD App - Employee Management System

Modern employee management application built with Angular 19

Angular TypeScript Firebase Bootstrap

Features β€’ Installation β€’ Usage β€’ Technologies β€’ Architecture


πŸ“‹ Description

Complete employee management system (CRUD) with advanced Firebase authentication, built with the latest versions of Angular and following modern development best practices.

The application features:

  • πŸ” Multiple authentication methods: Email/Password and Google OAuth
  • πŸ‘€ Complete user management: Registration, login, profile, and password recovery
  • πŸ’Ό Full CRUD operations for employee management
  • 🎨 Modern, responsive UI with Bootstrap 5
  • πŸ”’ Enterprise-grade security with JWT tokens and route guards

✨ Features

πŸ” Authentication & Security

  • βœ… Firebase Auth authentication
  • βœ… User Registration with email validation
  • βœ… Email/Password Login with error handling
  • βœ… Google Sign-In (OAuth 2.0)
  • βœ… Forgot Password with email recovery
  • βœ… Email Verification system
  • βœ… User Profile page with account details
  • βœ… Securely stored JWT tokens
  • βœ… Route protection with Guards
  • βœ… Input validation on all forms
  • βœ… Environment variables for sensitive credentials

πŸ’Ό Employee Management

  • βœ… Create new employees
  • βœ… List all employees
  • βœ… Update employee information
  • βœ… Delete employees
  • βœ… Required field validation
  • βœ… Responsive interface with Bootstrap 5

🎨 Modern UI/UX

  • βœ… Responsive, mobile-first design
  • βœ… Modern template syntax (@if, @for)
  • βœ… Loading spinners for async operations
  • βœ… User-friendly error messages with dismissible alerts
  • βœ… Success notifications for completed actions
  • βœ… Intuitive navigation with Angular Router
  • βœ… Visual feedback for CRUD operations
  • βœ… Bootstrap 5 cards and modern components

πŸ—οΈ Architecture

  • βœ… Modular and reusable services
  • βœ… Professional observable handling (no memory leaks)
  • βœ… Structured logging system
  • βœ… TypeScript typed interfaces
  • βœ… Separation of Concerns (SoC)

πŸ› οΈ Technologies

Frontend

Technology Version Usage
Angular 19.2.17 Main framework
TypeScript 5.8.3 Programming language
RxJS 7.8.2 Reactive programming
Bootstrap 5.3.8 CSS framework

Backend & Services

Technology Version Usage
Firebase 12.6.0 Realtime database
Firebase Auth - User authentication

Development Tools

  • Angular CLI 19.2.19
  • Karma (Testing)
  • Jasmine (Unit Testing)

πŸ“ Project Structure

CRUD/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ actualiza-componente/      # Update component
β”‚   β”‚   β”œβ”€β”€ caracteristica-emp/        # Employee features
β”‚   β”‚   β”œβ”€β”€ contacto-comp/             # Contact page
β”‚   β”‚   β”œβ”€β”€ error-personalizado/       # 404 page
β”‚   β”‚   β”œβ”€β”€ forgot-password/           # πŸ†• Password recovery
β”‚   β”‚   β”‚   β”œβ”€β”€ forgot-password.component.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ forgot-password.component.html
β”‚   β”‚   β”‚   └── forgot-password.component.css
β”‚   β”‚   β”œβ”€β”€ home-component/            # Main page (list)
β”‚   β”‚   β”œβ”€β”€ login/                     # Authentication system
β”‚   β”‚   β”‚   β”œβ”€β”€ login.component.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ login.service.ts       # Auth + Google Sign-In
β”‚   β”‚   β”‚   └── login-guardian.ts      # Route Guard
β”‚   β”‚   β”œβ”€β”€ register/                  # πŸ†• User registration
β”‚   β”‚   β”‚   β”œβ”€β”€ register.component.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ register.component.html
β”‚   β”‚   β”‚   └── register.component.css
β”‚   β”‚   β”œβ”€β”€ user-profile/              # πŸ†• User profile page
β”‚   β”‚   β”‚   β”œβ”€β”€ user-profile.component.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ user-profile.component.html
β”‚   β”‚   β”‚   └── user-profile.component.css
β”‚   β”‚   β”œβ”€β”€ paren-c/                   # Employee component
β”‚   β”‚   β”œβ”€β”€ proyectos-comp/            # Projects page
β”‚   β”‚   β”œβ”€β”€ quienes-somos-comp/        # About us page
β”‚   β”‚   β”œβ”€β”€ shared/                    # Shared services
β”‚   β”‚   β”‚   β”œβ”€β”€ loading-spinner/       # πŸ†• Reusable spinner
β”‚   β”‚   β”‚   β”œβ”€β”€ firebase-response.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ logger.service.ts
β”‚   β”‚   β”‚   └── notification.service.ts
β”‚   β”‚   β”œβ”€β”€ app.component.ts           # Root component
β”‚   β”‚   β”œβ”€β”€ app.module.ts              # Main module
β”‚   β”‚   β”œβ”€β”€ data.services.ts           # Firebase data service
β”‚   β”‚   β”œβ”€β”€ empleado.model.ts          # Employee model
β”‚   β”‚   └── empleados.service.ts       # Business logic
β”‚   β”œβ”€β”€ environments/                   # Environment variables
β”‚   β”‚   β”œβ”€β”€ environment.ts             # Production
β”‚   β”‚   β”œβ”€β”€ environment.development.ts # Development
β”‚   β”‚   └── environment.example.ts     # Template for setup
β”‚   β”œβ”€β”€ assets/                        # Static resources
β”‚   β”œβ”€β”€ main.ts                        # πŸ”₯ Firebase initialization
β”‚   └── index.html
β”œβ”€β”€ angular.json                       # Angular configuration
β”œβ”€β”€ package.json                       # Dependencies
└── README.md

πŸš€ Installation

Prerequisites

Make sure you have installed:

  • Node.js (version 18.x or higher)
  • npm (version 9.x or higher)
  • Angular CLI 19.x
npm install -g @angular/cli@19

Installation Steps

  1. Clone the repository
git clone <repository-url>
cd CRUD
  1. Install dependencies
npm install
  1. Configure Firebase

Create a project in Firebase Console and get your credentials.

Edit src/environments/environment.development.ts:

export const environment = {
  production: false,
  firebase: {
    apiKey: "YOUR_API_KEY",
    authDomain: "your-project.firebaseapp.com",
    projectId: "your-project",
    databaseURL: "https://your-project-default-rtdb.firebaseio.com"
  }
};

⚠️ IMPORTANT: Never upload your Firebase credentials to public repositories. Add src/environments/ to your .gitignore.

  1. Enable Firebase Authentication Providers

In the Firebase Console:

  • Go to Authentication β†’ Sign-in method
  • Enable Email/Password provider
  • Enable Google provider:
    • Add your support email
    • Add your project's public-facing name
  • Save changes
  1. Start the development server
ng serve

Navigate to http://localhost:4200/

πŸ“– Usage

Run in Development

npm start
# or
ng serve

The application will automatically reload when you make changes to the files.

Available Routes

Route Description Protected
/ Home - Employee list ❌ No
/login User login (Email/Password or Google) ❌ No
/register New user registration ❌ No
/forgot-password Password recovery ❌ No
/profile User profile and account settings βœ… Yes
/quienes About us page βœ… Yes
/contacto Contact page βœ… Yes
/proyectos Projects page ❌ No
/actualiza/:id Update employee ❌ No

Authentication Features

1️⃣ Register New User

  • Navigate to /register
  • Enter email and password (min 6 characters)
  • Confirm password
  • Click "Register"
  • Automatically logged in and redirected to home

2️⃣ Login with Email/Password

  • Navigate to /login
  • Enter your credentials
  • Click "Login"
  • Redirected to home page

3️⃣ Login with Google

  • Navigate to /login
  • Click "Sign in with Google" button
  • Select your Google account
  • Automatically redirected back and logged in

4️⃣ Forgot Password

  • Click "Forgot password?" link on login page
  • Enter your email address
  • Click "Send Reset Link"
  • Check your email for password reset instructions

5️⃣ User Profile

  • After logging in, click "Profile" in navigation
  • View your account details:
    • Email address
    • Email verification status
    • Account creation date
    • Last sign-in time
  • Send verification email if not verified
  • Logout from your account

Build for Production

npm run build
# or
ng build

Build artifacts will be stored in the dist/crud-app directory.

Deploy to Vercel

This project is ready for Vercel deployment with automatic environment configuration.

Quick Deploy:

  1. Push your code to GitHub
  2. Import project to Vercel
  3. Add environment variables in Vercel dashboard:
    • FIREBASE_API_KEY
    • FIREBASE_AUTH_DOMAIN
    • FIREBASE_PROJECT_ID
    • FIREBASE_DATABASE_URL
    • FIREBASE_STORAGE_BUCKET
    • FIREBASE_MESSAGING_SENDER_ID
    • FIREBASE_APP_ID
  4. Deploy!

πŸ“– Full deployment guide: See VERCEL_SETUP.md for detailed instructions.

The build script automatically generates environment files from Vercel environment variables during deployment.

Run Tests

# Unit tests
npm test

# Tests with coverage
ng test --code-coverage

πŸ”§ Available Scripts

Command Description
npm start Start development server
npm run build Build the application for production
npm test Run unit tests
npm run watch Build in watch mode (development)

πŸ›οΈ Architecture

Design Pattern

The application follows the MVC (Model-View-Controller) pattern adapted for Angular:

  • Model: empleado.model.ts, interfaces in shared/
  • View: HTML Templates + CSS
  • Controller: TypeScript Components

Data Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Component  β”‚ ───> β”‚   Service    β”‚ ───> β”‚   Firebase  β”‚
β”‚   (View)    β”‚ <─── β”‚   (Logic)    β”‚ <─── β”‚  (Backend)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Main Services

πŸ”Ή EmpleadosService

Handles business logic for CRUD operations.

πŸ”Ή DataServices

Communicates with Firebase Realtime Database.

πŸ”Ή LoginService

Advanced authentication manager with:

  • User registration (register())
  • Email/password login (login())
  • Google OAuth Sign-In (loginWithGoogle())
  • Password recovery (resetPassword())
  • Redirect handling (handleRedirectResult())
  • Session management with JWT tokens
  • Auth state listener for automatic token refresh

πŸ”Ή LoggerService

Conditional logging system (development vs production).

πŸ”Ή NotificationService

User notification system.

πŸ” Security

Implemented Best Practices

βœ… Environment Variables: Firebase credentials separated from code βœ… JWT Authentication: Tokens stored in localStorage βœ… Authorization Headers: Tokens sent in HTTP headers βœ… Route Guards: Private route protection βœ… Input Validation: Injection prevention βœ… Strong Typing: TypeScript to prevent errors

Firebase Security Configuration

Make sure to configure security rules in Firebase:

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }
}

🎨 Customization

Styles

Global styles are in:

  • src/styles.css - Global styles
  • Each component has its own CSS file

Bootstrap Themes

You can customize Bootstrap colors by editing variables in src/styles.css:

:root {
  --bs-primary: #your-color;
  --bs-secondary: #your-color;
}

πŸ› Troubleshooting

Issue: Firebase compilation error

Solution: Make sure you're using the correct Firebase version:

npm install [email protected]

Issue: "Cannot find module '@angular/core'" error

Solution: Reinstall dependencies:

rm -rf node_modules package-lock.json
npm install

Issue: CORS error with Firebase

Solution: Verify that the Firebase URL in environment.ts is correct and that security rules allow access.

Issue: "No Firebase App '[DEFAULT]' has been created"

Solution: This happens when Firebase isn't initialized before Angular starts. The app already handles this by initializing Firebase in main.ts before bootstrapping Angular.

Issue: Google Sign-In not working - "auth/operation-not-allowed"

Solution:

  1. Go to Firebase Console
  2. Navigate to Authentication β†’ Sign-in method
  3. Enable the Google provider
  4. Add your support email
  5. Save changes

Issue: Cross-Origin-Opener-Policy errors with Google Sign-In

Solution: The app uses signInWithRedirect instead of signInWithPopup to avoid COOP issues. This is already implemented.

Issue: 401 Unauthorized error after Google login

Solution: The app uses onAuthStateChanged listener to automatically refresh tokens. Make sure you're on the latest version of the code.

πŸ†• What's New in v2.0

This version includes major authentication enhancements:

New Components

  • ✨ User Registration - Complete signup flow with validation
  • ✨ Forgot Password - Email-based password recovery
  • ✨ User Profile - Account details and email verification
  • ✨ Loading Spinner - Reusable component for async operations

New Features

  • πŸ” Google Sign-In - OAuth 2.0 authentication with redirect flow
  • πŸ“§ Email Verification - Send verification emails from profile page
  • πŸ”„ Auto Token Refresh - Auth state listener keeps tokens updated
  • ⚠️ Enhanced Error Handling - User-friendly error messages
  • 🎨 Modern UI Updates - Bootstrap 5 cards, alerts, and icons

Technical Improvements

  • πŸš€ Firebase initialization moved to main.ts for better reliability
  • πŸ”§ Changed from signInWithPopup to signInWithRedirect to avoid COOP issues
  • πŸ›‘οΈ Automatic JWT token management with onAuthStateChanged
  • πŸ“± Fully responsive authentication pages
  • ♻️ Reusable loading spinner component across the app

πŸ“š Additional Resources

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for detailed guidelines.

πŸ“ License

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

πŸ‘¨β€πŸ’» Author

Norman - GitHub


⭐ If you liked this project, give it a star!

Made with ❀️ and Angular