How vanneszias/drone-manager works
Project Type and Purpose
• This is a full-stack hybrid application combining a Next.js frontend with a Python/Flask API backend.
• The frontend is built with Next.js v13 App Router (TypeScript, Tailwind CSS) to render pages and UI components.
• The backend is a Flask app (in the /api folder) exposing REST endpoints for resources like drones, events, zones, etc.
• The entire stack is deployed on Vercel: Next.js as edge/SSR, Flask as Python serverless functions.
File Structure Analysis
• /app
• Next.js App Router pages under /app/dashboard/... (one page per resource) and global layouts & CSS.
• app/types.ts defines shared data types.
• /components
• Reusable React components organized by feature (dashboard/resource) and UI primitives (components/ui).
• /hooks
• Custom React hooks (useDrones, useEvents, etc.) encapsulate data fetching via the API.
• /api
• app.py defines the Flask application and route registrations.
• config.py holds environment and database settings.
• /helpers contains one helper per resource (e.g. drone_helper.py) encapsulating DB logic.
• db.sql
• Database schema and seed statements.
• Configuration & build files
• next.config.js with rewrite rules mapping /api/* to the Flask server (locally to 127.0.0.1:5328, in prod to serverless).
• vercel.json / requirements.txt for Python serverless deployment.
README Insights
• Explains the Next.js ↔ Flask integration via rewrite rules.
• On localhost, Next.js proxies /api calls to a local Flask server; in production, Flask lives as Vercel serverless functions.
• Encourages leveraging Python AI libraries on the backend.
a. Main Components
• User / Browser: issues HTTP requests, renders UI.
• Next.js Frontend (Edge/SSR):
• Pages & Layouts (/app)
• React Components (/components)
• Hooks (/hooks) for data layer
• Tailwind CSS & global assets.
• API Gateway / Rewrite Layer: next.config.js rewrite of /api/*.
• Flask Backend (Python serverless functions):
• api/app.py routes
• helpers/*_helper.py for data access
• config.py for DB settings
• Database: relational DB (SQLite/Postgres) defined via db.sql.
• Hosting/Infrastructure: Vercel platform (Edge for Next.js, serverless for Flask).
b. Relationships & Data Flows
1. Browser → Next.js page (SSR or CSR)
2. UI (React) → Hook (e.g. useDrones)
3. Hook → HTTP GET/POST to /api/drones
4. Next.js rewrite → Flask function endpoint
5. Flask route → calls corresponding Helper → DB query via db.sql schema
6. Data returned back up the chain to UI.
7. User sees updated UI.
c. Architectural Patterns & Principles
• Client-Server Separation: clearly defined frontend vs backend responsibilities.
• Monorepo Hybrid: both Next.js and Flask live in same codebase.
• Serverless Functions: each Flask endpoint deploys as an independent lambda.
• DRY + Single Source of Truth: shared types (app/types.ts), centralized helpers in Flask.
• Feature-based Componentization in React.
d. Key Technologies & Frameworks
• Frontend: Next.js (TypeScript, App Router), React Hooks, Tailwind CSS
• Backend: Flask (Python 3), serverless on Vercel, WSGI
• Database: SQLite/PostgreSQL (schema in db.sql)
• Deployment: Vercel (edge functions for Next.js, Python serverless)
• Build & Config: next.config.js, vercel.json, requirements.txt, tsconfig.json