- Python 3.x
- MongoDB
- Google OAuth2 credentials
- IDE (VS Code recommended)
Follow these steps to set up the project:
-
Fork and Clone the Repository
- Fork the repository to your GitHub profile.
- Clone the forked repository to your local machine.
git clone https://github.com/your-username/Beehive.git
-
Open the Project in Your IDE
- Open the project in your favorite IDE, such as Visual Studio Code or PyCharm.
-
Create a Virtual Environment
- Navigate to the project directory and create a virtual environment.
python -m venv venv
-
Activate the Virtual Environment
- Activate the virtual environment.
.\venv\Scripts\activate
source venv/bin/activate
-
Install Required Libraries
- Install all the libraries listed in
requirements.txt.
pip install -r requirements.txt
- Install all the libraries listed in
-
Configure Environment Variables
- Rename
.env.exampleto.env. - Rename
client_secret_example.jsontoclient_secret.json.
- Rename
-
Create Google OAuth API Key
- Create a Google OAuth API key.
- Download the
client_secret.jsonfile and place it in the project directory. - Update your Google Cloud Console to include the new redirect URI:
http://localhost:5000/login/google/callback
-
Update
.envFile- Open the
.envfile and add the required credentials.
MONGODB_CONNECTION_STRING=mongodb://... GOOGLE_CLIENT_ID=your-client-id GOOGLE_CLIENT_SECRET=your-client-secret REDIRECT_URI=http://localhost:5000/admin/login/callback ADMIN_EMAILS=admin1@example.com,admin2@example.comNOTE: Add or modify the ADMIN_EMAILS variable with comma-separated emails.Make sure there are no spaces before or after the commas.
- Open the
-
Run the Application
- Execute the
app.pyfile to run the application.
python app.py
- Execute the
The application expects certain directories to exist for proper operation:
static/uploads- For general file uploadsstatic/uploads/profile- For user and admin profile photosstatic/uploads/thumbnails- For PDF thumbnails
These directories will be created automatically if they don't exist, but for proper deployment you may want to ensure they're included in your repository or created during setup.
- Setup Guide for Running Flask with MongoDB in Docker
This guide will help you set up and run your Flask application with MongoDB inside Docker using docker-compose.
Before you begin, ensure you have installed:
- Docker: Download here
- Run the following command to build and start the containers:
docker-compose up --buildThis will start both Flask and MongoDB.
Flask will be available at http://localhost:5000.
MongoDB will run inside Docker and be accessible on port 27017.
To check if MongoDB is running inside Docker:
docker psTo enter the MongoDB container and check data:
docker exec -it mongodb mongoshIf you want to use MongoDB Compass, connect to:
mongodb://localhost:27017
To stop the containers:
docker-compose downThis will stop and remove the containers, but data will persist due to the volume (mongo-data).
You have successfully set up Flask with MongoDB in Docker!
Now, every time you want to run your project, just use:
docker-compose upBy following these steps, you will have the project set up and ready to use.