How karan27q/erp works
Project type and purpose
• This is a full-stack Employee Management System that streamlines HR workflows: employee records, attendance, leave, payroll, tasks, reporting, and notifications.
• Frontend: React.js single-page app; Backend: Flask REST API; Database: relational (PostgreSQL/MySQL/SQLite); External services: Email service, PDF generator, CSV export.
File structure
• Top-level:
• frontend/ – React app
• backend/ (implied by README) – Flask API
• frontend contains public/ (static HTML), src/ (App.js, index.js, pages/, components/, services/, context/).
• backend (per README) includes app.py, routes/, controllers/, models/, utils/, config.py, migrations/, instance/, requirements.txt.
• Config/deployment manifests: .env files in both frontend and backend.
README for additional insights
• Tech Stack section lists libraries (Axios, React Router, Flask-RESTful, JWT).
• Folder Structure section clarifies MVC-style layering in backend and feature-based organization in frontend.
• Mentions API endpoints, authentication/authorization, environment variables, and external services (email, PDF, CSV).
a. Main components
• User’s Browser (React SPA)
• React Frontend (UI components, pages, React Router)
• Axios HTTP Client (in services/)
• Flask REST API Server (routes → controllers → models)
• Database (PostgreSQL/MySQL/SQLite)
• Authentication Layer (JWT issued by Flask, stored in client)
• External Services
• Email Service (SMTP or third-party like SendGrid)
• PDF Generation Engine (e.g. ReportLab)
• CSV Export Module
• Dev/Ops Components (environment variables, migration scripts)
b. Relationships and interactions
• Browser loads static assets from public/ via HTTP(S) → React App bootstraps.
• React App dispatches API calls (Axios) → Flask API endpoints.
• Flask API uses controllers to enforce business logic, communicates with models (ORM) → Database.
• Upon certain triggers, controllers call utils → Email Service or PDF generator.
• JWT issuance: login endpoint returns token to client → client stores token (local storage/context) → sent in Authorization header on subsequent API calls.
• Migration scripts run against Database for schema changes.
• Environment variables configure API base URLs, DB credentials, JWT secrets.
c. Architectural patterns and design principles
• Frontend: Component hierarchy + feature folders; Single-Page Application (SPA) pattern; Context API for global state.
• Backend: Layered MVC (routes → controllers → models); RESTful API design; Separation of concerns (config, utils, migrations).
• Security: JWT for stateless authentication; CORS and environment-based configs.
• Scalability: Decoupling via HTTP interface; externalizing heavy tasks (PDF, email) to separate services or queues.
d. Key technologies/frameworks
• React.js, React Router, Axios
• Python Flask, Flask-RESTful, SQLAlchemy (or ORM of choice)
• JWT library (PyJWT)
• Database (PostgreSQL/MySQL/SQLite)
• External libs: Email (SMTP or cloud API), PDF (ReportLab), CSV (Python csv)
• Dev tools: dotenv, Alembic (migrations)