How thangphan205/netconsole works
Project type and purpose
• This is a full‑stack network management tool (“Network Console Tool”) consisting of:
• A React/Vite single‑page application (frontend)
• A Python FastAPI service (backend)
• Network automation via Nornir/Netmiko
• A PostgreSQL database
• Docker Compose for development/production
• Traefik as a reverse proxy
• Purpose: provide a dashboard to view and configure switch interfaces, collect MAC/ARP/IP data, manage users/credentials, and push group configurations to Cisco/Juniper devices.
File structure
• Top‑level dirs:
• frontend/ – React SPA, Vite config, components, routes, OpenAPI‑generated client
• backend/ – FastAPI app, Alembic migrations, CRUD modules, automation scripts, email templates, tests
• docker‑compose*.yml – service definitions (frontend, backend, db, traefik)
• scripts/ – build/deploy/test helpers
• Backend layering:
• app/api/ – HTTP routes, dependency injection
• app/core/ – config, DB connection, security
• app/crud/ – data access
• app/automation/ – group‑config, inventory, device interactions
• app/models.py – ORM models
• alembic/ – schema migrations
• email‑templates/ – MJML templates and built HTML
• Frontend layering:
• src/routes/ – route components (login, admin, settings, entity pages)
• src/components/ – UI widgets and pages grouped by feature
• src/client/ – OpenAPI client classes/types for API calls
• src/hooks/ – auth and toast utilities
README for additional insights
• Confirms FastAPI + React + Docker Compose + Nornir
• Highlights features (switch info, interface config, data collection, group config)
• References environment variables, email notifications, Alembic, SMTP, Traefik dashboards
a. Main components
1. User’s Browser (React SPA)
2. Traefik Reverse Proxy
3. FastAPI Backend
– API layer (app/api)
– Business logic/CRUD layer (app/core, app/crud)
– Automation engine (app/automation using Nornir)
– Migrations (Alembic)
– Email service (SMTP)
4. PostgreSQL database
5. Network Devices (Cisco, Juniper)
6. (Optional) SMTP server
b. Relationships & data flow
• Browser → (HTTPS) → Traefik → FastAPI routes
• FastAPI ⇄ PostgreSQL for persistence (users, switches, interfaces, logs)
• FastAPI → SMTP to send emails (new account, reset password)
• FastAPI → Nornir → Network Devices to read/write configs
• Alembic invoked at startup for schema migrations
• Docker Compose brings up all services and networking
c. Architectural patterns & principles
• Layered architecture: API → service/CRUD → database
• Infrastructure as code: Docker Compose + Traefik
• Automated schema management: Alembic migrations
• Generated API client: OpenAPI → TypeScript
• Modular frontend with route-based code splitting
d. Key technologies/frameworks
• FastAPI, Pydantic, SQLAlchemy, Alembic
• React, Vite, TypeScript, JSX
• Nornir & Netmiko for device automation
• Docker, Docker Compose, Traefik
• PostgreSQL, SMTP (email)