How rowanb141/projectdatabasewebapp works
Project type and purpose
• This is a full-stack web application (“ProjectDatabaseWebApp”) that lets authenticated users view/check-in/check-out hardware and manage projects.
• Frontend: React (via Vite) with Tailwind CSS.
• Backend: Flask (Python) exposing a JSON REST API.
• Data store: MongoDB.
File structure
• Top-level:
– backend/ (Flask app, API routes, static “dist” folder)
– frontend/ (React + Vite source & configs)
• backend/app/routes/ splits concerns into auth.py, hardware.py, projects.py.
• backend/dist/ holds the production build of the frontend (index.html + JS/CSS assets) to be served by Flask.
• Configuration/deployment: Procfile (Heroku), .env.example, requirements.txt, postman_collection.json.
• frontend uses vite.config.js, tailwind.config.js, ESLint, and has pages/components structured in src/.
Extract README insights
• Dev setup requires running two servers: Vite for frontend, Flask for backend.
• JWT-based auth and protected endpoints.
• MongoDB runs locally or remotely (Compass optional).
• Deployment uses Heroku (git subtree push).
Main components
a. Client Layer
– Browser (React app)
– Dev: Vite Dev Server (localhost:5173)
– Prod: Static files served by Flask at / (backend/dist)
b. API Layer
– Flask application (run.py)
– Routes:
• /api/auth (register, login → issues JWT)
• /api/hardware (GET, PUT checkout/checkin)
• /api/projects (CRUD)
– Extensions: JWT manager, PyMongo connector
c. Data Layer
– MongoDB (local or hosted)
– Collections: users, hardware, projects
d. External/devops
– Postman (postman_collection.json)
– Smoke tests (backend/smoke_test.py)
– Heroku (Procfile)
Relationships & interactions
• Browser ↔ Frontend: user interacts via React UI → sends API requests (with JWT in Authorization header).
• Frontend → Flask API: REST calls over HTTP → JSON payloads.
• Flask API → MongoDB: queries/updates via PyMongo.
• Build pipeline:
– npm run build → dist/ → copied into backend/dist → Flask serves static.
• Auth flow: login/register → token issued → stored in browser localStorage → subsequent calls include token header.
Architectural patterns & design principles
• Separation of concerns: UI layer vs business/API layer vs data layer.
• Component-based UI (React).
• Modular backend routes (each resource in its own module).
• Environment-driven configuration (.env) for secrets and URIs.
• Testability: test directory, smoke tests, Postman.