Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ codecov:
coverage:
precision: 2
round: down
range: "70...100"
range: '70...100'

status:
project:
Expand All @@ -17,6 +17,6 @@ coverage:
threshold: 1%

comment:
layout: "reach, diff, flags, files"
layout: 'reach, diff, flags, files'
behavior: default
require_changes: no
9 changes: 7 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
---
name: Bug report
about: Something is broken
title: "[BUG] "
title: '[BUG] '
labels: bug
assignees: ""
assignees: ''
---

## Describe the bug

<!-- A clear description of what the bug is -->

## Steps to reproduce

1. Go to ...
2. Click on ...
3. See error

## Expected behavior

<!-- What you expected to happen -->

## Screenshots

<!-- If applicable -->

## Environment

- OS:
- Browser:
- Node version:
9 changes: 7 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
---
name: Feature request
about: Suggest a new feature or improvement
title: "[FEAT] "
title: '[FEAT] '
labels: enhancement
assignees: ""
assignees: ''
---

## Problem this solves

<!-- What problem does this feature address? -->

## Proposed solution

<!-- Describe the feature you would like -->

## Alternatives considered

<!-- Any alternative approaches you thought about -->

## Additional context

<!-- Mockups, references, related issues -->

## Would you like to work on this?

- [ ] Yes, I would like to implement this
10 changes: 8 additions & 2 deletions .github/ISSUE_TEMPLATE/good_first_issue.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
---
name: Good First Issue
about: A well-scoped task suitable for new contributors
title: "[GOOD FIRST ISSUE] "
title: '[GOOD FIRST ISSUE] '
labels: good first issue, help wanted
assignees: ""
assignees: ''
---

## What needs to be done

<!-- Describe the task clearly and specifically -->

## Files to look at

<!-- List the specific files a contributor should start with -->

## Acceptance criteria

<!-- Bullet points describing exactly what done looks like -->

- [ ]
- [ ]

## Difficulty

<!-- Easy / Medium -->

## Notes for new contributors

<!-- Any helpful context, links to relevant code, or tips -->
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
## Description

<!-- What does this PR do? Be specific. -->

## Related Issue

Closes #<!-- issue number -->

## Type of Change

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Refactor
- [ ] Tests

## Screenshots (for UI changes)

<!-- Add before/after screenshots or a screen recording -->

## Checklist

- [ ] I have read CONTRIBUTING.md
- [ ] My code follows the existing style
- [ ] I have run `npm test` and all tests pass
Expand Down
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
build
.next
coverage
2 changes: 2 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
EcoSphere is a Next.js based application utilizing a modern full-stack web architecture.

## Tech Stack

- **Framework:** Next.js (App Router)
- **Database ORM:** Prisma
- **Styling:** Tailwind CSS
- **Testing:** Jest, Playwright
- **Linting & Formatting:** ESLint, Prettier

## Directory Structure

- `/app`: Next.js App Router pages and layouts.
- `/components`: Reusable React components.
- `/lib`: Utility functions and library wrappers.
Expand Down
2 changes: 2 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ We pledge to make participation in our community a harassment-free experience fo
## Our Standards

Positive behavior includes:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and learning from mistakes

Unacceptable behavior includes:

