The Project
A large distributed workforce gets a fresh set of tasks every day. Each person has to complete them and prove it, someone has to check that proof, and the people running it need to know who is keeping up and who isn't.
Before this system, there was no central place to see who had finished their tasks for the day, to verify what they submitted, or to track work that was incomplete or never done.
Task Tracker is the system that does it now. Managers assign tasks to groups each day, members submit a link and a photo as proof, managers verify every submission, team leaders track who is done, and reports grade each member on timeliness and quality. 390 people use it every day.
The client and the system are covered by an NDA, so the project is shown under a different name. The screenshots on this page come from a local build with dummy data and renamed labels.
Key Features
Daily tasks with proof
Managers create a batch of tasks for a date and assign it to one group or to every group they manage in one step. Each task has a 48-hour deadline from the moment it's created. Members, who mostly work from their phones, submit a link and a required photo. The photo is compressed in the browser before upload, so a submission on mobile data stays small. A calendar marks the days on which they finished everything.
Verification and resubmission
Every submission gets a verdict: Complete, Incomplete, Error or Failed. Anything other than Complete sends the task back for resubmission, with a new 24-hour window (or the original deadline, if that's later). Members never see the verdict label, only the manager's written reason, so the feedback is about what to fix. The previous verdict, reason and resubmission count are kept on the record. Managers can review by submission or by person, select several rows at once, or mark a whole group's pending work complete.
Monitoring scoped to each role
Team leaders see which members are done or still pending for any day, and which days the entire team finished, but not what anyone submitted or how it was judged. Managers see full submissions for the groups assigned to them, and one manager can cover several groups. A super admin manages accounts and groups system-wide and can switch verification, task submission and report creation on or off for everyone.
Graded performance reports
A manager picks groups and a date range of up to two months and gets an Excel workbook. Each member gets a timeliness grade (full marks for submitting on the first day, less on the second, less again for late work, zero for overdue) and a verdict grade that also counts work that needed a redo. The two average into a final grade, and the sheet ranks members by their on-time, late, overdue and verdict counts.
Routed support tickets
Members and team leaders raise concerns from inside the app. Technical issues go to one designated support manager. Task and group issues go to the managers of the sender's group, and replies come back as in-app notifications.
My Contribution
I built this alone, from the spec to production. Every commit in the repo is mine. That covers:
- The Postgres schema and the row-level security policies for five roles, including the helper functions that keep the policies from recursing.
- The Next.js app: the mobile-first member view, the team leader and manager monitoring pages, the verdict workflow with its bulk actions, task assignment, account management and the super admin console.
- Server actions that authorize the caller and then build the cross-member views (team status, completed days, member detail and the report data), cached per group.
- Account creation through the Supabase admin API, rolling the auth user back if the profile insert fails, plus bulk import, promotion and demotion between roles, and moving members between groups.
- Image uploads to Cloudflare R2, with a proxy route on the app's own domain for reading them back.
- The deadline and grading rules, and the Excel report built from them.
- Deployment to Cloudflare Workers through OpenNext, and the work to keep the app inside Cloudflare's free-tier CPU limit and the database's egress budget.
The Challenge
The Problem
The same submission row has four different audiences. Its author can see it. A team leader should only know that it exists. A manager sees the link, the photo and the verdict, but only for groups linked to them through a many-to-many table. A super admin sees everything. I wanted as much of that as possible enforced in Postgres. My early row-level security policies broke, though: rules that checked the caller's role by querying profiles ended up re-entering the policies on profiles itself, and Postgres refused the queries as infinite recursion.
The views people use most made it harder. "Who on my team is done today", "which days did the whole team finish" and a two-month graded report all read across every member, task and day in a group. Run from the browser under row-level security, each one turned into a long chain of policy-checked queries. That cost database egress on a hosted plan, while the app ran on Cloudflare Workers with a 10 ms CPU budget per request.
The Decision
I split data access into two paths. Simple reads, such as a member's own tasks or a manager's queue, go straight from the browser through row-level security. The policies call small SECURITY DEFINER functions, get_my_role() and get_my_group_id(), that read the caller's profile without re-entering the profile policies. They're written in PL/pgSQL on purpose, so Postgres can't inline them back into the policy. That fixed the recursion. Postgres enforces own-row access, group membership, and every manager rule through the manager_groups junction table.
The cross-member views run as Next.js server actions. Each one reads the session, checks the caller's role and, for managers, that they actually manage the requested group. Only then does it query with the service-role client and return the fields that view needs. The team leader's status view carries no links or photos, and the page shows only done or pending. Results are cached per group and date, tagged by group. A submission or verdict invalidates only its own group's tags, so activity in one group never clears another group's cache. To stay under the Workers CPU limit, the middleware only checks that a session cookie exists. Real verification happens in the server actions and in Postgres.
The Tradeoff
The service-role path skips row-level security, so the database is no longer the only gatekeeper. Every server action and API route that holds the service-role key has to run its own authorization check before touching data, and a missing check there is a real hole. That's the part of the code I have to review most carefully whenever it changes. Caching also means a view can lag behind: team status refreshes within a minute, and the calendar and report data within an hour unless a mutation invalidates them first. For tracking daily progress, that lag was acceptable.
The Result
390 people use the system every day. Members submit from their phones, managers verify a whole group's work from one queue, and team leaders see completion without seeing anyone's content. Access rules live in the database for direct reads and in explicit checks on the server for aggregates, and the expensive views are computed once per group instead of once per viewer.
Technical Details
The app is Next.js 16 (App Router, React 19, TypeScript) on Supabase Postgres and Auth. It deploys to Cloudflare Workers through the OpenNext adapter. Dashboard pages are client components that share one Supabase client and load the user's profile and the system settings once through a context, so pages don't repeat those queries. Account management and aggregate reads go through API routes and server actions that hold the service-role key.
The data model is small on purpose: groups, profiles with a role and a single group, a manager_groups junction, tasks per group per day, and one submission per member per task, enforced with a unique key and upserted on resubmission. Deadlines aren't stored. They're computed from the task's creation time and the last verdict, so changing the rule doesn't need a migration.
Photos go to Cloudflare R2 through its S3-compatible API and are read back through a proxy route on the app's own domain, because some phones on mobile networks couldn't load the default R2 URLs. Report data is assembled on the server, with paging past the 1,000-row default limit, and the workbook is built in the browser with ExcelJS, five groups per batch.
What I'd change today
When a manager assigns one task to several groups, the app writes one task row per group, and edits and deletes find the siblings by matching title, date and creator. Two different tasks with the same title on the same day would be treated as one. I'd give each batch its own ID and key every edit on that.
I'd also move the report's grading into Postgres as a view or function. Right now the server action pages task and submission rows into Node in chunks and computes the grades there. Doing that aggregation in SQL would send back one row per member instead of every submission, which matters most on a plan where egress is the constraint.
The source code and the live system are private under an NDA. The screens above use dummy data with renamed labels.