Version: 1.0.0 Last Updated: 2025-12-01 Maintained by: Lucas Nakamura (lucassnakamura@gmail.com)
A comprehensive web-based toolkit for architects, urban planners, and sustainability professionals to evaluate how their projects align with the United Nations Sustainable Development Goals (SDGs). The system provides both guided questionnaire-based assessments and expert-level direct assessment capabilities.
- Overview
- Target Users
- Key Features
- Technology Stack
- System Architecture
- Installation Guide
- Configuration
- Database Setup
- Running the Application
- Project Structure
- API Documentation
- Integration Guide
- Deployment
- Testing
- Contributing
- License
- Support
The SDG Assessment Toolkit is a Flask-based web application that enables professionals to:
- Assess architectural and urban planning projects against all 17 UN SDGs
- Generate detailed, data-driven reports with visualizations
- Track multiple projects and assessments over time
- Export results for presentations and further analysis
- Integrate SDG assessment capabilities into existing workflows via API
- Architects - Evaluate sustainability of building designs
- Urban Planners - Assess city development projects against SDGs
- Sustainability Consultants - Provide SDG compliance reports to clients
- Government Agencies - Ensure public projects meet SDG targets
- Research Institutions - Analyze SDG alignment across multiple projects
- UIA (Union Internationale des Architectes) - Integrate SDG assessment into member services
- Capture project details (name, description, location, type)
- Record project specifications (size, budget, sector, timeline)
- Support for various project types: Residential, Commercial, Education, Healthcare, etc.
- Comprehensive questionnaire covering all 17 SDGs
- Multiple-choice and text-based responses
- Context-aware questions based on project type
- Draft saving and progress tracking
- Automatic scoring based on questionnaire responses
- Direct scores for primary SDG alignment
- Bonus scores for synergistic relationships between SDGs
- Total score calculation (capped at 100%)
- Raw score tracking for detailed analysis
- Interactive charts using Chart.js
- SDG-specific color-coded visualizations
- Radar charts showing alignment across all 17 SDGs
- Bar charts for comparative analysis
- Export capabilities (CSV, PNG, PDF)
- AI-powered suggestions for improving SDG alignment
- Prioritized action items
- Resource links to SDG documentation
- Best practices from similar projects
- Direct input of SDG scores by qualified experts
- Text-based assessment with notes
- Bypass questionnaire for experienced assessors
- Maintain audit trail of expert assessments
- Secure user registration and authentication
- Email confirmation workflow
- Password reset functionality
- User profiles and preferences
- Multi-user support with data isolation
- Create and manage multiple projects
- Track assessment history per project
- Project comparison across SDGs
- Bulk project operations
- Project archival and deletion (GDPR-compliant)
- Personal dashboard with key metrics
- Project comparison views
- SDG trend analysis
- Assessment completion tracking
- Visual summaries and reports
- RESTful API for external integrations
- JWT-based authentication
- CRUD operations for projects and assessments
- Webhook support for real-time updates
- Comprehensive API documentation via Swagger
- Export assessments as CSV
- Generate PDF reports
- Download charts as images (PNG, SVG)
- Bulk export capabilities
- Custom report templates
- CSRF protection
- XSS prevention via input sanitization (bleach)
- SQL injection protection (ORM-based queries)
- Secure password hashing (Werkzeug)
- HTTPS support
- GDPR-compliant data handling
- Python 3.9+ - Core programming language
- Flask 2.3.3 - Web framework
- SQLAlchemy 2.0.30 - ORM for database operations
- Flask-Login - User session management
- Flask-Mail - Email notifications
- Flask-WTF - Form handling and CSRF protection
- PyJWT - API authentication via JSON Web Tokens
- Gunicorn - Production WSGI server
- SQLite - Development database (file-based, no server needed)
- PostgreSQL - Recommended production database (scalable, robust)
- MySQL/MariaDB - Alternative production option
- SQL Server - Enterprise option
- Alembic - Database migrations
- Jinja2 - Server-side templating
- Bootstrap 5 - Responsive UI framework
- Chart.js - Data visualization
- JavaScript (ES6+) - Client-side interactivity
- jQuery - DOM manipulation and AJAX
- Werkzeug - Password hashing (PBKDF2)
- bleach - HTML sanitization
- itsdangerous - Cryptographic signing
- Flask-WTF - CSRF protection
- email-validator - Email validation
- pytest - Testing framework
- pytest-flask - Flask-specific test utilities
- pytest-cov - Code coverage reporting
- BeautifulSoup4 - HTML parsing in tests
- Gunicorn - WSGI application server
- Nginx - Reverse proxy and static file serving (recommended)
- systemd - Service management (Linux)
- Docker - Containerization (optional)
- Git - Version control
- Flasgger - Automatic Swagger UI generation
- OpenAPI 3.0 - API specification standard
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT LAYER β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Web Browser β β Mobile App β β API Client β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
βββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββ
β β β
β HTTPS β HTTPS β HTTPS + JWT
β β β
βββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββ
β WEB SERVER (Nginx) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Static Files β Reverse Proxy β SSL/TLS β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β HTTP (Internal)
β
βββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ
β APPLICATION SERVER (Gunicorn + Flask) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β FLASK APP β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β Routes β β Services β β Models β β β
β β β β β β β β β β
β β β β’ Auth β β β’ Scoring β β β’ User β β β
β β β β’ Projects β β β’ Email β β β’ Project β β β
β β β β’ Assess. β β β’ Project β β β’ Assess. β β β
β β β β’ API β β β’ Assess. β β β’ SDG β β β
β β β β’ Dashboardβ β β β β’ Response β β β
β β ββββββ¬ββββββββ βββββββ¬βββββββ βββββββ¬βββββββ β β
β β β β β β β
β β ββββββββββββββββββΌββββββββββββββββ β β
β ββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ β
β β ORM Layer (SQLAlchemy) β β
β ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β
β SQL Queries
β
βββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β DATABASE LAYER β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SQLite (Dev) / PostgreSQL (Prod) / MySQL / MSSQL β β
β β β β
β β Tables: β β
β β β’ users β’ assessments β’ sdg_scores β β
β β β’ projects β’ sdg_goals β’ sdg_relationshipsβ β
β β β’ question_responses β’ sdg_questions β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EXTERNAL SERVICES β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β SMTP Server β β File Storageβ β CDN (opt.) β β
β β (Email) β β (S3, etc.) β β β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- User authenticates via
/auth/loginβ Session created - User creates project via
/projects/newβ Project stored in DB - User starts assessment β Redirected to
/questionnaire/<assessment_id> - User answers questions β Responses saved via AJAX to
/api/save-progress - User submits assessment β Scoring service calculates SDG scores
- Results displayed β Charts rendered with Chart.js
- User exports data β CSV/PDF generated server-side
- Python 3.9 or higher
- pip (Python package manager)
- Git
- Virtual environment tool (venv, virtualenv, or conda)
- (Optional) PostgreSQL for production deployment
git clone https://github.com/aikiesan/sdg-assessment.git
cd sdg-assessment# Using venv (recommended)
python -m venv venv
# Activate on Linux/Mac
source venv/bin/activate
# Activate on Windows
venv\Scripts\activatepip install --upgrade pip
pip install -r requirements.txtCreate a .env file in the project root:
cp .env.example .env # If example exists, otherwise create manuallyEdit .env with your configuration (see Configuration section).
# Create database and tables
python create_db.py
# Seed SDG data
python seed_sdg_questions.py
# (Optional) Populate SDG relationships
python scripts/populate_relationships.pypython run.pyVisit http://localhost:5001 in your browser.
export FLASK_CONFIG=production
export SECRET_KEY='your-secure-random-key-here'
export DATABASE_URL='postgresql://user:pass@localhost/sdg_assessment'# PostgreSQL example
createdb sdg_assessment
flask db upgrade
python seed_sdg_questions.pygunicorn -w 4 -b 0.0.0.0:8000 run:appSee Deployment section for Nginx configuration.
Create a .env file in the project root:
# Flask Configuration
FLASK_CONFIG=development # Options: development, testing, production
SECRET_KEY=your-secret-key-here # Generate with: python -c "import secrets; print(secrets.token_hex(32))"
DEBUG=True # Set to False in production
# Database Configuration
DATABASE_URL=sqlite:///instance/sdgassessmentdev.db # Development
# DATABASE_URL=postgresql://user:password@localhost/sdg_assessment # Production
# Mail Server Configuration (for email notifications)
MAIL_SERVER=smtp.googlemail.com
MAIL_PORT=587
MAIL_USE_TLS=True
MAIL_USE_SSL=False
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_DEFAULT_SENDER=your-email@gmail.com
ADMIN_EMAIL=lucassnakamura@gmail.com
# Application Settings
APP_NAME=SDG Assessment Toolkit
APP_URL=http://localhost:5001 # Update to your domain in production
# Security Settings
SESSION_COOKIE_SECURE=False # Set to True in production with HTTPS
SESSION_COOKIE_HTTPONLY=True
SESSION_COOKIE_SAMESITE=Lax
# API Settings
API_RATE_LIMIT=100 # Requests per hour per userThe application uses different configuration classes defined in config.py:
- DevelopmentConfig - Debug enabled, SQLite database
- TestingConfig - In-memory SQLite, email suppressed
- ProductionConfig - Debug disabled, production database
Set via FLASK_CONFIG environment variable.
No additional setup required. Database file is created automatically at:
instance/sdgassessmentdev.db
# Ubuntu/Debian
sudo apt install postgresql postgresql-contrib
# macOS
brew install postgresql
# Windows
# Download from https://www.postgresql.org/download/windows/sudo -u postgres psql
CREATE DATABASE sdg_assessment;
CREATE USER sdg_user WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE sdg_assessment TO sdg_user;
\qexport DATABASE_URL='postgresql://sdg_user:secure_password@localhost/sdg_assessment'flask db upgrade
python seed_sdg_questions.pyCREATE DATABASE sdg_assessment CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'sdg_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON sdg_assessment.* TO 'sdg_user'@'localhost';
FLUSH PRIVILEGES;pip install mysqlclient # or PyMySQLexport DATABASE_URL='mysql://sdg_user:secure_password@localhost/sdg_assessment'# Initialize migrations (first time only)
flask db init
# Create a new migration
flask db migrate -m "Description of changes"
# Apply migrations
flask db upgrade
# Rollback last migration
flask db downgradeFor detailed database schema information, see DATABASE_SCHEMA.md.
python run.py
# Access at: http://localhost:5001export FLASK_APP=run.py
flask run --host=0.0.0.0 --port=5001gunicorn -w 4 -b 0.0.0.0:8000 --timeout 120 run:app
# With worker class for better concurrency:
gunicorn -w 4 -k gevent -b 0.0.0.0:8000 run:app# Development server: Ctrl+C
# Gunicorn:
pkill gunicorn
# or
ps aux | grep gunicorn # Find PID
kill <PID>sdg-assessment/
β
βββ app/ # Main application package
β βββ __init__.py # Flask app factory, extensions initialization
β βββ cli.py # Custom CLI commands
β βββ scoring_logic.py # Core SDG scoring algorithms
β β
β βββ models/ # Database models (SQLAlchemy ORM)
β β βββ __init__.py
β β βββ user.py # User model with authentication
β β βββ project.py # Project model
β β βββ assessment.py # Assessment & SdgScore models
β β βββ sdg.py # SdgGoal, SdgQuestion models
β β βββ response.py # QuestionResponse model
β β βββ sdg_relationship.py # SDG synergy relationships
β β
β βββ routes/ # Request handlers (blueprints)
β β βββ __init__.py
β β βββ main.py # Homepage, about, contact routes
β β βββ auth.py # Registration, login, logout
β β βββ projects.py # Project CRUD operations
β β βββ assessments.py # Assessment workflows
β β βββ questionnaire.py # Questionnaire step handling
β β βββ api.py # RESTful API endpoints
β β βββ dashboard.py # User dashboard and analytics
β β
β βββ services/ # Business logic layer
β β βββ __init__.py
β β βββ project_service.py # Project operations
β β βββ assessment_service.py # Assessment workflows
β β βββ scoring_service.py # SDG score calculations
β β βββ email_utils.py # Email sending utilities
β β
β βββ utils/ # Helper functions and utilities
β β βββ __init__.py
β β βββ auth.py # Authentication helpers
β β βββ db.py # Database utilities
β β βββ email_utils.py # Email templates and sending
β β βββ errors.py # Error handlers (404, 500)
β β βββ filters.py # Jinja2 template filters
β β βββ validation.py # Input validation
β β βββ sdg_data.py # SDG constants and data
β β
β βββ templates/ # Jinja2 HTML templates
β β βββ base.html # Base template with navigation
β β βββ index.html # Homepage
β β βββ auth/ # Authentication templates
β β βββ projects/ # Project templates
β β βββ assessments/ # Assessment templates
β β βββ questionnaire/ # Questionnaire templates
β β βββ dashboard/ # Dashboard templates
β β
β βββ static/ # Static assets
β βββ css/ # Stylesheets
β βββ js/ # JavaScript files
β βββ images/ # Images and icons
β βββ sdg_icons/ # SDG goal icons
β
βββ migrations/ # Database migration scripts (Alembic)
β βββ versions/ # Individual migration files
β βββ env.py # Migration environment config
β
βββ tests/ # Test suite
β βββ conftest.py # Pytest fixtures
β βββ test_auth.py # Authentication tests
β βββ test_projects.py # Project tests
β βββ test_assessments.py # Assessment tests
β βββ test_api.py # API tests
β βββ test_models.py # Model tests
β
βββ scripts/ # Utility scripts
β βββ populate_relationships.py # Populate SDG relationships
β βββ create_test_user.py # Create test users
β βββ check_test_data.py # Verify test data
β
βββ documentation/ # Additional documentation
β βββ README.md # Documentation index
β βββ DATA_MODEL.md # Database schema overview
β βββ ARCHITECTURE.md # System architecture
β βββ DEPLOYMENT.md # Deployment guide
β βββ ENVIRONMENT.md # Environment variables
β βββ INTEGRATION_GUIDE.md # Integration options
β βββ USER_GUIDE.md # End-user guide
β βββ CONTRIBUTING.md # Contribution guidelines
β βββ SECURITY.md # Security policy
β βββ ROADMAP.md # Future plans
β
βββ instance/ # Instance-specific files (not in git)
β βββ sdgassessmentdev.db # SQLite database (development)
β
βββ .env # Environment variables (not in git)
βββ .env.example # Example environment variables
βββ .gitignore # Git ignore rules
βββ requirements.txt # Python dependencies
βββ config.py # Flask configuration classes
βββ run.py # Application entry point
βββ create_db.py # Database initialization script
βββ seed_sdg_questions.py # Seed SDG questions
βββ schema.sql # SQL schema reference
βββ pytest.ini # Pytest configuration
βββ README.md # This file
βββ LICENSE # License information
The application provides a RESTful API for external integrations. API documentation is available at:
http://localhost:5001/apidocs # Swagger UI (if Flasgger enabled)
All API endpoints (except login) require JWT authentication.
POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}
Response:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"user_id": 1
}GET /api/projects
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc...| Method | Endpoint | Description |
|---|---|---|
| GET | /api/projects |
List all user's projects |
| POST | /api/projects |
Create a new project |
| GET | /api/projects/<id> |
Get project details |
| PUT | /api/projects/<id> |
Update project |
| DELETE | /api/projects/<id> |
Delete project |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/projects/<id>/assessments |
Create assessment for project |
| GET | /api/assessments/<id> |
Get assessment details |
| PUT | /api/assessments/<id> |
Update assessment |
| DELETE | /api/assessments/<id> |
Delete assessment |
| POST | /api/assessments/<id>/finalize |
Finalize and score assessment |
| GET | /api/assessments/<id>/summary |
Get assessment results |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/sdg/goals |
List all 17 SDG goals |
| GET | /api/sdg/relationships |
Get SDG synergy relationships |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/dashboard |
Get user dashboard metrics |
curl -X POST http://localhost:5001/api/projects \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Green Building Project",
"description": "Sustainable office complex",
"project_type": "Commercial",
"location": "SΓ£o Paulo, Brazil",
"size_sqm": 5000,
"sector": "Commercial",
"budget": 2000000,
"start_date": "2025-01-01",
"end_date": "2026-12-31"
}'curl -X GET http://localhost:5001/api/assessments/123/summary \
-H "Authorization: Bearer YOUR_JWT_TOKEN"For complete API documentation, see documentation/INTEGRATION_GUIDE.md.
Embed the assessment tool in your existing website:
<iframe
src="https://your-sdg-toolkit.com/assessments/new?token=YOUR_TOKEN"
width="100%"
height="800px"
frameborder="0">
</iframe>Integrate via API calls (see API Documentation).
The toolkit supports SSO integration:
- Configure OAuth2 provider in
config.py - Implement custom authentication provider in
app/utils/auth.py - Map external user IDs to local user accounts
For detailed integration instructions, see documentation/INTEGRATION_GUIDE.md.
- Set
FLASK_CONFIG=production - Generate strong
SECRET_KEY - Use PostgreSQL/MySQL instead of SQLite
- Configure HTTPS/SSL certificates
- Set up reverse proxy (Nginx)
- Configure firewall rules
- Enable database backups
- Set up monitoring and logging
- Configure email server
- Review security settings
- Run security audit
- Set up rate limiting
- Configure CORS if needed
- Optimize static file serving
- Set up CDN for assets (optional)
server {
listen 80;
server_name sdg-assessment.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name sdg-assessment.example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Static files
location /static {
alias /path/to/sdg-assessment/app/static;
expires 30d;
add_header Cache-Control "public, immutable";
}
# Proxy to Gunicorn
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}Create /etc/systemd/system/sdg-assessment.service:
[Unit]
Description=SDG Assessment Toolkit
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/path/to/sdg-assessment
Environment="PATH=/path/to/sdg-assessment/venv/bin"
Environment="FLASK_CONFIG=production"
EnvironmentFile=/path/to/sdg-assessment/.env
ExecStart=/path/to/sdg-assessment/venv/bin/gunicorn -w 4 -b 127.0.0.1:8000 run:app
Restart=always
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable sdg-assessment
sudo systemctl start sdg-assessment
sudo systemctl status sdg-assessmentFor detailed deployment instructions, see documentation/DEPLOYMENT.md.
pytestpytest --cov=app --cov-report=html
# View coverage report: open htmlcov/index.htmlpytest tests/test_auth.pypytest tests/test_auth.py::test_register_userpytest -vtests/conftest.py- Fixtures (test client, database, users)tests/test_auth.py- Authentication teststests/test_projects.py- Project CRUD teststests/test_assessments.py- Assessment workflow teststests/test_api.py- API endpoint teststests/test_models.py- Database model tests
Contributions are welcome! Please see documentation/CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
pytest - Commit:
git commit -m "Add my feature" - Push:
git push origin feature/my-feature - Open a Pull Request
- Follow PEP 8 style guide
- Write docstrings for all functions
- Add tests for new features
- Update documentation as needed
This project is licensed under the MIT License. See LICENSE for details.
- Email: lucassnakamura@gmail.com
- GitHub Issues: https://github.com/aikiesan/sdg-assessment/issues
Please include:
- Python version
- Operating system
- Steps to reproduce
- Expected vs actual behavior
- Error messages and logs
Open an issue on GitHub with the "enhancement" label.
- United Nations for the Sustainable Development Goals framework
- Flask and SQLAlchemy communities
- Chart.js for visualization capabilities
- All contributors to this project
Made with β€οΈ for a sustainable future "# UIA_SDG_Toolbox"