How yaolya/medkit works
Project type and purpose
• This is a full‑stack web application (MedKit) for tracking personal medical supplies.
• Frontend: React.js SPA that lets users browse medications, manage categories, build shopping lists, and track expirations.
• Backend: Python Flask REST API providing CRUD endpoints for users, medicaments, categories, products (user’s items), and lists.
• Database: PostgreSQL with tables for medicament, user, category, product, manufacturer, disease, and many‑to‑many join tables.
File structure
• Top‑level folders:
• frontend/ – standard Create‑React‑App layout with src/, public/, package.json, components, API wrappers.
• web/backend/ – Flask application with modular route packages (category/, medicament/, product/, user/), config.py, database.py, models.py, main.py.
• Patterns:
• Frontend follows component‑based design + API layer under src/api.
• Backend follows a simple MVC: models in models.py, controllers/routes in each module’s route.py, app factory in main.py.
• Config & deployment: .flaskenv, .profile, .gitignore, README, user_manual.md.
README for additional insights
• Confirms tech stack: React.js UI, Flask API, PostgreSQL DB.
• Describes user roles and feature workflows (add medications, categories, lists, track expiration).
• Client/Browser (React SPA)
• Frontend Application
• UI Components (pages, forms, filters)
• API Service Layer (CategoriesApi, MedicamentsApi, ListsApi, UserApi)
• Backend Application (Flask)
• Request Router (main.py)
• Controllers/Routes (category.route.py, medicament.route.py, product.route.py, user.route.py)
• Business Logic & Validation (in route handlers and possibly service classes)
• Data Models (models.py)
• Configuration & DB Connection (config.py, database.py)
• Database (PostgreSQL) with ER tables: medicament, product, user, category, manufacturer, disease, join tables.
• External/Infrastructure: optionally Docker or hosting platform if used (not in code).
b. Relationships & interactions:
• Browser sends HTTP(S) requests to Flask endpoints via fetch/axios calls in API wrappers.
• Frontend API layer maps UI events to REST calls (GET/POST/PUT/DELETE).
• Flask routes dispatch to model queries through SQLAlchemy (or direct SQL), enforce business rules.
• SQLAlchemy maps Python models to PostgreSQL tables.
• Backend responds with JSON; React updates UI state/context/hooks.
• Authentication flows use tokens stored via utils/auth and utils/refreshToken.
c. Architectural patterns & design principles:
• Frontend: Component‑based design, custom hooks for data fetching, centralized context for global state.
• Backend: Modular MVC (models ↔ routes), clear separation between route definitions and DB setup.
• RESTful API design, one endpoint per resource.
• Many‑to‑many and one‑to‑many relationships encoded in DB and exposed via nested JSON.
d. Key technologies & libraries:
• React.js, React Router, Context API, custom hooks (useFetching, usePosts).
• Axios or fetch for API calls (in src/api).
• Flask, Flask‑SQLAlchemy (implied by database.py), flask‑dotenv (.flaskenv).
• PostgreSQL.