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 π