Code Monkey home page Code Monkey logo

job-leet-core-api's Introduction

Job Leet - Job Portal API

Welcome to Job Leet, your go-to job portal powered by the Job Leet Job Portal API. This project is built using .NET 8, Docker and MySQL, providing a robust REST API for job-related functionalities.

Find the Frontend Development repository of this project Here

Getting Started with Docker environment

Install Docker

  1. Create .env file in the root directory Fill the following information
MYSQL_DATABASE= DBName
MYSQL_PASSWORD= StrongPassword
  1. Rename appsettings.json to appsettings.Development.json Replace the following informatoin
"ConnectionStrings": {
    "jobleetconnect": "Server=sql_server;Database=<DBName>;User=<Username>;Password=<password>;Port=3306;AllowPublicKeyRetrieval=True;SslMode=None"
  },
  1. Navigate to the docker-compose.yml and check the credentials; It should match the credentials of jobleetconnect Note: The credentials in docker-compose.yml, .env and jobleetconnect must match.
 environment:
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: leetadmin
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}`
  1. Final step
docker-compose build && docker-compose up

and Access the service using

http://localhost:8080/api/v1/<endpoint>

Or

http://localhost:8080/swagger/index.html

Table of Contents

Getting Started In local environment

Prerequisites

Make sure you have the following installed on your system:

Clone and Build

Clone the repository:

git clone https://github.com/Nix-code/Job-Leet-core-api.git

Navigate to the project directory:

cd Job-Leet-core-api

Build the application: bash dotnet build

Configuration

Update the appsettings.json file with your MySQL database connection details. But we will be using appsettings.Development.json for our work.

Database

Job Leet uses a MySQL database to store job-related data. You can configure the database connection settings in the appsettings.json file.

Migrate the Database

dotnet add package Microsoft.EntityFrameworkCore.Design

Features

  • BaseAPIController
  • BaseDBContext
  • Input Validation
  • Data Validation
  • Database Migrations
  • Endpoints
  • Caching
  • Loggers
  • Authentication
  • Exceptions
  • SecurityHeaders
  • RateLimiter
  • Versioning
  • Jwt Tokens
  • Message Broker (RabbitMQ)
  • Documentations
  • Docker Container
  • CICD
  • Unit tests

Issues

If you encounter any issues or have suggestions, feel free to open an issue here

Contribution

We welcome contributions to make Job Leet even better! If you'd like to contribute, please follow the steps here

License

This project is licensed under the MIT License. Feel free to explore, contribute, and use Job Leet according to the terms of the license.

job-leet-core-api's People

Contributors

nixhantb avatar

Watchers

 avatar  avatar

job-leet-core-api's Issues

Create Base Entity for Job-Leet

Create a base entity to include common properties across multiple entities in the "Job-Leet" project. This will help adhere to the DRY (Don't Repeat Yourself) principle and provide a consistent structure for entities.

Details:

Base Entity Name: BaseEntity

Properties:

  • Id: An integer representing the unique identifier for the entity.
  • CreatedAt: A DateTime property representing the creation timestamp.
  • UpdatedAt: A DateTime property representing the last update timestamp.

Add any other common properties as needed.

Usage:

Entities in the project, such as the "Job" entity, will inherit from this base entity to include common properties.

Implementation Steps:

  • Create a new C# class named BaseEntity in the "JobLeet.Core.Entities" namespace.
  • Define the common properties (Id, CreatedAt, UpdatedAt, .....) in the BaseEntity class.

If you want to see the Entity information, Navigate Here
Ensure that entities like "Job" inherit from this base entity.

Additional Considerations:

Optionally, you can include a constructor in the BaseEntity class to set default values or handle common initialization logic.
Related Files/Folders:

JobLeet.Core.Entities/BaseEntity.cs

Maintain Directory convention with Correct Versioning

In the Interfaces folder, the versioning of entities follows a pattern of Entity -> Vx (Version). However, inside the Entities folder within JobLeet.Core, there are inconsistencies in versioning for some entities listed below.

  1. Accounts
  2. Common
  3. Companies
  4. Applications
  5. Seekers

Current Structure Example

├── Entities
│   ├── BaseEntity.cs
│   ├── Common
│   │   ├── V1
│   │   │   ├── Qualifications
│   │   │   │   ├── Education.cs
│   │   │   │   ├── Qualification.cs
│   │   │   │   ├── Skill.cs
│   │   │   ├── Shared
│   │   │   │   ├── Address.cs
│   │   │   │   ├── Date.cs
│   │   │   │   ├── PersonName.cs
│   │   │   │   ├── Phone.cs

Expected Behavior

├── JobLeet.Core
│   ├── Entities
│   │   ├── Common
│   │   │   ├── Address.cs
│   │   │   ├── Date.cs
│   │   │   ├── PersonName.cs
│   │   │   ├── Phone.cs
│   │   │   ├── Education.cs
│   │   │   ├── Qualification.cs
│   │   │   ├── Skill.cs


The reason for this is not to make structure too deep and complex and also get allign with common approach for Interfaces and other folders.

namespace should end with Vx for all except for BaseClass.

Example

  1. For Entities
    namespace JobLeet.WebApi.JobLeet.Core.Entities.Accounts.V1

  2. For Interfaces
    namespace JobLeet.WebApi.JobLeet.Core.Interfaces.Jobs.V1

Implement Centralized Error Message Management

Description:
Implement a centralized error message management system in the application to improve code maintainability and consistency. This system will involve storing error messages in a CSV file and retrieving them dynamically in the application code.
Tasks:

  • Create ErrorMessages.csv:
  • Create a CSV file named ErrorMessages.csv in the project directory.

The file should have the following structure:
Key,Message
FieldNotFound,The specified field was not found.
InvalidInput,The input provided is invalid.
UnauthorizedAccess,You do not have permission to access this resource.

Create ErrorMessages Class:

  • Create a static class named ErrorMessageManager to load and store error messages.
    
  • The class should read the ErrorMessages.csv file and store the messages in a dictionary.
    
  • Provide a method GetMessage(string key) to retrieve messages by key.
    

Modify Application Code:

Replace hard-coded error messages with calls to ErrorMessages.GetMessage(key) in the application code.
Ensure that appropriate keys are used for all error messages.

Actual : throw new Exception("The specified field was not found.");

Expectation: throw new Exception(ErrorMessages.GetMessage("FieldNotFound"));

Integrate Email Entity with RegisterUser and Standalone Email Entity

Currently, there is a need to integrate the Email entity within the RegisterUser entity while also maintaining a standalone Email entity for other functionalities, such as /email endpoints. This integration requires synchronization of EmailAddress updates between both contexts.

Acceptance Criteria

  • Email entity is correctly defined and configured for standalone usage.
  • RegisterUser entity includes an owned instance of Email entity.
  • Changes to EmailAddress in RegisterUser are synchronized to the standalone Email entity.

Implement Centralized Error Handling for Unhandled Exceptions

Description:

Implement a centralized error handling mechanism using middleware to catch and handle unhandled exceptions globally across the application.

Current Behavior:
Unhandled exceptions are causing 500 errors without providing meaningful error messages to the user.

Expected Behavior:
All unhandled exceptions should be caught by the centralized error handling middleware, logging the error details and returning a consistent error response to the client.

Proposed Solution:

  1. Implement a centralized error handling middleware to catch all unhandled exceptions.
  2. Log the error details.
  3. Return a consistent and meaningful error response to the client.

Establish Entity and Folder Structure

Create the entity and folder structure for the Job Portal API project, ensuring a well-organized and scalable layered architecture.

The Job Portal API project employs a well-organized and scalable layered architecture, reflecting industry best practices. The architecture is designed to enhance modularity, maintainability, and extensibility, adhering to the following key principles:

Separation of Concerns:

The layered structure divides the application into distinct concerns, such as API endpoints (JobPortal.Api), core business logic (JobPortal.Core), and data infrastructure (JobPortal.Infrastructure). This separation facilitates focused development and easier maintenance.

Scalability and Maintainability:

By organizing components into separate layers, the architecture promotes scalability, allowing each layer to evolve independently. The clear division of responsibilities enhances maintainability by isolating changes within specific areas of the application.

Reusability and Testing:

The use of entities, interfaces, and repositories in JobPortal.Core encourages code reusability. The modular nature of the architecture also facilitates unit testing of individual components, supporting robust software quality assurance practices.

Extensibility and Flexibility:

The layered structure accommodates future enhancements and modifications. New features can be added with minimal impact on existing functionality, fostering an agile and adaptable development process.
This architecture ensures that the Job Portal API project is well-prepared for current and future requirements, offering a robust foundation for development, scalability, and maintainability.

  • Providing the rough base project architecture for Job Leet API
  • Create Folders and DummyFIle.cs (Can change later based on requirements)
└── JobLeet.Api
    │   ├── Controllers
    │   │   └── // API controllers
    │   ├── Models
    │   │   └── // View models or DTOs
    │   ├── RateLimiting
    │   │   └── // Rate limiting middleware or configuration
    │   ├── Logging
    │   │   └── // Logging configuration and middleware
    │   ├── Caching
    │   │   └── // Caching configuration or middleware
    │   ├── ExceptionHandling
    │   │   └── // Exception handling middleware or filters
    │   ├── Security
    │   │   └── // JWT token implementation and authentication middleware
    │   ├── Versioning
    │   └── // API versioning configuration
    │   
    ├── JobLeet.Core
    │   ├── Entities
    │   │   └── // Business entities 
    │   ├── Interfaces
    │   └── Repositories
    │         └── // Repository interfaces
    │  
    ├── JobLeet.Infrastructure
    │   ├── Data
    │   │   ├── Contexts
    │   │   │   └── // Database context
    │   │   ├── Migrations
    │   │   │   └── // Database migration files
    │   │   └── // Database-related files
    │   ├── Repositories
    │   │   └── // Repository implementations
    │   └── // Other infrastructure-related files
    └── JobLeet.Tests
        ├── IntegrationTests
        │   └── // Integration tests
        ├── UnitTests
        └── // Unit tests
     

Implement JWT Token Generation

This story involves implementing JWT token generation in the LoginUserRepository of the JobLeet application. The JWT token will be returned upon successful login and will be used for authenticating subsequent requests.

Tasks:

Add JWT Dependencies:
Install the Microsoft.AspNetCore.Authentication.JwtBearer package.

Include the script to generate JWT secrct key and store that in jwtkey.key file
- Implement JwtHelper.cs file to generate the secret key
- Write a script to automatically create and add secret to jwtkey.key file

Modify LoginUserRepository:
Generate and return a JWT token upon successful login.

Update Models:
Add a Token property to the LoginUserModel to include the JWT in the login response.

Acceptance Criteria:
The JWT token should be generated and returned upon successful login.
The login response should include the generated JWT token.

Create README for JobLeet API Project

Description:

The README.md file for the Job Leet API project could benefit from some enhancements to improve clarity and readability. Below are the suggested changes:

Consistent Formatting:

Ensure consistent formatting across sections for better readability.

API Documentation Link:

Consider adding a direct link to the API documentation for detailed information on API endpoints.

Code Formatting:

Use code blocks in the Installation section to highlight commands and configurations.

Clarify Database Configuration:

Explicitly mention the configuration settings in the appsettings.json file that users need to update for their MySQL database.

Clarify API Versioning Methods:

Provide brief examples for each versioning method (Header Versioning, Query Parameter Versioning, Media Type Versioning).

Rate Limiter Configuration:

Include information on how users can customize rate limiter settings if needed.

Caching:

Add a section detailing how caching is implemented or configured in the project.

Logging Information:

Provide information on how logging is configured and utilized in the project.

Exception Handling:

Include details on how exceptions are handled in the API and any middleware or filters employed for this purpose.

Security Measures:

Detail the security measures in place, especially regarding JWT token implementation and authentication middleware.

Link to License File:

Add a link to the full text of the MIT License or mention that license details can be found in a separate LICENSE file.

Create Entities inside JobLeet.Core (Entity Version 0.1)

Currently, the structure of the project does not include a dedicated "Entities" folder directly inside the "JobLeet.Core" directory. This proposed change aims to enhance organization by introducing a central location for entity-related files.

(Add any additional context, reasoning, or considerations for this proposed change.)

Entity Description: Here



├── JobLeet.Core
│   ├── Entities
│   │   ├── BaseEntity.cs
│   │   ├── Common
│   │   │   ├── V1
│   │   │   │   ├── Qualifications
│   │   │   │   │   ├── Education.cs
│   │   │   │   │   ├── Qualification.cs
│   │   │   │   │   ├── Skill.cs
│   │   │   │   ├── Shared
│   │   │   │   │   ├── Address.cs
│   │   │   │   │   ├── Date.cs
│   │   │   │   │   ├── PersonName.cs
│   │   │   │   │   ├── Phone.cs
│   │   ├── Accounts
│   │   │   ├── V1
│   │   │   │   ├── Users
│   │   │   │   │   ├── Admin.cs
│   │   │   │   │   ├── Login.cs
│   │   │   │   │   ├── User.cs
│   │   │   │   ├── Roles
│   │   │   │   │   ├── Role.cs
│   │   ├── Companies
│   │   │   ├── V1
│   │   │   │   ├── Company.cs
│   │   │   │   ├── IndustryTypes
│   │   │   │   │   ├── IndustryType.cs
│   │   │   │   ├── Profiles
│   │   │   │   │   ├── CompanyProfile.cs
│   │   ├── Employers
│   │   │   ├── V1
│   │   │   │   ├── Employer.cs
│   │   ├── Jobs
│   │   │   ├── V1
│   │   │   │   ├── Applications
│   │   │   │   │   ├── Application.cs
│   │   │   │   │   ├── ApplicationDate.cs
│   │   │   │   ├── Statuses
│   │   │   │   │   ├── Status.cs
│   │   │   │   ├── Job.cs
│   │   ├── Seekers
│   │   │   ├── V1
│   │   │   │   ├── Seeker.cs

Better usage of Social Media in Seekers Api

Currently, the Seekers API supports only a single LinkedIn profile link. Users may want to add links to other social media platforms like Facebook, Twitter, GitHub, etc. Instead of having a single LinkedInProfile string property, we should support a more flexible and generic approach by using a list of social media links.

Actual Response

{ "linkedInProfile": "https://www.linkedin.com/in/sampleprofile", "portfolio": "https://www.sampleportfolio.com" }

Expected Response

{ "portfolio": "https://www.sampleportfolio.com", "socialMedia": [ { "platform": "LinkedIn", "url": "https://www.linkedin.com/in/sampleprofile" }, { "platform": "Facebook", "url": "https://www.facebook.com/sampleprofile" }, { "platform": "GitHub", "url": "https://www.github.com/sampleprofile" } ] }

Changes

  1. Replace the LinkedInProfile string property with a List property in the Seeker entity.
  2. Update the Seeker model to reflect the new socialMedia property.
  3. Create a SocialMedia class to represent social media links.
  4. Update the Entity Framework Core configuration to handle the new List property.
  5. Create and apply a new migration to update the database schema.

Create Base Repository for Common CRUD operation

-Create a generic base repository (BaseRepository) that includes common CRUD operations.

  • Utilize dependency injection to inject this repository where needed.
  • Allow for entity-specific repositories to inherit from the generic base repository.
  • Ensure that the generic repository is flexible enough to accommodate various entity types.

// JobLeet.Core/Interfaces/IRepository.cs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.