How luisfer2405/wisp works
1. Project shape
- This is a split frontend/backend application for a WISP operations platform.
- The root script iniciar_wisp.sh is the main local entrypoint; it starts the FastAPI backend and the Vite frontend together.
- The repo also includes database verification, seeding, and repair scripts, which suggests the backend depends on a real relational datastore rather than mock data.
2. Backend runtime and composition
- The backend is a Python API built around backend/app/main.py.
- Its structure is modular: core/ holds cross-cutting infrastructure, modules/ holds business domains, and shared/ contains reusable primitives.
- The likely request path is: router → service/business logic → model/database access → response schema.
3. Backend infrastructure layer
- core/config.py, core/database.py, core/security.py, and core/dependencies.py define the runtime environment, DB session handling, auth/security helpers, and dependency injection.
- This is the boundary where environment config, database wiring, and API security are centralized so modules do not duplicate them.
4. Backend domain modules
- The backend currently exposes at least two clear domains:
- modules/auth: login/registration and token handling.
- modules/wisp: the main operational domain for subscriber/network/business data.
- Each module follows the same pattern: router.py for HTTP endpoints, schemas.py for request/response contracts, models.py for persistence objects, and service.py where applicable for business rules.
5. Backend shared abstractions
- shared/enums.py, shared/exceptions.py, and shared/utils.py indicate common domain values, typed error handling, and helper functions shared across modules.
- This usually means business constraints are enforced consistently across auth and WISP workflows, rather than inline in individual endpoints.
6. Data and validation tooling
- The backend includes several operational scripts: seed_data.py, fix_db.py, validate_postgres.py, verify_db_schema.py, check_alignment.py, and check_data.py.
- These files imply the repo is schema-sensitive and probably uses PostgreSQL, with explicit checks to keep code, enums, and DB state aligned.
- The docs/database.md and related docs reinforce that the data model is an important architectural boundary.
7. Authentication and access control flow
- The frontend has AuthContext, ProtectedRoute, LoginPage, RegisterPage, and auth service files; the backend has an auth module and security helpers.
- The architecture is likely JWT-based: user credentials go from the auth UI to the backend auth router/service, a token is returned, and the frontend stores it in context and uses it for protected API requests.
- Protected UI routes and backend dependency checks together define the access boundary.
8. Frontend structure
- The frontend is a TypeScript React app organized by feature rather than by technical layer.
- There are route-level modules for major business areas: dashboard, subscribers, network, billing, orders, tickets, reports, settings, cashbox, analytics, and profile.
- layouts/DashboardLayout.tsx, Sidebar, and TopNav define the shared application shell around those pages.
9. Frontend reusable UI and workflow components
- The components/ directory contains business-focused reusable widgets such as client tables, filters, search bars, modals, metrics panels, pagination, payment/order creation, and table reports.
- This indicates the UI is built from a set of domain-specific primitives reused across subscriber, billing, and operational screens.
- Pages are thin orchestration layers; the interaction-heavy logic lives in these shared components.
10. Frontend data access boundary
- services/api.ts, auth.service.ts, auth.ts, and billing.service.ts centralize HTTP communication with the backend.
- hooks/useClients.ts suggests local data-fetching and state orchestration live close to the feature consuming them, rather than in a global store.
- The frontend therefore depends on the backend through a small service layer, not direct ad hoc fetch calls from every page.
11. Business domains represented in the UI
- The largest visible domains are subscriber management, network inventory/topology, billing and payments, orders/work orders, tickets, and admin/settings.
- network/ includes pages for nodes, OLTs, ONUs, and network maps, which aligns with the separate docs/olt-integration.md.
- The app is not just CRUD; it appears to support operational workflows like onboarding clients, generating bills, tracking payments, and managing service tickets.
12. External and operational boundaries
- docker-compose.yml, .env.example, and the startup script imply environment-based configuration and container-friendly deployment.
- backend/test_api.py, test_jwt.py, and verification scripts show the repo includes lightweight validation around API behavior and security.
- The docs folder is part of the architecture: it captures business rules, database design, and OLT integration expectations that shape how frontend and backend should evolve.
13. What to show in an architecture diagram
- Draw the frontend as a React/Vite SPA with a shared shell, route modules, reusable business components, and a service/auth layer.
- Draw the backend as a FastAPI application with a core infrastructure layer and domain modules for auth and WISP operations.
- Put the database behind backend models/services, and show auth/JWT as the cross-cutting security path between frontend and backend.
- Include scripts/docs/docker as supporting operational artifacts around the application, not part of the runtime request path.
Main entry points: App.tsx App routes · main.py API app · dependencies.py Dependencies · router.py Auth module
Components 22
Frontend SPA
React/Vite client with shared shell, auth state, feature pages, and API services.
- Frontend boot · Client application bootstrap and root mounting.
frontend/src/main.tsx - App routes · Top-level application routing and page composition.
frontend/src/App.tsx - Dashboard shell · Shared authenticated layout for the main app experience.
frontend/src/layouts/DashboardLayout.tsx - Auth state · Stores login state and token/session behavior for the UI.
frontend/src/contexts/AuthContext.tsx - Protected route · Blocks unauthenticated access to private screens.
frontend/src/components/ProtectedRoute.tsx - API client · Central HTTP layer used by feature screens.
frontend/src/services/api.ts - Auth service · Frontend auth-specific API calls and token handling.
frontend/src/services/auth.service.ts - Login · User sign-in screen connected to the auth flow.
frontend/src/modules/auth/LoginPage.tsx - Clients · Representative subscriber-management screen.
frontend/src/modules/subscribers/ClientsPage.tsx - Billing · Representative billing and payments workflow screen.
frontend/src/modules/billing/BillingGeneratePage.tsx - Network · Representative network operations screen.
frontend/src/modules/network/NetworkPage.tsx
Backend API
FastAPI application with core infrastructure, domain modules, and shared primitives.
- API app · Backend application entrypoint and router assembly.
backend/app/main.py - Config · Environment and application configuration.
backend/app/core/config.py - Database · Database engine and session setup.
backend/app/core/database.py - Security · JWT and authentication/security primitives.
backend/app/core/security.py - Dependencies · FastAPI dependency providers for shared runtime services.
backend/app/core/dependencies.py - Auth module · Authentication routes, schemas, models, and service logic.
backend/app/modules/auth/router.py - WISP module · Main operational domain for subscriber and network data.
backend/app/modules/wisp/router.py - Shared types · Enums and reusable error/util helpers shared across modules.
backend/app/shared/enums.py
Ops & Data
Startup, database, docs, and verification scripts that support the runtime systems.
- Start app · Local script that launches backend and frontend together.
iniciar_wisp.sh - DB tooling · Schema checks, seeding, repair, and PostgreSQL validation scripts.
backend/validate_postgres.py - Data docs · Documentation that defines database and business-rule boundaries.
docs/database.md
Connections 25
- Start app → API app: starts · Launches the FastAPI backend.
- Start app → Frontend boot: starts · Launches the Vite frontend.
- Frontend boot → App routes: mounts · Bootstraps the top-level app.
- App routes → Dashboard shell: uses · Wraps authenticated screens in the shared layout.
- App routes → Login: routes to · Exposes the auth entry screen.
- App routes → Clients: routes to · Exposes subscriber workflows.
- App routes → Billing: routes to · Exposes billing workflows.
- App routes → Network: routes to · Exposes network operations screens.
- Auth state → Protected route: protects · Provides session state for guarded routes.
- Login → Auth service: calls · Submits credentials through the auth client.
- Auth service → API client: uses · Shares the common HTTP client.
- API client → API app: requests · Frontend API traffic targets the backend.
- API app → Config: loads · Initializes the app from configuration.
- API app → Dependencies: injects · Uses dependency providers across routes.
- API app → Auth module: includes · Registers authentication endpoints.
- API app → WISP module: includes · Registers core operational endpoints.
- Dependencies → Database: binds · Provides database sessions to request handlers.
- Dependencies → Security: binds · Provides auth/security dependencies.
- Auth module → Security: uses · Validates identity and issues tokens.
- Auth module → Shared types: uses · Shares enums and error conventions.
- WISP module → Database: persists via · Relies on relational persistence.
- WISP module → Shared types: uses · Shares domain values and common helpers.
- Database → DB tooling: checked by · Database state is verified and repaired by scripts.
- DB tooling → Data docs: guided by · Scripts align with documented schema and rules.
- Config → Data docs: constrained by · Runtime config follows documented data boundaries.