A Django REST API backend for AI-powered CV optimization and improvement services. The platform allows users to submit questionnaires with their career information and receive AI-generated, optimized CVs tailored to specific job applications.
-
User Authentication & Authorization
- JWT-based authentication
- Google OAuth integration
- User profiles with subscription management
-
AI-Powered CV Generation
- OpenAI GPT-4 integration for CV optimization
- PDF resume upload and text extraction
- Questionnaire-based job targeting
- Markdown to PDF conversion for generated CVs
-
Subscription Management
- Stripe integration for payments
- Multiple subscription plans (Free, Basic, Pro, Premium)
- Webhook handling for subscription events
- Billing portal integration
-
Background Tasks
- Celery for asynchronous task processing
- Redis as message broker and cache
- Scheduled tasks with Celery Beat
-
API Documentation
- OpenAPI 3.0 schema
- Interactive Swagger UI
- Comprehensive endpoint documentation
- Backend: Django 5.2.1 + Django REST Framework
- Database: PostgreSQL
- Cache/Queue: Redis
- Task Queue: Celery with Eventlet
- AI: OpenAI GPT-4
- Payments: Stripe
- PDF Processing: WeasyPrint, PyPDF2
- Containerization: Docker + Docker Compose
- Deployment: PM2, GitHub Actions
- Python 3.11+
- Docker & Docker Compose
- PostgreSQL (or use Docker)
- Redis (or use Docker)
- OpenAI API key
- Stripe account (for payments)
-
Clone the repository
git clone <repository-url> cd cvimprover-api
-
Create environment file
cp .env.example .env
-
Configure environment variables
# Django SECRET_KEY=your-secret-key DEBUG=True # Database DB_NAME=cvimprover DB_USER=postgres DB_PASSWORD=password DB_HOST=postgres_master DB_PORT=5432 # Redis & Celery CELERY_BROKER_URL=redis://redis:6379/0 CELERY_RESULT_BACKEND=redis://redis:6379/0 CACHE_URL=redis://redis:6379/1 # OpenAI OPENAI_API_KEY=your-openai-api-key # Stripe STRIPE_SECRET_KEY=your-stripe-secret-key STRIPE_PUBLISHABLE_KEY=your-stripe-publishable-key STRIPE_WEBHOOK_SECRET=your-webhook-secret # Google OAuth GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret # CORS CORS_ALLOWED_ORIGINS=http://localhost:3000 FRONTEND_URL=localhost:3000 BACKEND_URL=localhost:8000
-
Start the services
docker-compose up -d
-
Run migrations and create superuser
docker-compose exec web python manage.py migrate docker-compose exec web python manage.py createsuperuser docker-compose exec web python manage.py seed_plans
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up database
python manage.py migrate python manage.py seed_plans
-
Start Redis and Celery
# Terminal 1: Redis redis-server # Terminal 2: Celery Worker celery -A cvimprover worker --loglevel=info # Terminal 3: Celery Beat celery -A cvimprover beat --loglevel=info
-
Start Django server
python manage.py runserver
The API provides the following main endpoints:
-
Authentication:
/auth/
- User registration, login, logout
- Google OAuth integration
- JWT token management
-
CV Management:
/cv/
- Questionnaire submission
- AI response generation
- PDF generation from AI responses
-
Subscription Management:
/core/
- Plan listing
- Checkout session creation
- Billing portal access
- Webhook handling
-
Create a questionnaire
curl -X POST http://localhost:8000/cv/questionnaire/ \ -H "Authorization: Bearer <your-jwt-token>" \ -H "Content-Type: application/json" \ -d '{ "position": "Software Engineer", "industry": "Technology", "experience_level": "3-5", "company_size": "medium", "application_timeline": "1-3 months", "job_description": "Looking for a full-stack developer..." }'
-
Generate AI response
curl -X POST http://localhost:8000/cv/ai-responses/ \ -H "Authorization: Bearer <your-jwt-token>" \ -H "Content-Type: application/json" \ -d '{ "questionnaire": 1, "prompt": "Please optimize my CV for this software engineering position" }'
Run the test suite:
# Using Docker
docker-compose exec web python manage.py test
# Local development
python manage.py test
Access the interactive API documentation at:
- Swagger UI:
http://localhost:8000/
- OpenAPI Schema:
http://localhost:8000/schema/
- Create a Stripe account and get your API keys
- Set up webhook endpoint:
your-domain/core/payments/webhook/stripe/
- Configure subscription plans in Django admin or using the seeder
- Get your OpenAI API key from the OpenAI platform
- Add it to your environment variables
- The system uses GPT-4 for CV optimization
- Create a Google Cloud project
- Configure OAuth 2.0 credentials
- Add authorized redirect URIs
- Set the client ID and secret in environment variables
The project includes PM2 configuration for production deployment:
# Start all services
pm2 start ecosystem.prod.config.js
# Monitor services
pm2 monit
# View logs
pm2 logs
Automated deployment is configured via GitHub Actions:
- Tests run on pull requests
- Automatic deployment to production on main branch pushes
cvimprover-api/
โโโ core/ # Core app (users, plans, payments)
โ โโโ models.py # User and Plan models
โ โโโ views.py # Authentication and payment views
โ โโโ serializers.py # API serializers
โโโ cv/ # CV management app
โ โโโ models.py # Questionnaire and AI Response models
โ โโโ views.py # CV-related API endpoints
โ โโโ serializers.py # CV serializers
โโโ cvimprover/ # Main project settings
โ โโโ settings.py # Django configuration
โ โโโ urls.py # URL routing
โ โโโ celery.py # Celery configuration
โโโ docker-compose.yml # Docker services configuration
โโโ Dockerfile # Docker image definition
โโโ requirements.txt # Python dependencies
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the API documentation
- Review the logs:
docker-compose logs web
- Open an issue on GitHub
- Additional AI model integrations
- Cover letter generation
- LinkedIn profile optimization
- Interview preparation features
- Multi-language support
- Advanced analytics dashboard
Built with โค๏ธ using Django and modern web technologies.