How rayan569916/fleetflow works
1. This repo is a monorepo with two main runtime surfaces: a Flask-based backend API under backend/, and an Angular 21 dashboard frontend under fleetflow-dashboard/. The frontend is the primary operator UI; the backend is the data/API layer that serves it.
2. The backend entrypoint is backend/app.py, with environment-specific configuration in config.py, config_local.py, and config_development.py. extensions.py centralizes shared Flask extensions, and the rest of the backend is organized as Blueprints/routes by domain.
3. Backend persistence is model-driven. backend/models/ contains the core domain entities for logistics and finance: users, customers, shipments, tracking, invoices, fleet/drivers, cargo requests, item lists, unit prices, reports, balance sharing, featured offers, push subscriptions, and finance-related objects. The presence of db_bundle/bundle.sql and maintenance scripts like fix_db.py, check_schema.py, and seed.py indicates a relational schema with scripted migration/repair workflows.
4. The backend API boundary is split by functional area in backend/routes/: auth, dashboard, shipments, tracking, invoices, finance, fleet, reports, unit price, featured offers, balance share, cargo mobile/dashboard, loading list, general utilities, and customer support details. There are also mobile-specific routes (auth_mobile.py, cargo_mobile.py), which suggests the same backend serves both browser and mobile clients.
5. Business logic that is not just request/response handling lives in backend/services/. These include dashboard aggregation, password recovery, push notifications, and WhatsApp messaging. That means the API layer delegates outward-facing side effects and composite workflows to service modules rather than embedding them in routes.
6. Cross-cutting concerns are isolated in backend/utils/, especially authentication helpers and report-generation utilities. This separation is important because auth and reporting are used across multiple route groups rather than being tied to one domain.
7. The frontend uses Angular standalone components with a clear shell-and-feature split. src/app/layout/ defines the global chrome (dashboard-layout, header, sidebar, plus a login/signup layout and transaction layout), while src/app/dashboard/ contains feature pages for cargo requests, shipments, tracking, invoices, drivers, reports, settings, notifications, offices, and related widgets.
8. The Angular app’s state/data boundary is service-centric. src/app/services/ holds domain services that call the backend API (auth, shipment, invoice, report, unit-price, featured-offers, balance-share, cargo-request, dashboard-data, transaction, user, etc.). Shared UI state such as sidebar expansion is kept in UiStateService, and DashboardDataService provides centralized dashboard streams.
9. Frontend request flow is guarded and intercepted. auth.interceptor.ts attaches auth context to outbound requests, error.interceptor.ts normalizes API failures, and route guards (role.guard.ts, pending-changes.guard.ts) enforce access control and prevent accidental navigation away from edited forms. This makes auth and permissions a first-class architecture boundary in the UI.
10. The dashboard UI is composed from reusable widgets under src/app/shared/ and src/app/core/. Shared components include confirmation dialogs, toast notifications, card/status/transaction primitives, and mobile navigation. Core constants and typed models centralize dashboard-specific contracts so feature components stay thin.
11. Deployment is containerized and production-oriented. The root contains a Dockerfile, docker-compose.yml, and Nginx configuration under deployment/nginx/, while the Angular app has its own Dockerfile, nginx.conf, and service worker config. That implies the frontend is built as static assets and served behind Nginx, with the backend exposed separately or proxied.
12. The main runtime data flow is: user interacts with the Angular dashboard, Angular services call Flask API routes, Flask routes validate/authenticate and delegate to domain services, services read/write the underlying database models, and side-effect services may send push notifications or WhatsApp messages. File uploads are also part of the backend boundary, with backend/uploads/offers/ indicating persisted media tied to featured offers.
Main entry points: routes Routes · app.py App entry · layout Shell layout · dashboard Dashboard pages
Components 19
Flask backend
API server, domain models, services, and persistence workflows.
- App entry · Creates and wires the Flask application.
backend/app.py - Config · Environment-specific Flask configuration.
backend/config.py - Extensions · Centralized Flask extensions and shared integrations.
backend/extensions.py - Routes · HTTP boundary split into feature-specific Blueprints.
backend/routes - Services · Composite business logic and outbound side effects.
backend/services - Models · Relational domain entities for logistics and finance.
backend/models - Utils · Authentication and reporting helpers reused across routes.
backend/utils - DB bundle · Bundle SQL and repair scripts for schema maintenance.
backend/models/db_bundle/bundle.sql - Offer media · Persisted upload area for featured offer media.
backend/uploads/offers
Angular dashboard
Operator UI, client services, layouts, and reusable components.
- Shell layout · Global dashboard layout, header, sidebar, and auth shells.
fleetflow-dashboard/src/app/layout - Dashboard pages · Operator-facing feature pages and widgets.
fleetflow-dashboard/src/app/dashboard - API services · Client-side services that call backend API routes.
fleetflow-dashboard/src/app/services - Core · Typed models, constants, and client-wide shared definitions.
fleetflow-dashboard/src/app/core - Guards · Route access and navigation protection for the UI.
fleetflow-dashboard/src/app/guards - Interceptors · Auth attachment and API error normalization for requests.
fleetflow-dashboard/src/app/core/interceptors - Shared UI · Common dialogs, toasts, and dashboard primitives.
fleetflow-dashboard/src/app/shared - Angular build · Frontend build, service worker, and Nginx runtime config.
fleetflow-dashboard/Dockerfile
Deployment
Container and Nginx packaging for backend and frontend.
- Container build · Root Docker and compose setup for the monorepo.
Dockerfile - Nginx config · Nginx configuration for serving or proxying the app.
deployment/nginx/captaincargo.conf
Connections 23
- App entry → Config: loads · App startup reads environment configuration.
- App entry → Extensions: initializes · Application wiring installs shared extensions.
- App entry → Routes: registers · The entrypoint mounts domain blueprints.
- Routes → Services: delegates · Request handlers call into business workflows.
- Routes → Utils: uses · Routes reuse auth and reporting helpers.
- Services → Models: reads/writes · Services persist and query domain entities.
- Utils → Models: supports · Helpers operate across model-backed features.
- Models → DB bundle: backed by · Models are reflected in bundled schema scripts.
- Routes → Offer media: stores media · Feature routes persist uploaded offer assets.
- Shell layout → Dashboard pages: hosts · Layout shells render the main dashboard pages.
- Dashboard pages → API services: calls · Feature components fetch and mutate via services.
- API services → Routes: requests · Client services consume the Flask API boundary.
- API services → Core: types · Services share client contracts and constants.
- Shell layout → Shared UI: composes · Layouts use reusable shared UI primitives.
- Dashboard pages → Shared UI: composes · Pages build from shared widgets and controls.
- Interceptors → API services: wraps · Interceptors sit in the HTTP request pipeline.
- Guards → Shell layout: protects · Route guards constrain access to dashboard areas.
- Guards → Dashboard pages: protects · Feature routes are gated by role and pending-changes checks.
- Angular build → Shell layout: packages · Angular app is built and served as static assets.
- Container build → App entry: ships · Container build includes the Flask backend runtime.
- Container build → Angular build: ships · Container build includes the frontend runtime image.
- Nginx config → Angular build: serves · Nginx serves the compiled Angular dashboard.
- Nginx config → Routes: proxies · Proxy configuration can forward API traffic to Flask.