Skip to content

rajkandula/SolarFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

132 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

β˜€οΈ SolarFlow β€” Solar Installation Management Platform

A full-stack project management platform for solar installation companies. Customers order solar panels, sales reps approve & assign jobs, construction crews execute installs, and managers oversee everything end-to-end.


πŸš€ Project Name

SolarFlow β€” From order to installation, seamlessly.


πŸ§‘β€πŸ€β€πŸ§‘ User Roles

Role Access Level Key Actions
Customer Limited Submit solar installation orders, track order status
Sales Rep Moderate Review & approve orders, assign crews, manage quotes
Construction Crew Task-based View assigned jobs, update install progress, mark complete
Manager Full Access All of the above + resource management, analytics, reporting

Screenshot 2026-04-18 at 2 57 46β€―AM

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS + shadcn/ui
  • State Management: Zustand
  • Data Fetching: TanStack Query (React Query)
  • Forms: React Hook Form + Zod validation
  • Maps: Google Maps API (for installation addresses)
  • Charts: Recharts (manager dashboard analytics)

Backend

  • Runtime: Node.js
  • Framework: Express.js (REST API)
  • Language: TypeScript
  • Auth: JWT + Role-Based Access Control (RBAC)
  • File Uploads: Multer + AWS S3 (photos of completed installs)

Database

  • Primary DB: PostgreSQL (relational β€” orders, users, assignments)
  • ORM: Prisma
  • Cache: Redis (session management, real-time job queue)

DevOps & Infrastructure

  • Containerization: Docker + Docker Compose
  • CI/CD: GitHub Actions
  • Hosting: GCP Cloud Run (backend) + Vercel (frontend)
  • Storage: GCP Cloud Storage (install photos, documents)
  • Monitoring: GCP Cloud Logging + Sentry

πŸ“ Project Structure

