How juan0diaz/app-read-now works
Purpose and entry points
This is a library/publication management system with a React/Vite frontend and ASP.NET Core API over Supabase Postgres. The browser starts at src/main.tsx and composes application routing/UI via src/App.tsx. The API starts at backend/Program.cs; its HTTP surface is controller-based.
Frontend application shell
src/App.tsx coordinates page-level navigation for public catalog, authentication, profiles, favorites, loans, publishing, and administration. src/components/Layout.tsx provides shared application framing. Key role-oriented screens are src/pages/PublisherDashboard.tsx and src/pages/AdminDashboard.tsx; catalog interaction begins in src/pages/Home.tsx and src/pages/BookDetail.tsx.
Authentication and authorization boundary
Supabase Auth remains client-owned: src/lib/supabase.ts and src/context/AuthContext.tsx manage login, registration, OAuth callback, and session state. The API receives Supabase-issued JWTs, validates them, and converts application roles into claims through backend/Auth/RoleClaimsTransformation.cs. This separates identity issuance from business-data authorization.
API and business-data boundary
The frontend should use src/lib/api.ts for authenticated API calls rather than querying Supabase tables directly. ASP.NET controllers expose the main resource boundaries: books in backend/Controllers/LibrosController.cs, publications in backend/Controllers/PublicacionesController.cs, favorites in backend/Controllers/FavoritosController.cs, and users/genres through backend/Controllers/UsuariosController.cs and backend/Controllers/GenerosController.cs. API permissions distinguish Visualizador, Publicador, and Administrador roles.
Persistence model
Entity Framework Core maps the application domain through backend/Data/AppDbContext.cs to Supabase Postgres. Central records include books, genres, publications, users, roles, favorites, and loan associations: backend/Models/Libro.cs, backend/Models/Publicacion.cs, and backend/Models/UsuarioPrestamo.cs. Request/response shape is decoupled from entities using backend/Dtos/LibroDtos.cs and backend/Dtos/PublicacionDtos.cs.
Primary flows
Catalog reads flow browser page → src/lib/api.ts → protected/public API controller → AppDbContext → Postgres. Publishing and administration follow the same path but require role claims resolved from user-role tables. Authentication flows browser → Supabase Auth → client session/JWT; subsequent API requests carry that JWT. Favorites and loan/profile functions operate on user-associated records after API authorization.
Runtime and infrastructure
Frontend runs on Node.js with Vite, normally port 3000 (package.json, vite.config.ts). Backend runs on .NET/ASP.NET Core, normally port 5080 (backend/Backend.Api.csproj, backend/Program.cs). Supabase supplies both Auth and hosted Postgres. Codespaces/devcontainer startup generates frontend environment variables and API URL from secrets via .devcontainer/devcontainer.json and .devcontainer/scripts/generate-env.sh; backend secrets are read from environment rather than committed configuration.
Main entry points: App.tsx App routing · Program.cs API entry · AppDbContext.cs EF Core context · api.ts Authenticated API client
Components 17
React frontend
Browser application on Vite.
- Browser client
- Frontend entry
src/main.tsx - App routing · Coordinates catalog, account, publishing, and admin navigation.
src/App.tsx - Shared layout
src/components/Layout.tsx - Catalog screens · Home and book-detail interaction.
src/pages/Home.tsx - Publisher & admin screens
src/pages/PublisherDashboard.tsx - Client auth session · Manages login, OAuth callback, and JWT session state.
src/context/AuthContext.tsx - Authenticated API client · Frontend boundary for business-data calls.
src/lib/api.ts
ASP.NET Core API
Controller-based business API.
- API entry
backend/Program.cs - Resource controllers · Books, publications, favorites, users, and genres endpoints.
backend/Controllers/LibrosController.cs - Role claims transform · Maps application roles to authorization claims.
backend/Auth/RoleClaimsTransformation.cs - Book & publication DTOs · Decouple request and response shapes from entities.
backend/Dtos/LibroDtos.cs - EF Core context · Maps domain records and associations to Postgres.
backend/Data/AppDbContext.cs - Domain entities · Books, publications, and user-loan associations.
backend/Models/Libro.cs
Supabase
Managed identity and Postgres.
- Supabase Auth · Issues client session JWTs.
- Supabase Postgres · Stores books, publications, users, roles, favorites, and loans.
Other components
- Dev environment setup · Generates frontend environment and API URL from secrets.
.devcontainer/devcontainer.json
Connections 20
- Browser client → Frontend entry: loads
- Frontend entry → App routing: mounts
- App routing → Shared layout: uses
- App routing → Catalog screens: routes to
- App routing → Publisher & admin screens: routes to
- App routing → Client auth session: reads session
- Catalog screens → Authenticated API client: catalog requests
- Publisher & admin screens → Authenticated API client: role-protected requests
- Client auth session → Supabase Auth: login and OAuth
- Client auth session → Authenticated API client: supplies JWT
- Authenticated API client → API entry: authenticated HTTP
- API entry → Resource controllers: routes requests
- API entry → Role claims transform: validates JWT and resolves roles
- Resource controllers → Book & publication DTOs: uses contracts
- Resource controllers → EF Core context: reads and writes
- Role claims transform → EF Core context: reads user roles
- EF Core context → Domain entities: maps
- EF Core context → Supabase Postgres: EF Core access
- Dev environment setup → Frontend entry: generates environment
- Dev environment setup → API entry: provides secrets