This repository contains the backend API for the Jennie AI project, used to interact with various endpoints for testing and development purposes. You can also find the frontend code for this project in the Jennie Frontend Repository.
Additionally, you can access the complete API documentation here.
- Technologies Used
- Getting Started
- Environment Setup
- Running the Application
- Available Endpoints
- Testing the API
- Contributing
- License
The backend for Jennie AI is powered by Django and utilizes the following packages:
- Django 4.2.15
- Django REST Framework 3.15.2
- Simple JWT 5.3.1
- Django CORS Headers 4.4.0
- Django Ratelimit 4.1.0
- Django Redis 5.4.0
- Django Storages 1.14.4
- Celery
- Python-dotenv
- Flask 3.0.3
- Flask-CORS 4.0.1
- Gunicorn
- Psycopg2 2.9.9
- Google API Libraries (Generative AI, Authentication, etc.)
For a complete list of dependencies, refer to the requirements.txt
file.
Before starting, make sure you have the following installed:
- Python (version 3.8+)
- PostgreSQL
- Redis (optional, if using Celery)
- Virtualenv
-
Clone the Repository
Clone the project repository from GitHub:
git clone https://github.com/philiptitus/vectorapi.git cd vectorapi
-
Create a Virtual Environment
Set up a Python virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install Dependencies
Install the necessary project dependencies:
pip install -r requirements.txt
-
Set Up Environment Variables
Create a
.env
file in the project root directory with the following variables:DJANGO_SECRET_KEY=your-secret-key DJANGO_DEBUG=True # Set to False in production DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1 DB_NAME=your_db_name DB_USER=your_db_user DB_PASSWORD=your_db_password DB_HOST=localhost DB_PORT=5432 GOOGLE_API_KEY=your-google-api-key YOUTUBE_API_KEY=your-youtube-api-key GOOGLE_SEARCH_API_KEY=your-google-search-api-key GOOGLE_CUSTOM_SEARCH_ENGINE_ID=your-custom-search-engine-id [email protected] EMAIL_HOST_PASSWORD=your-email-password # Optional Celery settings # CELERY_BROKER_URL=redis://localhost:6379/0 # CELERY_RESULT_BACKEND=redis://localhost:6379/0
-
Apply Migrations
Run database migrations:
python manage.py migrate
-
Create a Superuser
Set up an admin user for the Django admin interface:
python manage.py createsuperuser
-
Collect Static Files
Collect static assets:
python manage.py collectstatic
-
Start the Development Server
Run the application locally using the Django development server:
python manage.py runserver
The app will be available at
http://localhost:8000
. -
Start Celery Worker (Optional)
If you're using Celery for background tasks, you can start the worker with:
celery -A jennie worker --loglevel=info
-
Production with Gunicorn
For production, you can serve the application using Gunicorn:
gunicorn jennie.wsgi:application --bind 0.0.0.0:8000
Here are the primary API endpoints available:
- Login:
POST /api/users/login/
- Register:
POST /api/users/register/
- Get Profile:
GET /api/users/profile/
- Update Profile:
PUT /api/users/profile/update/
- Delete Account:
DELETE /api/users/delete/
- Password Reset Request:
POST /api/users/password-reset/
- Password Reset Confirmation:
POST /api/users/password-reset-confirm/<uidb64>/<token>/
- Set New Password:
POST /api/users/set-new-password/
- Latest Interview Session:
GET /api/v1/latest/
- Answer List:
GET /api/v1/answers/
- Notification List:
GET /api/v1/notifications/
- Check Session Expired:
GET /api/v1/expired/
- Run Code:
POST /api/v1/run/
- Get Code:
GET /api/v1/code/
- Get Agent:
GET /api/v1/agent/
- Preparation Material List:
GET /api/v1/materials/
- Job List:
GET /api/v1/jobs/
- Create Job:
POST /api/v1/jobs/create/
- Create Interview:
POST /api/v1/interviews/create/
- User Interviews:
GET /api/v1/interviews/
You can test the API locally or on the deployed server.
-
Local Testing: Use tools like Postman or
curl
for testing. -
Deployed Server: If you prefer, you can test the deployed version of the API using the following base URL:
https://jennie-1720624972853.ue.r.appspot.com
-
Import Endpoints: Create a collection in Postman and add the API endpoints with their corresponding request methods (GET, POST, PUT, DELETE).
-
JWT Authentication: For protected routes, obtain a JWT token by logging in via the
/api/users/login/
endpoint. Include the token in theAuthorization
header:Authorization: Bearer <your-jwt-token>
-
Sample Request: Example of retrieving the latest interview session:
GET https://jennie-1720624972853.ue.r.appspot.com/api/v1/latest/
We welcome contributions! Feel free to fork this repository, make improvements, and submit pull requests. Any contributions are greatly appreciated.
This project is licensed under the MIT License. See the LICENSE file for more details.
© 2024 Philip Titus