Skip to content

mathalama/career-navigator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Career Navigator - API

Career Navigator is a web application that helps users navigate their career paths through mentorship, job recommendations, and skill development resources.

Technology Stack

  • Java 17
  • Spring Boot 4.0.0
  • Spring Security with JWT authentication
  • Spring Data JPA with PostgreSQL
  • Spring Mail for email notifications
  • Maven for dependency management
  • Lombok for reducing boilerplate code

Features

  • User registration and authentication with JWT
  • Email verification system
  • Role-based access control (USER, ADMIN)
  • Mentor management and reviews
  • Job listings and recommendations
  • User profile management
  • CORS support for frontend integration

Prerequisites

Before running the application, ensure you have:

  • Java 17 or higher
  • Maven 3.6+
  • PostgreSQL 12+
  • Gmail account (for email functionality)

Project Structure

backend/
├── src/
│   ├── main/
│   │   ├── java/dev/mathalama/careernavigator/
│   │   │   ├── config/          # Security and application configuration
│   │   │   ├── controller/      # REST API endpoints
│   │   │   ├── dto/             # Data Transfer Objects
│   │   │   ├── entity/          # JPA entities
│   │   │   ├── exception/       # Global exception handling
│   │   │   ├── repository/      # Database repositories
│   │   │   └── service/         # Business logic
│   │   └── resources/
│   │       └── application.properties
│   └── test/                    # Test files
├── .env                         # Environment variables (not in repo)
├── pom.xml                      # Maven dependencies
└── README.md

Setup Instructions

1. Clone the Repository

git clone https://github.com/mathalama/career-navigator-api.git
cd career-navigator/backend

2. Setup PostgreSQL Database

Create a new database:

CREATE DATABASE career_navigator_db;

Or use Docker:

docker run --name career-nav-postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=career_navigator_db -p 5432:5432 -d postgres:15

3. Configure Environment Variables

Create a .env file in the backend root directory:

# Database Configuration
DATABASE_URL=jdbc:postgresql://localhost:5432/your_database
DATABASE_USERNAME=username
DATABASE_PASSWORD=password

# JWT Configuration
JWT_TOKEN=your-secret-key-here-minimum-32-characters-long

# Mail Configuration (Gmail)
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_EMAIL=your-email@gmail.com
MAIL_PASSWORD=your-app-password

# Application URLs
APP_BASE_URL=http://localhost:8080
FRONTEND_URL=http://localhost:5173

# CORS Configuration
CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000

Note: For Gmail, you need to create an App Password instead of using your regular password.

4. Install Dependencies

mvnw clean install

Or on Unix/Mac:

./mvnw clean install

5. Run the Application

Using Maven:

mvnw spring-boot:run

Or on Unix/Mac:

./mvnw spring-boot:run

The application will start on http://localhost:8080

6. Verify Installation

Check if the server is running:

curl http://localhost:8080/api/auth/verify-email?token=test

You should receive a response indicating the token is invalid (which is expected).

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/verify-email?token= - Verify email
  • POST /api/auth/resend-verification - Resend verification email

Profile

  • GET /api/profile/me - Get current user profile
  • PUT /api/profile/me - Update user profile

Jobs

  • GET /api/jobs - Get all jobs
  • GET /api/jobs/{id} - Get job by ID

Mentors

  • GET /api/mentors - Get all mentors
  • GET /api/mentors/{id} - Get mentor by ID

Reviews

  • GET /api/reviews/mentor/{mentorId} - Get reviews for mentor
  • POST /api/reviews - Create review (authenticated)
  • PUT /api/reviews/{id} - Update review (authenticated)
  • DELETE /api/reviews/{id} - Delete review (authenticated)

Admin (Admin role required)

  • GET /api/admin/users - Get all users
  • DELETE /api/admin/users/{id} - Delete user

Development

Running Tests

mvnw test

Building for Production

mvnw clean package

The JAR file will be created in the target/ directory.

Running the JAR

java -jar target/career-navigator-0.0.1-SNAPSHOT.jar

Configuration

Key configuration properties in application.properties:

  • Database: JPA with Hibernate auto-update enabled
  • JWT: Token expiration set to 24 hours
  • Mail: SMTP with TLS enabled
  • CORS: Configurable allowed origins
  • Security: Public endpoints for auth and mentor reviews

Security

  • Passwords are encrypted using BCrypt
  • JWT tokens for stateless authentication
  • CSRF protection disabled (JWT-based API)
  • Role-based authorization (USER, ADMIN)
  • Email verification required for new accounts

Troubleshooting

Database Connection Issues

  • Check PostgreSQL is running: psql -U postgres
  • Verify database exists: \l in psql
  • Check connection string in .env

Email Not Sending

  • Verify Gmail App Password is correct
  • Check SMTP settings in .env
  • Ensure "Less secure app access" or App Passwords enabled

JWT Token Issues

  • Ensure JWT_TOKEN in .env is at least 32 characters
  • Token expires after 24 hours

Environment Variables Reference

Variable Description Example
DATABASE_URL PostgreSQL JDBC URL jdbc:postgresql://localhost:5432/your_database
DATABASE_USERNAME Database username postgres
DATABASE_PASSWORD Database password postgres
JWT_TOKEN Secret key for JWT signing (min 32 chars) your-secure-secret-key-here
MAIL_HOST SMTP server host smtp.gmail.com
MAIL_PORT SMTP server port 587
MAIL_EMAIL Sender email address your-email@gmail.com
MAIL_PASSWORD Email password or app password your-app-password
APP_BASE_URL Backend base URL http://localhost:8080
FRONTEND_URL Frontend application URL http://localhost:5173
CORS_ALLOWED_ORIGINS Allowed CORS origins (comma-separated) http://localhost:5173,http://localhost:3000

License

This is an educational project.

Contact

For questions or issues, please contact the development team.

About

Career Navigator API - RESTful backend service for intelligent career path recommendations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors