Skip to content

Employee Recognition API is a GraphQL backend for sending recognition, reactions, and comments between employees in real time. Built with Apollo Server and TypeScript, it supports role-based access and WebSocket subscriptions. Perfect for internal tools or prototyping employee appreciation systems.

Notifications You must be signed in to change notification settings

Saiharitha3/GraphQL-API---Employee-Recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Employee Recognition API

A modern GraphQL API for employee recognition and appreciation systems, built with Apollo Server, TypeScript, and WebSocket subscriptions for real-time updates.

πŸš€ Features

  • GraphQL API with Apollo Server v4
  • Real-time subscriptions using WebSocket
  • Employee recognition system with reactions and comments
  • Role-based access control (Employee, Manager, HR)
  • Custom GraphQL interface for easy testing
  • TypeScript for type safety
  • In-memory data storage (ready for database integration)

πŸ“‹ Prerequisites

  • Node.js >= 16.0.0
  • npm or yarn

πŸ› οΈ Installation

  1. Clone the repository

    git clone <repository-url>
    cd employee-recognition-api
  2. Install dependencies

    npm install
  3. Start the development server

    npm start

    Or for development with auto-restart:

    npm run dev

🌐 Available Endpoints

πŸ“Š API Features

Core Entities

  • Users: Employees, Managers, and HR personnel
  • Recognitions: Appreciation messages between employees
  • Reactions: Emoji reactions on recognitions
  • Comments: Text comments on recognitions

Authentication

Currently uses a simple token-based system:

  • Format: Bearer token_<userId>
  • Example: Bearer token_1 for user with ID "1"

Sample Users

The system comes with pre-configured users:

ID Name Email Role Team Department
1 John Doe [email protected] EMPLOYEE Engineering Technology
2 Jane Smith [email protected] MANAGER Engineering Technology
3 Bob Wilson [email protected] HR HR Human Resources
4 Sarah Johnson [email protected] EMPLOYEE Design Product
5 Mike Chen [email protected] MANAGER Design Product
6 Emily Davis [email protected] EMPLOYEE Marketing Sales
7 David Rodriguez [email protected] MANAGER Marketing Sales

πŸ” GraphQL Queries

Get All Users

query {
  users {
    id
    name
    email
    role
    team
    department
    recognitionsReceivedCount
    recognitionsGivenCount
  }
}

Get Recognitions

query {
  recognitions {
    id
    message
    emoji
    from {
      id
      name
    }
    to {
      id
      name
    }
    reactions {
      emoji
      user {
        name
      }
    }
    comments {
      message
      user {
        name
      }
    }
    createdAt
  }
}

Get User by ID

query {
  user(id: "1") {
    id
    name
    email
    role
    recognitionsReceived {
      id
      message
      from {
        name
      }
    }
    recognitionsGiven {
      id
      message
      to {
        name
      }
    }
  }
}

✏️ GraphQL Mutations

Create Recognition

mutation {
  createRecognition(input: {
    fromId: "1"
    toId: "2"
    message: "Great work on the project!"
    emoji: "πŸ‘"
  }) {
    id
    message
    emoji
    from {
      name
    }
    to {
      name
    }
  }
}

Add Reaction

mutation {
  addReaction(input: {
    recognitionId: "1"
    userId: "3"
    emoji: "πŸŽ‰"
  }) {
    id
    emoji
    user {
      name
    }
  }
}

Add Comment

mutation {
  addComment(input: {
    recognitionId: "1"
    userId: "4"
    message: "I agree! Well done!"
  }) {
    id
    message
    user {
      name
    }
  }
}

πŸ“‘ Subscriptions

Real-time Recognition Updates

subscription {
  recognitionCreated {
    id
    message
    emoji
    from {
      name
    }
    to {
      name
    }
    createdAt
  }
}

Real-time Reaction Updates

subscription {
  reactionAdded {
    id
    emoji
    recognition {
      id
      message
    }
    user {
      name
    }
  }
}

πŸ§ͺ Testing

The project includes test files in the tests/ directory:

  • queries.graphql - Sample queries for testing
  • mutations.graphql - Sample mutations for testing
  • subscriptions.graphql - Sample subscriptions for testing

πŸ—οΈ Project Structure

employee-recognition-api/
β”œβ”€β”€ server.ts              # Main server file with GraphQL setup
β”œβ”€β”€ schema.graphql         # GraphQL schema definitions
β”œβ”€β”€ package.json           # Dependencies and scripts
β”œβ”€β”€ tsconfig.json          # TypeScript configuration
β”œβ”€β”€ public/                # Static files (custom UI)
β”‚   └── index.html         # Custom GraphQL interface
β”œβ”€β”€ tests/                 # Test files
β”‚   β”œβ”€β”€ queries.graphql
β”‚   β”œβ”€β”€ mutations.graphql
β”‚   └── subscriptions.graphql
└── README.md             # This file

πŸ”§ Development

Available Scripts

  • npm start - Start the server with ts-node
  • npm run dev - Start with nodemon for development
  • npm run build - Build TypeScript to JavaScript
  • npm test - Run Jest tests

Adding New Features

  1. Schema Changes: Update schema.graphql
  2. Resolvers: Add to the resolvers object in server.ts
  3. Validation: Add validation functions as needed
  4. Testing: Add test queries/mutations to the tests/ directory

πŸš€ Production Deployment

Environment Variables

  • PORT - Server port (default: 4000)
  • NODE_ENV - Environment (development/production)

Database Integration

The current implementation uses in-memory storage. For production:

  1. Replace the in-memory arrays with database calls
  2. Add proper authentication (JWT, OAuth, etc.)
  3. Implement proper error handling and logging
  4. Add rate limiting and security measures

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ†˜ Support

For issues and questions:

  1. Check the existing issues
  2. Create a new issue with detailed information
  3. Include error messages and steps to reproduce

Happy Coding! πŸŽ‰

About

Employee Recognition API is a GraphQL backend for sending recognition, reactions, and comments between employees in real time. Built with Apollo Server and TypeScript, it supports role-based access and WebSocket subscriptions. Perfect for internal tools or prototyping employee appreciation systems.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published