solarflow/
β”œβ”€β”€ README.md
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .env.example
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci.yml
β”‚       └── deploy.yml
β”‚
β”œβ”€β”€ frontend/                          # Next.js App
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tailwind.config.ts
β”‚   β”œβ”€β”€ next.config.ts
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── assets/
β”‚   └── src/
β”‚       β”œβ”€β”€ app/                       # Next.js App Router
β”‚       β”‚   β”œβ”€β”€ layout.tsx
β”‚       β”‚   β”œβ”€β”€ page.tsx               # Landing / redirect
β”‚       β”‚   β”œβ”€β”€ (auth)/
β”‚       β”‚   β”‚   β”œβ”€β”€ login/page.tsx
β”‚       β”‚   β”‚   └── register/page.tsx
β”‚       β”‚   β”œβ”€β”€ (dashboard)/
β”‚       β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Shared dashboard shell
β”‚       β”‚   β”‚   β”œβ”€β”€ customer/
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx       # Customer home
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ orders/
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx   # My orders list
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ new/page.tsx # New order form
β”‚       β”‚   β”‚   β”‚   β”‚   └── [id]/page.tsx # Order detail + status
β”‚       β”‚   β”‚   β”‚   └── profile/page.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ sales/
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx       # Sales dashboard
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ orders/
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx   # Pending approval queue
β”‚       β”‚   β”‚   β”‚   β”‚   └── [id]/page.tsx # Review & approve order
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ assignments/
β”‚       β”‚   β”‚   β”‚   β”‚   └── page.tsx   # Assign crew to jobs
β”‚       β”‚   β”‚   β”‚   └── quotes/page.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ crew/
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx       # Crew task board
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ jobs/
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx   # My assigned jobs
β”‚       β”‚   β”‚   β”‚   β”‚   └── [id]/page.tsx # Job detail + update status
β”‚       β”‚   β”‚   β”‚   └── schedule/page.tsx
β”‚       β”‚   β”‚   └── manager/
β”‚       β”‚   β”‚       β”œβ”€β”€ page.tsx       # Manager overview
β”‚       β”‚   β”‚       β”œβ”€β”€ orders/page.tsx
β”‚       β”‚   β”‚       β”œβ”€β”€ crews/
β”‚       β”‚   β”‚       β”‚   β”œβ”€β”€ page.tsx   # All crews + availability
β”‚       β”‚   β”‚       β”‚   └── [id]/page.tsx
β”‚       β”‚   β”‚       β”œβ”€β”€ resources/
β”‚       β”‚   β”‚       β”‚   β”œβ”€β”€ page.tsx   # Inventory (panels, inverters, etc.)
β”‚       β”‚   β”‚       β”‚   └── order/page.tsx # Order more resources
β”‚       β”‚   β”‚       β”œβ”€β”€ analytics/page.tsx
β”‚       β”‚   β”‚       └── settings/page.tsx
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ ui/                    # shadcn/ui base components
β”‚       β”‚   β”œβ”€β”€ layout/
β”‚       β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ Topbar.tsx
β”‚       β”‚   β”‚   └── RoleGuard.tsx      # Route protection by role
β”‚       β”‚   β”œβ”€β”€ orders/
β”‚       β”‚   β”‚   β”œβ”€β”€ OrderCard.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ OrderForm.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ OrderStatusBadge.tsx
β”‚       β”‚   β”‚   └── OrderTimeline.tsx
β”‚       β”‚   β”œβ”€β”€ jobs/
β”‚       β”‚   β”‚   β”œβ”€β”€ JobCard.tsx
β”‚       β”‚   β”‚   β”œβ”€β”€ JobStatusUpdater.tsx
β”‚       β”‚   β”‚   └── InstallPhotoUpload.tsx
β”‚       β”‚   β”œβ”€β”€ crew/
β”‚       β”‚   β”‚   β”œβ”€β”€ CrewSelector.tsx
β”‚       β”‚   β”‚   └── CrewAvailabilityCard.tsx
β”‚       β”‚   β”œβ”€β”€ resources/
β”‚       β”‚   β”‚   β”œβ”€β”€ InventoryTable.tsx
β”‚       β”‚   β”‚   └── ResourceOrderForm.tsx
β”‚       β”‚   └── analytics/
β”‚       β”‚       β”œβ”€β”€ KPICards.tsx
β”‚       β”‚       β”œβ”€β”€ InstallationsChart.tsx
β”‚       β”‚       └── RevenueChart.tsx
β”‚       β”œβ”€β”€ hooks/
β”‚       β”‚   β”œβ”€β”€ useAuth.ts
β”‚       β”‚   β”œβ”€β”€ useOrders.ts
β”‚       β”‚   β”œβ”€β”€ useJobs.ts
β”‚       β”‚   └── useResources.ts
β”‚       β”œβ”€β”€ lib/
β”‚       β”‚   β”œβ”€β”€ api.ts                 # Axios instance + interceptors
β”‚       β”‚   β”œβ”€β”€ auth.ts
β”‚       β”‚   └── utils.ts
β”‚       β”œβ”€β”€ store/
β”‚       β”‚   β”œβ”€β”€ authStore.ts           # Zustand auth state
β”‚       β”‚   └── notificationStore.ts
β”‚       └── types/
β”‚           β”œβ”€β”€ order.ts
β”‚           β”œβ”€β”€ job.ts
β”‚           β”œβ”€β”€ user.ts
β”‚           └── resource.ts
β”‚
β”œβ”€β”€ backend/                           # Express.js API
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── src/
β”‚       β”œβ”€β”€ server.ts                  # Entry point
β”‚       β”œβ”€β”€ app.ts                     # Express setup, middleware
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   β”œβ”€β”€ database.ts            # Prisma client
β”‚       β”‚   β”œβ”€β”€ redis.ts
β”‚       β”‚   └── gcp.ts                 # GCP Storage client
β”‚       β”œβ”€β”€ middleware/
β”‚       β”‚   β”œβ”€β”€ auth.middleware.ts     # JWT verification
β”‚       β”‚   β”œβ”€β”€ role.middleware.ts     # RBAC guard
β”‚       β”‚   β”œβ”€β”€ upload.middleware.ts   # Multer config
β”‚       β”‚   └── error.middleware.ts
β”‚       β”œβ”€β”€ modules/
β”‚       β”‚   β”œβ”€β”€ auth/
β”‚       β”‚   β”‚   β”œβ”€β”€ auth.router.ts
β”‚       β”‚   β”‚   β”œβ”€β”€ auth.controller.ts
β”‚       β”‚   β”‚   └── auth.service.ts
β”‚       β”‚   β”œβ”€β”€ orders/
β”‚       β”‚   β”‚   β”œβ”€β”€ orders.router.ts
β”‚       β”‚   β”‚   β”œβ”€β”€ orders.controller.ts
β”‚       β”‚   β”‚   └── orders.service.ts
β”‚       β”‚   β”œβ”€β”€ jobs/
β”‚       β”‚   β”‚   β”œβ”€β”€ jobs.router.ts
β”‚       β”‚   β”‚   β”œβ”€β”€ jobs.controller.ts
β”‚       β”‚   β”‚   └── jobs.service.ts
β”‚       β”‚   β”œβ”€β”€ crews/
β”‚       β”‚   β”‚   β”œβ”€β”€ crews.router.ts
β”‚       β”‚   β”‚   β”œβ”€β”€ crews.controller.ts
β”‚       β”‚   β”‚   └── crews.service.ts
β”‚       β”‚   β”œβ”€β”€ resources/
β”‚       β”‚   β”‚   β”œβ”€β”€ resources.router.ts
β”‚       β”‚   β”‚   β”œβ”€β”€ resources.controller.ts
β”‚       β”‚   β”‚   └── resources.service.ts
β”‚       β”‚   β”œβ”€β”€ notifications/
β”‚       β”‚   β”‚   β”œβ”€β”€ notifications.router.ts
β”‚       β”‚   β”‚   └── notifications.service.ts
β”‚       β”‚   └── analytics/
β”‚       β”‚       β”œβ”€β”€ analytics.router.ts
β”‚       β”‚       └── analytics.service.ts
β”‚       └── utils/
β”‚           β”œβ”€β”€ jwt.ts
β”‚           β”œβ”€β”€ email.ts               # Nodemailer (status notifications)
β”‚           └── logger.ts
β”‚
└── database/                          # DB schema & migrations
    β”œβ”€β”€ schema.prisma
    β”œβ”€β”€ migrations/
    β”‚   β”œβ”€β”€ 001_init.sql
    β”‚   β”œβ”€β”€ 002_add_resources.sql
    β”‚   └── 003_add_notifications.sql
    └── seed/
        └── seed.ts                    # Dev seed data (roles, demo users)