- Sexualized language or imagery, and unwanted sexual attention
- Trolling, insulting or derogatory comments, personal attacks
- Public or private harassment
Expand Down
23 changes: 15 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ cp .env.example .env
```

Fill in `.env`:

- `DATABASE_URL` — from your Neon project dashboard
- `NEXTAUTH_SECRET` — generate with `openssl rand -base64 32`
- `NEXTAUTH_URL` — `http://localhost:3000` for local dev
Expand Down Expand Up @@ -109,6 +110,7 @@ docs/ — Additional documentation
```

For detailed documentation, see:

- [Architecture Overview](docs/ARCHITECTURE.md) — Data flow, tech stack, and key decisions
- [API Reference](docs/API.md) — All API route documentation with request/response examples
- [Component Reference](docs/COMPONENTS.md) — UI component catalog and usage patterns
Expand All @@ -133,14 +135,14 @@ Comment on the issue saying you'd like to work on it. A maintainer will assign i

Always branch off from `dev` (the default branch). Use this naming convention:

| Type | Format | Example |
|---|---|---|
| New feature | `feat/short-description` | `feat/dark-mode-toggle` |
| Bug fix | `fix/short-description` | `fix/map-marker-overlap` |
| Documentation | `docs/short-description` | `docs/update-setup-guide` |
| Tests | `test/short-description` | `test/insights-edge-cases` |
| Refactor | `refactor/short-description` | `refactor/emissions-engine` |
| UI/styling | `ui/short-description` | `ui/mobile-nav-polish` |
| Type | Format | Example |
| ------------- | ---------------------------- | --------------------------- |
| New feature | `feat/short-description` | `feat/dark-mode-toggle` |
| Bug fix | `fix/short-description` | `fix/map-marker-overlap` |
| Documentation | `docs/short-description` | `docs/update-setup-guide` |
| Tests | `test/short-description` | `test/insights-edge-cases` |
| Refactor | `refactor/short-description` | `refactor/emissions-engine` |
| UI/styling | `ui/short-description` | `ui/mobile-nav-polish` |

```bash
git checkout dev
Expand All @@ -165,6 +167,7 @@ Optional longer body explaining what and why (not how).
**Types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`

**Examples:**

```
feat(insights): add carbon intensity per revenue metric
fix(map): prevent marker overlap when coordinates are identical
Expand All @@ -179,16 +182,19 @@ Keep the first line under 72 characters. Use the imperative mood ("add", not "ad
## Pull Request Process

1. **Make sure your branch is up to date** with `dev` before opening a PR:

```bash
git fetch upstream
git rebase upstream/dev
```

2. **Run the full test suite** before submitting:

```bash
npm test
npm run lint
```

Fix any failures before opening the PR — PRs that fail CI won't be reviewed.

3. **Open the PR against `dev`** on the original repo (not `main`).
Expand Down Expand Up @@ -217,6 +223,7 @@ Every PR is automatically reviewed by **[CodeRabbit](https://coderabbit.ai)**, a
- Pre-merge checks (e.g. missing tests, accessibility issues, type safety)

**What to do with CodeRabbit feedback:**

- Address any `❌` (failing) checks before asking for a human review
- `⚠️` warnings are suggestions — use your judgement
- You can reply directly to CodeRabbit's comments to ask it to explain something or re-check after a fix
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ cp .env.example .env
```

Fill in `.env`:

- `DATABASE_URL` — your Neon connection string (use the pooled string for Vercel)
- `NEXTAUTH_SECRET` — generate with `openssl rand -base64 32`
- `NEXTAUTH_URL` — `http://localhost:3000` for local dev
Expand Down Expand Up @@ -152,18 +153,18 @@ __tests__/

All routes are scoped to the signed-in user's organization.

| Route | Methods | Purpose |
|---|---|---|
| `/api/auth/[...nextauth]` | GET/POST | NextAuth session handling |
| `/api/signup` | POST | Create user + first organization |
| `/api/suppliers` | GET/POST | List / batch-create suppliers |
| `/api/facilities` | GET/POST | List / batch-create facilities |
| `/api/routes` | GET/POST | List / batch-create transport routes |
| `/api/activities` | GET/POST | List / batch-create usage records |
| `/api/upload` | POST | Bulk CSV/Excel ingestion |
| `/api/dashboard` | GET | Scope totals, top emitters, monthly trend |
| `/api/insights` | GET | Runs the rule-based insight engine |
| `/api/reports` | GET/POST | Report export history |
| Route | Methods | Purpose |
| ------------------------- | -------- | ----------------------------------------- |
| `/api/auth/[...nextauth]` | GET/POST | NextAuth session handling |
| `/api/signup` | POST | Create user + first organization |
| `/api/suppliers` | GET/POST | List / batch-create suppliers |
| `/api/facilities` | GET/POST | List / batch-create facilities |
| `/api/routes` | GET/POST | List / batch-create transport routes |
| `/api/activities` | GET/POST | List / batch-create usage records |
| `/api/upload` | POST | Bulk CSV/Excel ingestion |
| `/api/dashboard` | GET | Scope totals, top emitters, monthly trend |
| `/api/insights` | GET | Runs the rule-based insight engine |
| `/api/reports` | GET/POST | Report export history |

---

Expand All @@ -182,6 +183,7 @@ All factors live in the `EmissionFactor` table (seeded with indicative DEFRA/EPA
## Insights engine

`lib/insights.ts` is fully rule-based (no ML/LLM):

- Top-emitter concentration (supplier or facility > 30% of total)
- High-carbon transport mode flags (air freight, with rail/sea mode-shift suggestions)
- Scope 2 share warnings (purchased electricity > 30% of total)
Expand Down Expand Up @@ -234,4 +236,4 @@ Contributions are welcome from developers of all skill levels!

Licensed under the [Apache License 2.0](LICENSE).

Copyright 2026 Arghya and EcoSphere contributors.
Copyright 2026 Arghya and EcoSphere contributors.
18 changes: 15 additions & 3 deletions __tests__/e2e/core-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '@playwright/test';

test.describe('Landing page', () => {
test('shows hero content and the interactive demo responds to scenario clicks', async ({ page }) => {
test('shows hero content and the interactive demo responds to scenario clicks', async ({
page,
}) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: /supply chain/i })).toBeVisible();

Expand All @@ -11,9 +13,19 @@ test.describe('Landing page', () => {

// Toggling Scope 3 visibility should change the total readout.
const scope3Toggle = page.getByLabel('Show Scope 3 (transport)');
const totalBefore = await page.locator('text=Total estimated emissions').locator('..').locator('p').first().innerText();
const totalBefore = await page
.locator('text=Total estimated emissions')
.locator('..')
.locator('p')
.first()
.innerText();
await scope3Toggle.uncheck();
const totalAfter = await page.locator('text=Total estimated emissions').locator('..').locator('p').first().innerText();
const totalAfter = await page
.locator('text=Total estimated emissions')
.locator('..')
.locator('p')
.first()
.innerText();
expect(totalAfter).not.toBe(totalBefore);
});

Expand Down
1 change: 0 additions & 1 deletion __tests__/unit/activity-pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ describe('Activity Pagination Calculations', () => {
expect(isStartValid && isEndValid).toBe(true);
});
});

6 changes: 4 additions & 2 deletions __tests__/unit/builder-delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ describe('guardNodeDeletion', () => {
const facility = guardNodeDeletion('facility', 2);
expect(supplier.blocked).toBe(true);
expect(facility.blocked).toBe(true);
if (supplier.blocked) expect(supplier.error).toContain('This supplier is still used by 2 routes');
if (facility.blocked) expect(facility.error).toContain('This facility is still used by 2 routes');
if (supplier.blocked)
expect(supplier.error).toContain('This supplier is still used by 2 routes');
if (facility.blocked)
expect(facility.error).toContain('This facility is still used by 2 routes');
});
});
1 change: 0 additions & 1 deletion __tests__/unit/chart-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ describe('Chart Data Mapping Formatting', () => {
expect(filtered.find((d) => d.name.includes('Scope 2'))?.value).toBe(5000);
});
});

Loading
Loading