A comprehensive inventory management and analytics platform for The Circular Classroom, consolidating inventory tracking, donation management, and optimization analytics into a single, scalable application.
Deployed on: Vercel (frontend + backend) + Supabase PostgreSQL DB
- Node.js >= 20.x
- npm >= 10.x
- Supabase project with PostgreSQL database
- AWS credentials (for S3, SES, SNS)
- Cognito User Pool for authentication
# Install dependencies for all workspaces
npm install
# Create .env file from template
cp .env.example .env
# Update with your actual credentials
nano .env# Start both frontend and backend in development mode
npm run dev
# Or start them separately:
npm --workspace=apps/frontend run dev
npm --workspace=apps/backend run startFrontend will be on http://localhost:3000
Backend API on http://localhost:3000/api
# Generate Prisma client
npm run prisma:generate
# Run migrations (development)
npm run prisma:migrate
# Apply migrations (production)
npm run prisma:migrate:prod
# Seed database
npm run prisma:db:seed
# Open Prisma Studio
npm --workspace=packages/database run studioecotrack/
βββ apps/
β βββ frontend/ # Next.js frontend application
β β βββ src/app # Pages and layouts
β β βββ src/components # React components
β β βββ src/utils # Utilities (auth, API client)
β β βββ public/ # Static assets
β β βββ next.config.mjs
β βββ backend/ # Express.js unified API
β βββ routes/ # API route handlers
β β βββ *.js # Inventory routes
β β βββ analytics.*.js # Analytics routes
β βββ controllers/ # Request handlers
β βββ services/ # Business logic
β βββ models/ # Service layer
β βββ middlewares/ # Auth & utility middleware
β βββ seeders/ # Database seeders
β βββ app.js # Express app entry point
βββ packages/
β βββ database/ # Shared Prisma schema
β βββ prisma/
β β βββ schema.prisma # Single source of truth
β β βββ migrations/ # Database version history
β β βββ seed.ts # Initial data seeding
β βββ package.json
βββ .env.example # Environment template
βββ package.json # Workspace root config
βββ vercel.json # Vercel deployment config
βββ .github/workflows/ # CI/CD pipelines
- Framework: Next.js 16.2 with App Router
- Styling: Tailwind CSS + Material UI
- State: React hooks + localStorage for session
- Auth: AWS Cognito (JWT-based)
- Deployment: Vercel
Key Features:
- Inventory management dashboard
- Analytics and reporting
- Donation drive tracking
- User role-based access control
- CSV import/export
- PWA support
- Framework: Express 5.2
- Database: PostgreSQL via Prisma ORM
- Authentication: AWS Cognito JWT verification + role-based access control
- File Storage: AWS S3
- Email: AWS SES
- Notifications: AWS SNS
- Optimization: JavaScript LP Solver for assembly planning
- Deployment: Vercel Functions (or traditional Node)
Key API Routes:
/api/brand- Brand management/api/category- Item categories/api/inventory- Inventory tracking/api/transaction- Immutable ledger/api/donation-drive- Donation campaigns/api/analytics/collection- Collection metrics/api/analytics/assembly- Optimization algorithms/api/analytics/overview- Network KPIs/api/analytics/report- PDF generation
- ORM: Prisma 7.5
- Schema: Shared across frontend and backend
- Tables: 23 models covering inventory, users, transactions, analytics
- Migrations: Version-controlled in
packages/database/prisma/migrations/
See .env.example for all required variables. Key ones:
# Database
DATABASE_URL=postgresql://...@db.supabase.co/...
# AWS Cognito
COGNITO_USER_POOL_ID=...
COGNITO_CLIENT_ID=...
# AWS Services
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=ap-southeast-1
S3_BUCKET_NAME=...
SES_SENDER_EMAIL=...
SNS_TOPIC_ARN=...
# Frontend
NEXT_PUBLIC_API_URL=https://backend-api.vercel.app/api- Connect repository to Vercel
- Add environment variables in Vercel project settings
- Configure builds:
- Frontend:
npm run build:frontend - Backend:
npm --workspace=apps/backend run start
- Frontend:
- Deploy - automatically on push to
main
.github/workflows/vercel-deploy.yml- Builds and deploys to Vercel on main branch.github/workflows/validate-conventions.yml- Validates commit conventions
- School - Partner institutions
- User - End users (Admin, SchoolStaff, Parent, PsgVolunteer)
- DonationDrive - Collection campaigns
- Transaction - Immutable ledger (DonationIn, Transfer, Sale, etc.)
- ItemType - SKU definitions
- InventoryBalance - Current stock tracking
- Category - Item classification with weight metrics
- Product/Recipe - Assembly configurations
See packages/database/prisma/schema.prisma for full schema.
# Run backend tests
npm --workspace=apps/backend run test
# With coverage
npm --workspace=apps/backend run test:coverage
# Run specific test file
npm --workspace=apps/backend run test -- reportController.test.js- Routes:
/api/{resource}for inventory,/api/analytics/{feature}for analytics - Controllers:
{resource}Controller.js(e.g.,inventoryController.js) - Services: Files in
/servicesand/modelsdirectories - Branch names:
feature/,bugfix/,hotfix/,release/ - Commits: Follow Conventional Commits (feat:, fix:, docs:, etc.)
-
Create feature branch:
git checkout -b feature/your-feature-name
-
Make changes and commit with Conventional Commits:
git commit -m "feat: add new feature" -
Push and create PR:
git push origin feature/your-feature-name
-
CI/CD validates builds and tests
-
Deploy automatically on merge to main
Swagger docs available at /swagger-output.json on backend. Generate with:
npm --workspace=apps/backend run swagger- Follow commit conventions (commitlint enforced)
- Ensure builds pass locally:
npm run build - Write tests for new features
- Update README if adding major features
- Ensure all lint checks pass:
npm run lint
MIT
The Circular Classroom
Last Updated: April 2026
Version: 1.0.0
Status: Production Ready