A comprehensive Node.js/Express/MongoDB backend for helping Small and Medium Enterprises (SMEs) in Ghana achieve Net Zero Carbon Emissions.
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- API Documentation
- Database Models
- Deployment
- 🔐 Authentication & Authorization - JWT-based auth with role-based access control
- 💬 Real-time Chat - Socket.io powered messaging between SMEs
- 📚 Knowledge Base - Educational resources on sustainability
- 📰 News Section - Latest updates on carbon emissions and Net Zero
- 📊 Carbon Footprint Tracker - 3-level sustainability system with tracking
- 🏢 Organization Management - Multi-tenant SME profiles
- 🎯 Sustainability Roadmap - 6-milestone progress tracking
- 🎯 Goal Setting - Set and track carbon reduction goals
- 📤 File Uploads - Cloudinary integration for images and documents
- 📧 Email Notifications - Gmail SMTP for transactional emails
- 📖 API Documentation - Swagger/OpenAPI docs
- Runtime: Node.js with TypeScript
- Framework: Express.js
- Database: MongoDB (Atlas - FREE tier)
- ODM: Mongoose
- Real-time: Socket.io
- Authentication: JWT (jsonwebtoken)
- File Storage: Cloudinary (FREE tier)
- Email: Nodemailer + Gmail SMTP (FREE)
- Validation: Joi + express-validator
- Security: Helmet, bcryptjs, express-mongo-sanitize
- Logging: Winston
- API Docs: Swagger
shopify-be/
├── src/
│ ├── config/ # Configuration files
│ │ ├── database.ts
│ │ ├── environment.ts
│ │ └── cloudinary.ts
│ ├── models/ # Mongoose models
│ │ ├── User.ts
│ │ ├── Organization.ts
│ │ ├── Conversation.ts
│ │ ├── Message.ts
│ │ ├── KnowledgeArticle.ts
│ │ ├── NewsArticle.ts
│ │ ├── CarbonEntry.ts
│ │ ├── EmissionFactor.ts
│ │ ├── SustainabilityRoadmap.ts
│ │ └── SustainabilityGoal.ts
│ ├── controllers/ # Route controllers
│ ├── routes/ # API routes
│ ├── middleware/ # Custom middleware
│ ├── services/ # Business logic
│ ├── validators/ # Input validation
│ ├── utils/ # Utility functions
│ ├── sockets/ # Socket.io handlers
│ ├── types/ # TypeScript types
│ ├── swagger/ # API documentation
│ ├── app.ts # Express app setup
│ └── server.ts # Entry point
├── tests/ # Test files
├── logs/ # Log files
├── .env.example # Environment template
├── .gitignore
├── package.json
├── tsconfig.json
├── nodemon.json
└── README.md
- Node.js 18+ and npm
- MongoDB Atlas account (FREE)
- Cloudinary account (FREE)
- Gmail account with App Password
- Clone the repository
git clone <your-repo-url>
cd shopify-be- Install dependencies
npm install- Setup environment variables
cp .env.example .envThen edit .env with your credentials:
- MongoDB Atlas connection string
- JWT secrets (generate random strings)
- Cloudinary credentials
- Gmail SMTP credentials
- Build TypeScript
npm run build- Run in development
npm run dev- Run in production
npm startSee .env.example for all required variables:
- Go to https://www.mongodb.com/cloud/atlas/register
- Create FREE cluster (M0 tier)
- Create database user
- Whitelist IP:
0.0.0.0/0 - Get connection string
- Go to https://cloudinary.com/users/register/free
- Get Cloud Name, API Key, API Secret from dashboard
- Enable 2-Step Verification on Google Account
- Go to https://myaccount.google.com/apppasswords
- Generate App Password for "Mail"
- Use 16-digit password in
.env
Once running, visit:
- Swagger UI:
http://localhost:5000/api-docs - API Base:
http://localhost:5000/api/v1
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- LoginPOST /api/v1/auth/logout- LogoutPOST /api/v1/auth/refresh- Refresh tokenPUT /api/v1/auth/change-password- Change password
GET /api/v1/chat/conversations- List conversationsPOST /api/v1/chat/conversations- Create conversationGET /api/v1/chat/conversations/:id/messages- Get messagesPOST /api/v1/chat/messages- Send message- WebSocket:
/socket.io- Real-time chat
GET /api/v1/knowledge/articles- List articlesGET /api/v1/knowledge/articles/:slug- Get articlePOST /api/v1/knowledge/articles- Create article (admin)GET /api/v1/knowledge/search?q=...&level=...- Search
GET /api/v1/news- List newsGET /api/v1/news/:slug- Get news articlePOST /api/v1/news- Create news (admin)
POST /api/v1/carbon/calculate- Calculate emissionsPOST /api/v1/carbon/entries- Create entryGET /api/v1/carbon/entries?level=...- List entriesGET /api/v1/carbon/dashboard- Dashboard statsGET /api/v1/carbon/roadmap- Get roadmap
- User - User accounts with roles
- Organization - SME company profiles
- Conversation - Chat rooms
- Message - Chat messages
- KnowledgeArticle - Educational content
- NewsArticle - News posts
- CarbonEntry - Emission records
- EmissionFactor - Calculation factors (Ghana-specific)
- SustainabilityRoadmap - Progress tracking
- SustainabilityGoal - Reduction targets
The system uses a 3-level progression:
- Basic carbon footprint tracking
- Initial data collection
- Understanding emissions sources
- Implementing efficiency measures
- Renewable energy integration
- Advanced tracking
- Complete transformation
- Carbon offsetting
- Net-zero achievement
- Push to GitHub
git init
git add .
git commit -m "Initial commit"
git remote add origin <your-repo>
git push -u origin main- Create Render Web Service
- Go to https://render.com
- Connect GitHub repository
- Set build command:
npm run build - Set start command:
npm start - Add environment variables from
.env
- Deploy!
- Auto-deploys on every push
https://solidify-api.onrender.com
npm run dev # Development with nodemon
npm run build # Build TypeScript
npm start # Production server
npm test # Run tests
npm run lint # Lint code
npm run lint:fix # Fix linting issues- JWT authentication with refresh tokens
- Password hashing with bcrypt
- Helmet for security headers
- Rate limiting
- MongoDB injection prevention
- XSS protection
- CORS configuration
- Input validation
- Admin - Full access, manage all content
- Manager - Organization management, create content
- User - View content, use chat, track emissions
Author: Jehiel Britstot Houmanou Email: jehielbh@gmail.com Institution: Advanced School of Systems and Data Studies (ASSDAS) Supervisor: Mr Eugene Akoto
MIT License - See LICENSE file
- Ghana Enterprises Agency (GEA)
- KNUST Net-Zero Carbon Emission Lab
- SME Climate Hub
- All participating Ghanaian SMEs
Built for the fight towards Net Zero Carbon Emissions by 2050 🌍