How mati-gaston/pokedex-app works
Project type and purpose
• This is a full-stack web application (“Pokedex + Gestor de usuarios”) with:
• A React/React Router DOM frontend (port 3000)
• A Node.js + Express backend (port 4000)
• A MySQL database
• External integration with the public PokéAPI
• Main features: JWT-based authentication, role-based access (admin/viewer), user CRUD, paginated/searchable Pokedex.
File structure
• Top level:
• backend/ – Node.js + Express server
– index.js (entry point)
– db.js (MySQL connection)
– controllers/authController.js
– routes/auth.js, routes/users.js
– middleware/authMiddleware.js
– database.sql
• frontend/ – React app
– src/components (NavBar, protected-route, etc.)
– src/context/AuthContext.js (holds auth state + JWT)
– src/pages (Login, Admin, Pokedex, etc.)
– public/index.html + images
• Architectural hints:
• Follows a layered pattern in backend: Routes → Controllers → DB access
• Frontend uses Context for auth, React Router for routing.
README for additional insights
• Technology stack: React, Bootstrap, Node.js, Express, JWT, bcryptjs, dotenv, MySQL
• Database setup script (database.sql) creates usuarios table + seed user
• Frontend fetches both your backend API (for auth & user management) and the external PokéAPI (for Pokémon data).
a. Main components
• Client-Browser (React SPA)
• Web Server (Express API)
• MySQL Database
• External Service (PokéAPI)
• localStorage (in the browser) for JWT
b. Relationships & data flows
1. User opens React UI → UI triggers HTTP requests
2. Authentication flow:
– Login page → POST /auth/login → Express → authController → MySQL
– Express generates JWT → returns to client → stored in localStorage
3. Protected routes (admin, user CRUD):
– React sends JWT in Authorization header → authMiddleware verifies → controllers handle DB operations
4. Pokedex page:
– React directly calls external PokéAPI → renders paginated/search data
5. Admin pages:
– React calls /users routes → Express → MySQL
c. Architectural patterns & principles
• Layered architecture (Presentation, API routing, controllers/services, persistence)
• Stateless sessions via JWT
• Separation of concerns (frontend vs. backend)
• Context API for global state in React
d. Technologies & frameworks
• React (+ React Router, Bootstrap)
• Node.js + Express
• MySQL (via mysql2 or similar driver in db.js)
• JWT (jsonwebtoken) & bcryptjs for auth
• dotenv for environment configuration