DEMO: https://demo-pynextstack.reactatomics.com
Username: root
Password: bringthemhome
For the DEMO, only one root user can be logged in at a time. Therefore, it is recommended to register your own user first and then promptly log in as the root user to change your role. Otherwise, you might cause each other to be disconnected while trying the demo.
Please note that in the demo version, ChatGPT will not function as it is not connected to the API. Additionally, you have the option to modify the SMTP settings to suit your needs for testing the forgot-password functionality. It has been successfully tested with GMAIL. Later on, I will disable the edit functionality and added my own SMTP settings for your testing convenience for now just use it as it please.
PyNextStack is a full-stack system utilizing FastAPI with asynchronous capabilities on the backend and Next.js for the frontend showcases the robustness of Python in server-side development. This architecture provides a scalable, efficient solution that leverages FastAPI's high performance and ease of use for creating APIs, alongside Next.js for a reactive and server-side rendered user interface. The asynchronous nature of the backend ensures non-blocking operation, enhancing the system's ability to handle high volumes of requests simultaneously, which is ideal for real-time applications. This combination offers a modern, full-stack framework that is both powerful and developer-friendly, demonstrating the versatility of Python in web development.
- JWT Authentication: Secure authentication mechanism using JWT to ensure that user actions are verified and secure.
- Protected API Documentation: Access to API documentation is restricted, requiring authentication to prevent unauthorized use.
- Rate Limiting: Defense against brute force attacks by limiting the number of login attempts.
- Data Encryption: Encryption techniques are employed to securely store user data.
- Registration and Login: Efficient and secure processes for user registration and login.
- Profile Management: Enables users to update their profiles and manage account settings.
- ChatGPT Integration: Enhances user engagement with AI-driven chat support.
- Email Notifications: Sends automated emails for actions such as registration and password resets using SMTP.
- Next.js and MUI: A modern, responsive UI built with Next.js and Material-UI for a seamless user experience.
- Responsive Design: Ensures a consistent experience across various devices and screen sizes.
- Asynchronous Support: Utilizes FastAPI's async features for efficient performance.
- Scalable Architecture: Designed to handle growth in users and data smoothly.
- Comprehensive Logging: Detailed logging for user actions, system events, and errors.
- Real-Time Monitoring: Tools and practices in place for monitoring application performance in real-time.
- FastAPI: For building the high-performance API backend.
- Next.js: The React framework for building the frontend.
- Material-UI (MUI): For designing the frontend with React UI components.
- MongoDB: As the NoSQL database for user data.
- Redis: For rate limiting and JWT token management.
- Docker: For containerizing and deploying the application.
- Python-JOSE: A library for JWT operations.
- SMTP Libraries: For sending automated email notifications.
Before you begin, ensure you have met the following requirements:
-
Docker: This project is containerized with Docker, making it necessary to have Docker Desktop (for Windows or Mac) or Docker Engine (for Linux) installed on your system. To install Docker, follow the instructions on the official Docker website.
-
Python: The project requires the latest version of Python for certain local scripts and integrations. To install Python, visit the official Python website and download the latest version for your operating system. Ensure that Python is properly added to your system's PATH to allow for command-line execution.
Once you have Docker and Python installed, you're ready to proceed with the project setup. The next sections will guide you through configuring your development environment, running the project with Docker, and executing any necessary Python scripts or commands.
git clone https://github.com/georgekhananaev/PyNextStack
- create "chatgpt_credentials.env" file or revise the code in "generate_env.py".
- Example of chatgpt_credentials.env:
open_ai_organization=org-your_openai_key open_ai_secret_key=sk-your_openai_key
- Run the Installation.
- PowerShell / Linux (Option 1)
python generate_env.py ; docker-compose build --no-cache ; docker-compose up -d
- CMD (Option 2)
python generate_env.py && docker-compose build --no-cache && docker-compose up -d
- Manual (Option 3)
python generate_env.py
docker-compose build --no-cache
docker-compose up -d
docker-compose down -v
Just the FastApi server. You must start mongodb server, redis server first. Change the username and password uri in the .env file above.
Create a .env File or Run `python generate_env.py`
# mongodb connection
mongodb_server=localhost
mongodb_port=27017
mongodb_username=bringthemhome
mongodb_password=bringthemhome
# fastapi
fastapi_ui_username=bringthemhome
fastapi_ui_password=bringthemhome
jwt_secret_key=bringthemhome
static_bearer_secret_key=bringthemhome
algorithm=HS256
# chatgpt
open_ai_organization=org-your_openai_key
open_ai_secret_key=sk-your_openai_key
# default root user
owner_username=root
owner_password=bringthemhome
owner_email=israel@israeli.com
# Initial email settings located in app/components/initial settings.py
Please note: mongodb uri should be "localhost" if you running it locally, or "mongodb" if you running it inside a docker container
-
Update PIP && Install requirements.txt
python.exe -m pip install --upgrade pip
pip install -r requirements.txt
-
Start FastAPI server with Uvicorn
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
You need to have Node.js installed on your machine. Visit https://nodejs.org/ to download and install the latest version.
Create a .env File If Necessary; Otherwise, Default Settings Are Loaded
# Set the URL for your backend here
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000/api/v1
# The default value is 'bringthemhome'. Ensure this matches the 'static_bearer_secret_key' set in your backend.
NEXT_PUBLIC_API_KEY=static_bearer_secret_key
Please note: If you are running MongoDB locally, the URI should be set to "localhost". If you are running MongoDB inside a Docker container, the URI should be set to "mongodb". container
-
For Development:
npm install
npm run dev
-
For Production:
npm run build
npm start
- Frontend: http://localhost:3000
Username: root Password: bringthemhome
- Access the API documentation at http://localhost:8000/docs. You can obtain a token by entering your username and password from the text box above.
- Please note that the Swagger UI is also password-protected, and it will temporarily block access if the password is entered incorrectly more than five times, for a duration of five minutes.
Username: bringthemhome Password: bringthemhome
This application implements advanced security practices including password hashing, token validation, rate limiting, and secure API documentation access.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Developed by George Khananaev.
- Thanks to the FastAPI, MongoDB, Redis, and Docker communities for support and resources.
If you have ideas on how we can grow it into something greater, please share your suggestions. Additionally, if you have any special requests or unique features you'd like to see implemented, feel free to include those as well.
Upon reaching 100 stars, the project will incorporate the following features:
- Firebase authentication support will be integrated.
- Two-Factor Authentication will be implemented.
- SMS and WhatsApp support will be added to the backend with TWILIO.
- File handling capabilities, utilizing either Google Storage or AWS.
- Enhanced email handling, including functionalities such as Inbox, Outgoing, Draft, etc.
If you find my work helpful, consider supporting me by buying me a coffee at Buy Me A Coffee.
Your support helps me continue to create and maintain useful projects.
Thank you!