πŸ—ΊοΈ Data Flow

Customer submits order
    ↓
Order lands in Sales queue (status: PENDING)
    ↓
Sales Rep reviews β†’ Approves + assigns Construction Crew (status: APPROVED)
    ↓
Crew sees job on their dashboard β†’ Travels to site β†’ Updates status (IN_PROGRESS)
    ↓
Install complete β†’ Crew uploads photo evidence β†’ Marks COMPLETED
    ↓
Manager sees real-time analytics, can order more inventory resources

πŸ” Role Permissions Matrix

Feature Customer Sales Crew Manager
Submit order βœ… βœ… ❌ βœ…
View own orders βœ… βœ… ❌ βœ…
Approve/reject orders ❌ βœ… ❌ βœ…
Assign crew to job ❌ βœ… ❌ βœ…
View assigned jobs ❌ ❌ βœ… βœ…
Update job status ❌ ❌ βœ… βœ…
Upload install photos ❌ ❌ βœ… βœ…
Manage resources/inventory ❌ ❌ ❌ βœ…
Order new resources ❌ ❌ ❌ βœ…
View analytics ❌ πŸ”Έ Own ❌ βœ… Full
Manage users ❌ ❌ ❌ βœ…

πŸ“¦ Order Status Lifecycle

DRAFT β†’ PENDING β†’ APPROVED β†’ ASSIGNED β†’ IN_PROGRESS β†’ COMPLETED
                β†˜ REJECTED

🏁 Getting Started

Prerequisites

  • Node.js 20+
  • Docker & Docker Compose
  • PostgreSQL 15+

Installation

# Clone the repo
git clone https://github.com/your-org/solarflow.git
cd solarflow

# Copy env files
cp .env.example .env
cp frontend/.env.example frontend/.env.local
cp backend/.env.example backend/.env

# Start services with Docker
docker-compose up -d

# Install dependencies
cd frontend && npm install
cd ../backend && npm install

# Run DB migrations + seed
cd backend
npx prisma migrate dev
npx ts-node src/database/seed/seed.ts

# Start dev servers (in separate terminals)
# Terminal 1 - Backend
cd backend && npm run dev        # http://localhost:4000

# Terminal 2 - Frontend
cd frontend && npm run dev       # http://localhost:3000

Demo Accounts (after seeding)

Role Email Password
Customer [email protected] demo1234
Sales [email protected] demo1234
Crew [email protected] demo1234
Manager [email protected] demo1234

🌱 Environment Variables

# Backend (.env)
DATABASE_URL=postgresql://user:password@localhost:5432/solarflow
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_jwt_secret_here
JWT_EXPIRES_IN=7d
GCP_PROJECT_ID=your-gcp-project
GCP_BUCKET_NAME=solarflow-uploads
AWS_REGION=us-east-1
SMTP_HOST=smtp.sendgrid.net
SMTP_USER=apikey
SMTP_PASS=your_sendgrid_key
PORT=4000

# Frontend (.env.local)
NEXT_PUBLIC_API_URL=http://localhost:4000/api
NEXT_PUBLIC_GOOGLE_MAPS_KEY=your_maps_key

πŸ“‘ API Endpoints (Key Routes)

POST   /api/auth/login
POST   /api/auth/register

GET    /api/orders              β†’ List orders (filtered by role)
POST   /api/orders              β†’ Create new order (customer)
PATCH  /api/orders/:id/approve  β†’ Approve order (sales/manager)
PATCH  /api/orders/:id/reject   β†’ Reject order (sales/manager)
PATCH  /api/orders/:id/assign   β†’ Assign crew (sales/manager)

GET    /api/jobs                β†’ My jobs (crew) / all jobs (manager)
PATCH  /api/jobs/:id/status     β†’ Update job status (crew)
POST   /api/jobs/:id/photos     β†’ Upload install photos (crew)

GET    /api/resources           β†’ Inventory list (manager)
POST   /api/resources/order     β†’ Order new resources (manager)

GET    /api/analytics/overview  β†’ KPI summary (manager)
GET    /api/analytics/installs  β†’ Install trends (manager)

🀝 Contributing

  1. Fork the repo
  2. Create feature branch: git checkout -b feature/your-feature
  3. Commit changes: git commit -m 'feat: add your feature'
  4. Push to branch: git push origin feature/your-feature
  5. Open a Pull Request

πŸ“„ License

MIT License β€” see LICENSE for details.


Built with β˜€οΈ to make solar accessible for everyone.

About

The aim of the project is to offer software solution that facilitates the sales process for solar team by efficiently coordinating between sales teams, clients, operational managers, and construction crews.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors