This project showcases the process of translating a Python-based backend application into Node.js and enhancing it with Redis for improved performance. It serves as a comprehensive demonstration for the backend session of the AI4Devs Master program.
This repository demonstrates the step-by-step translation of a Python Flask backend application into a Node.js application using TypeScript and Sequelize. Additionally, it integrates Redis to implement a distributed caching system, enhancing the application's performance and scalability.
- Language Translation: Convert the backend from Python to Node.js while maintaining functionality and structure.
- Performance Enhancement: Integrate Redis to implement caching mechanisms, reducing database load and improving response times.
- Best Practices: Apply software development best practices throughout the migration and enhancement process.
- Backend Frameworks:
- Python: Flask
- Node.js: Express.js with TypeScript
- Database:
- PostgreSQL
- ORM: Sequelize (for Node.js), SQLAlchemy (for Python)
- Caching:
- Redis
- Containerization:
- Docker & Docker Compose
- Others:
- TypeScript, Sequelize-Typescript, dotenv
The initial Python-based backend application using Flask. It includes:
- Flask Application: Handles HTTP requests and interacts with the PostgreSQL database.
- SQLAlchemy ORM: Manages database models and migrations.
- Docker Setup: Contains
Dockerfile
anddocker-compose.yml
for containerization.
This branch/project focuses on translating the Python Flask application to a Node.js application. Key features include:
- TypeScript Integration: Ensures strong typing and better code maintainability.
- Sequelize ORM: Manages database interactions with PostgreSQL.
- Express.js: Serves as the web framework for handling routes and middleware.
- Docker Configuration: Updated to accommodate Node.js environment.
A fully functional version of this translation is available in the starter-to-node-working directory.
Building upon the Node.js translation, this phase integrates Redis to implement a distributed caching system. Enhancements include:
- Redis Integration: Implements caching for product data to enhance performance.
- Cache Management: Ensures cache invalidation upon creating, updating, or deleting products.
- Docker Update: Adds Redis service to the
docker-compose.yml
for seamless integration.
The enhanced version with Redis is available in the starter-to-node-redis directory.
Follow these instructions to set up and run the project locally.
- Docker & Docker Compose
-
Clone the Repository
git clone https://github.com/your-username/ai4devs-backend-demo.git cd ai4devs-backend-demo
-
Navigate to the First Project Phase
- Python Starter:
starter/
- Python Starter:
-
Set Up the Starter Project
You have the readme.md of this project with the instructions to run it.
-
Testing prompts: Python to Node.js
To accompplish the first goal you have all the prompts used to guide the AI along the way. Also, all the most frequet errors faced during the process.
If you're facing any issue with the starter-to-node-working project, you can find the solution here.
-
Testing prompts: Adding Redis
To accompplish the second goal you have all the prompts used to guide the AI along the way. Also, all the most frequet errors faced during the process.
If you're facing any issue with the starter-to-node-redis project, you can find the solution here.