A Flask web application demonstrating the transition from a single-file handler architecture to a modular and scalable Flask project structure using MongoDB with MongoEngine.
check the preview of my site on this link. It takes few seconds to load since its a free tier of hosting and spin down after 50 seconds of inactivity https://blog-of-gg.onrender.com
This project was originally implemented as a small Flask application with all logic inside a single handler file. As the project grew, it was refactored into a structured architecture using the Application Factory pattern and Flask Blueprints to improve maintainability, scalability, and code organization.
The application includes basic authentication features and a blog system, while integrating MongoDB for data storage.
- Modular Flask architecture
- Application Factory pattern
- Blueprint-based routing
- MongoDB integration using MongoEngine
- User authentication (Login, Register, Forgot Password)
- Blog post management
- Jinja2 templating
- Organized static assets (CSS, JS, images)
ideal-spoon-with-mongodb/
│
├── app/ # Main application package
│ ├── __init__.py # Application Factory (create_app)
│ ├── models.py # MongoEngine schemas (User, BlogPost)
│ │
│ ├── routes/ # Blueprints
│ │ ├── auth/
│ │ │ ├── routes.py # Login, Register, Forget Password
│ │ │ └── forms.py # WTForms for authentication
│ │ │
│ │ └── main/
│ │ └── routes.py # Home, Blog posts, error handlers
│ │
│ ├── static/ # CSS, JavaScript, Images
│ ├── templates/ # Jinja2 HTML templates
│ └── utils/ # Helper utilities (Gravatar, decorators)
│
├── config.py # Application configuration (MongoDB URI)
├── run.py # Entry point to start the Flask server
├── requirements.txt # Project dependencies
└── .gitignore # Ignored files (venv, cache, etc.)
git clone https://github.com/GG-Ranjeet/Blogging-Website-Between-Semester.git
cd Blogging-Website-Between-Semesterpython -m venv .venvActivate it:
Windows for cmd
.venv\Scripts\activate
for powershell
.venv\Scripts\Activate.ps1
Linux / Mac
source .venv/bin/activate
pip install -r requirements.txtUpdate the MongoDB connection string inside:
config.py
or use the .env file with required uri I used in this config
Example:
MONGODB_SETTINGS = {
"host": "mongodb://localhost:27017/blogdb"
}
MONGO_URI='your_mongo_uri'
FLASK_KEY='THIS_IS_MY_TEST_TOKEN'
DEBUGING='True'python run.pyThe application will start on:
http://127.0.0.1:5000
- Python
- Flask
- MongoDB
- MongoEngine
- WTForms
- Jinja2
- HTML / CSS / JavaScript
The goal of this project is to demonstrate how to refactor a simple Flask application into a clean, production-style architecture by separating configuration, models, routes, templates, and utilities.
This structure makes the project easier to maintain and extend with additional features such as APIs, user roles, or larger database models.
This project is open source and available under the MIT License.