Skip to content

debelio/personal-api-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

Devbox AWS SAM Python License

Personal API - Serverless Resume Endpoint

A serverless Personal/CV PoC API built with AWS Lambda, API Gateway, and Python with automated deployment and API key management.

πŸš€ Features

  • Serverless Architecture: Built with AWS Lambda and API Gateway
  • RESTful API Design: Clean, intuitive endpoints with API key authentication
  • CORS Enabled: Frontend-friendly with proper CORS headers
  • Search Functionality: Search through CV content
  • Modular Data Access: Different endpoints for different CV sections
  • Infrastructure as Code: SAM template for easy deployment
  • Automated Deployment: Complete deployment script with API key management
  • Cost Effective: Runs entirely within AWS free tier limits

πŸ“‹ API Endpoints

All endpoints require API key authentication via the x-api-key header.

Endpoint Method Description
/ or /cv GET Get complete CV data
/cv/personal GET Get personal information only
/cv/experience GET Get work experience
/cv/education GET Get education information
/cv/skills GET Get technical skills
/cv/projects GET Get project portfolio
/cv/summary GET Get professional summary
/cv/certifications GET Get certifications
/cv/languages GET Get languages spoken
/cv/achievements GET Get achievements
/cv/interests GET Get interests and hobbies
/cv/search?q=keyword GET Search through CV content

πŸ› οΈ Technology Stack

  • Backend: Python 3.12
  • Cloud Services: AWS Lambda, API Gateway
  • Infrastructure: AWS SAM (Serverless Application Model)
  • Deployment: AWS CloudFormation
  • API Security: API Gateway API Keys and Usage Plans

πŸ“ Project Structure

personal-api/
β”œβ”€β”€ src/
β”‚   └── lambda_function.py      # Main Lambda function
β”œβ”€β”€ .envrc                      # direnv environment configuration
β”œβ”€β”€ devbox.json                 # devbox development environment
β”œβ”€β”€ devbox.lock                 # devbox lockfile
β”œβ”€β”€ deployment.sh               # Automated deployment script
β”œβ”€β”€ template.yaml               # SAM template (production)
β”œβ”€β”€ template-local.yaml         # SAM template for local testing
β”œβ”€β”€ samconfig.toml             # SAM configuration
└── README.md                   # This file

πŸš€ Getting Started

Prerequisites

  • AWS Account (free tier eligible)
  • AWS CLI configured with appropriate permissions
  • SAM CLI installed
  • Python 3.12+
  • jq (optional, for better JSON parsing)

Development Environment

This project uses devbox and direnv for consistent development environments.

Setup Development Environment

  1. Install devbox

    curl -fsSL https://get.jetpack.io/devbox | bash
  2. Install direnv

    # For Ubuntu/Debian
    sudo apt-get install direnv
    
    # For other distributions, visit: https://direnv.net/docs/installation.html
  3. Configure direnv Add to your ~/.bashrc or ~/.zshrc:

    eval "$(direnv hook bash)"  # or zsh
  4. Clone the repository and set up environment

    git clone https://github.com/yourusername/personal-api.git
    cd personal-api
  5. Allow direnv

    direnv allow

Now your development environment will automatically load the correct dependencies when you enter the project directory.

πŸš€ Quick Deployment

Using the Automated Deployment Script

The project includes a comprehensive deployment.sh script that handles the complete deployment lifecycle:

# Make the script executable
chmod +x deployment.sh

# Deploy the application (interactive)
./deployment.sh deploy

# Or use the interactive menu
./deployment.sh

Available Commands

./deployment.sh deploy    # Deploy application with optional API key creation
./deployment.sh destroy   # Complete cleanup of all resources
./deployment.sh newkey    # Create additional API keys for existing deployment
./deployment.sh           # Interactive menu

Manual Deployment (Alternative)

  1. Update CV data

  2. Test locally

    sam build
    sam local start-api -t template-local.yaml
  3. Deploy to AWS

    sam build
    sam deploy --config-file samconfig.toml

πŸ§ͺ Testing

Test API Endpoints

After deployment using deployment.sh, you'll receive an API key. Test your endpoints:

# Example with your API key
curl -H "x-api-key: YOUR_API_KEY" https://your-api-id.execute-api.eu-west-1.amazonaws.com/Stage/cv

# Test specific endpoints
curl -H "x-api-key: YOUR_API_KEY" https://your-api-id.execute-api.eu-west-1.amazonaws.com/Stage/cv/skills
curl -H "x-api-key: YOUR_API_KEY" https://your-api-id.execute-api.eu-west-1.amazonaws.com/Stage/cv/search?q=python

πŸ”§ Configuration

SAM Configuration

The samconfig.toml file contains deployment settings:

  • Stack name: personal-api
  • Region: eu-west-1
  • Stage: Stage

API Security

  • All endpoints require API key authentication
  • Usage plans limit requests to 1000/month with 10 requests/second rate limit
  • Burst limit of 20 requests

πŸ”‘ API Key Management

Creating API Keys

The deployment.sh script automatically handles API key creation:

  1. During initial deployment: Script prompts to create an API key
  2. Create additional keys: Use ./deployment.sh newkey
  3. Automatic usage plan linking: Keys are automatically associated with usage plans

Usage Plan Limits

  • Monthly quota: 1000 requests
  • Rate limit: 10 requests per second
  • Burst limit: 20 requests

πŸ“Š Monitoring

  • CloudWatch Logs: Automatic logging for Lambda function
  • CloudWatch Metrics: Monitor invocation count, duration, errors
  • API Gateway Metrics: Track API usage, throttling, and errors
  • Usage Plan Monitoring: Track API key usage against quotas

🧹 Cleanup

To completely remove all resources:

./deployment.sh destroy

This will:

  • Delete the CloudFormation stack
  • Remove all usage plans
  • Delete all associated API keys
  • Clean up all AWS resources

πŸ”§ Customization

Adding New Endpoints

  1. Add route handling in src/lambda_function.py
  2. Update the template.yaml with new API Gateway events
  3. Redeploy using ./deployment.sh deploy

Modifying CV Data

Edit the CV_DATA dictionary in src/lambda_function.py with your personal information.

🚨 Troubleshooting

Debugging

  • Check CloudWatch logs for Lambda function errors
  • Use sam local start-api for local testing
  • Review API Gateway logs for request/response issues

🌟 Future Enhancements

  • CI/CD Pipeline: GitHub Actions or AWS CodePipeline integration
  • DynamoDB Integration: Store CV data in DynamoDB for dynamic updates
  • API Versioning: Support for multiple API versions
  • Frontend Integration: React/Vue.js frontend dashboard
  • Enhanced Monitoring: Custom CloudWatch dashboards and alarms

πŸ“ License

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

🀝 Contributing

This is a proof-of-concept project created for demonstration purposes. Feel free to fork and modify according to your needs.

About

A serverless Personal/CV PoC API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors