Skip to content

AdaviDigital/AgriPilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AgriPilot System

AI-Powered Animal Production Management Platform

AgriPilot System is a full website + REST API package for managing poultry, cattle, dairy, goat, sheep, pig, rabbit, fish, turkey, snail, horse, camel and mixed-livestock operations — covering livestock identification, AI health monitoring, feed management, breeding, production, growth, finance, inventory, workforce, sales/CRM, suppliers, reports, notifications, weather, GPS mapping, and an AI Farm Advisor.

This package contains:

  1. Frontend — a static, fully-linked multi-page website (HTML/CSS/JavaScript) covering the marketing site, authentication flows, and the internal dashboard/app for every module in the brief.
  2. Backend — a Node.js/Express REST API with JWT authentication, role-based access control, and Swagger/OpenAPI docs.
  3. Database — schema for PostgreSQL (primary), MySQL (alternative), and a MongoDB reference schema, selectable via one environment variable.

1. Project Structure

agripilot/
├── index.html                 Marketing homepage
├── features.html, species.html, about.html, contact.html
├── privacy.html, terms.html, 404.html
├── login.html, register.html, forgot-password.html, verify-otp.html
├── dashboard.html              Executive dashboard (app shell)
├── livestock.html, livestock-profile.html
├── health.html                 AI Health Monitoring
├── feed.html, breeding.html, growth.html, production.html
├── finance.html, inventory.html, workforce.html
├── sales.html, suppliers.html, reports.html
├── notifications.html, weather.html, farm-map.html
├── ai-advisor.html             Conversational AI Farm Advisor
├── users.html, settings.html
├── css/style.css                Shared design system & layout
├── js/script.js                 Shared frontend logic (nav, theme, forms, AI mock, charts)
├── images/                      Logo, favicon, OG cover (SVG, no binary deps)
├── robots.txt, sitemap.xml
├── build.py, pages_*.py         Python generator scripts used to build every HTML page
│                                 (kept for maintainability — re-run the pages_*.py scripts
│                                 after editing partials in build.py to regenerate all pages)
├── Dockerfile, nginx.conf        Frontend container
├── docker-compose.yml            Frontend + backend + PostgreSQL, one command
└── backend/
    ├── server.js                 Express app entry point
    ├── package.json
    ├── .env.example
    ├── Dockerfile
    ├── config/database.js        Multi-database connector (Postgres/MySQL/MongoDB)
    ├── middleware/                auth (JWT+RBAC), validation, error handling, logging
    ├── models/                    Sequelize models (14 domain models)
    ├── controllers/                Auth controller, AI advisor controller, generic CRUD factory
    ├── routes/                     One route file per module (17 files)
    ├── database/
    │   ├── migrate.js, seed.js
    │   ├── schema.postgres.sql    Primary DB schema (run directly if not using Sequelize sync)
    │   ├── schema.mysql.sql       Alternative DB schema
    │   └── schema.mongodb.md      MongoDB collection reference
    ├── docs/openapi.yaml          Swagger/OpenAPI spec (served at /api/docs)
    └── tests/                     Jest + Supertest test suite

Every HTML page links to the shared css/style.css and js/script.js, and every internal link between pages has been verified to resolve to a real file in this package.


2. Running the Frontend

The frontend is plain HTML/CSS/JS — no build step required.

Option A — open directly: open index.html in a browser. (Some browsers restrict fetch from file://; use a local server for the full experience.)

Option B — local server:

cd agripilot
python3 -m http.server 8080
# visit http://localhost:8080

Option C — Docker:

docker build -t agripilot-frontend .
docker run -p 8080:80 agripilot-frontend

The dashboard and internal app pages use realistic sample data hard-coded into the HTML so the UI is fully explorable without a live backend. Wire js/script.js's AgriPilot.apiRequest() helper (or your own fetch calls) to the backend endpoints below to make it live.


3. Running the Backend

cd backend
cp .env.example .env      # fill in real secrets before deploying
npm install
npm run migrate           # creates/updates tables from the Sequelize models
npm run seed               # optional — creates a demo farm, login, and sample records
npm run dev                 # or `npm start` for production

API base URL: http://localhost:5000/api/v1 Swagger UI: http://localhost:5000/api/docs Health check: GET /api/v1/health

Demo login after seeding: jide@agripilot.demo / Password123!

Choosing a database

Set DB_CLIENT in .env to postgres (default/primary), mysql, or mongodb. All connection variables for each are in .env.example. If you prefer raw SQL over the Sequelize sync/migrate step, import backend/database/schema.postgres.sql or schema.mysql.sql directly into your database.

Full stack with Docker Compose

docker compose up --build

This starts the frontend (port 8080), the API (port 5000), and a PostgreSQL database, and automatically loads schema.postgres.sql on first boot.


4. Authentication & Roles

JWT access + refresh tokens, bcrypt password hashing, and 16 configurable roles are enforced at the route level (backend/middleware/auth.js):

Super Administrator · Farm Owner · Farm Manager · Veterinarian · Animal Health Officer · Feed Manager · Breeding Officer · Finance Officer · Inventory Officer · Staff · Customer · Supplier · Government Inspector · Cooperative Manager · Investor · AI Administrator

Super Administrator bypasses per-route role checks; every other role is scoped to what it needs (e.g. only Finance Officer/Farm Owner can write transactions).

Endpoints requiring extra hardening in production: MFA challenge completion, OTP delivery (email/SMS provider), OAuth (Google/Microsoft) callback handlers, and CAPTCHA on /auth/register and /auth/login — the scaffolding (fields, flags, routes) is in place; plug in your provider credentials from .env.


5. Security Notes

  • helmet, cors, express-rate-limit, and compression are enabled globally in server.js.
  • Passwords are hashed with bcrypt (BCRYPT_SALT_ROUNDS, default 12).
  • Refresh tokens are stored server-side as a SHA-256 hash, not in plaintext.
  • All list/get/create/update/delete routes require a valid JWT (authenticate) and, where relevant, a specific role (authorize(...)).
  • Input validation uses express-validator on write endpoints; extend the chains in each route file as needed.
  • Before production: rotate every secret in .env.example, put the API behind HTTPS/a reverse proxy (see nginx.conf), and review the audit-log table (backend/database/schema.postgres.sql) for compliance needs.

6. Deploying to Hostinger

Static frontend only (Hostinger Business Hosting):

  1. Zip the site root (excluding backend/, build.py, pages_*.py, Dockerfile, docker-compose.yml).
  2. Upload via Hostinger's File Manager or FTP into public_html/.
  3. Confirm robots.txt and sitemap.xml sit at the domain root (they already do in this package).
  4. No build step needed — it's static HTML/CSS/JS.

Full stack (Hostinger Cloud/VPS/Cloud Enterprise Hosting):

  1. SSH into the server, install Node.js 18+, and clone/upload this package.
  2. cd backend && cp .env.example .env and fill in production secrets and your managed database credentials (Hostinger's PostgreSQL/MySQL add-on, or an external managed DB).
  3. npm install --omit=dev && npm run migrate && npm run seed (seed optional).
  4. Run the API with a process manager: pm2 start server.js --name agripilot-api.
  5. Point Nginx (see nginx.conf as a starting template) at the static files for / and reverse-proxy /api/ to localhost:5000.
  6. Add a free SSL certificate via Hostinger's SSL manager or Let's Encrypt/Certbot.
  7. Optionally set SERVE_FRONTEND=true in .env to have the Express server itself serve the static site from one process — useful on single-app hosting plans.

7. Tests

cd backend
npm test

Runs Jest + Supertest against the health-check endpoint and auth validation rules. Extend backend/tests/ as you flesh out business logic.


8. Regenerating the Frontend Pages

The HTML pages are generated from Python scripts (build.py + pages_*.py) so the shared header, footer, sidebar and design system stay perfectly consistent across all 32 pages. To change a shared partial (nav, footer, sidebar links) or add a new page, edit build.py and re-run the relevant pages_*.py script:

python3 pages_marketing.py  # marketing pages
python3 pages_auth.py       # login, register, forgot password, OTP
python3 pages_dashboard.py  # executive dashboard
python3 pages_livestock.py  # livestock registry, profile, health monitoring
python3 pages_ops1.py       # feed, breeding, growth, production
python3 pages_ops2.py       # finance, inventory, workforce, sales, suppliers
python3 pages_final.py      # AI advisor, reports, notifications, weather, map, users, settings
python3 pages_404.py        # 404 page

This is optional — the generated .html files in this package are already complete, static, and require no Python at runtime. The scripts are included purely so the site remains easy to maintain.


9. Contact

AgriPilot System WhatsApp / Phone: +234 806 217 7435 Email: olatundeajayi87@yahoo.com · adavidigitalmediaconcepts@gmail.com Location: Ikorodu, Lagos, Nigeria


10. Scope Notes

This package delivers a production-grade frontend website and a genuinely wired REST API + database layer covering every module in the brief. A handful of items named in the original brief are explicitly out of scope for an HTML/CSS/JS + Node.js package and would need dedicated tooling: native iOS/Android apps, on-device computer vision/facial recognition, physical IoT sensor firmware, and hosted large-language-model integration for the AI Advisor (currently a fast, deterministic rule-based responder over live data — swap in a hosted LLM call for true natural-language understanding; see the comment in backend/controllers/ai.controller.js). Everything else described in the brief has a working page, route, model, and/or schema in this package.

About

AI-powered animal production management for poultry, cattle, dairy, goats, sheep, pigs, fish and mixed livestock farms — built for Africa, ready for the world.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors