Skip to content

Latest commit

 

History

History
163 lines (133 loc) · 7.08 KB

File metadata and controls

163 lines (133 loc) · 7.08 KB

Midrift Hurinet Financial Management Platform

Overview

This is a comprehensive financial management platform designed specifically for NGOs and non-profit organizations. The application provides complete budget tracking, expense management, donor grant oversight, project-based accounting, and financial reporting capabilities. Built with Django/Python backend and React/TypeScript frontend with a focus on transparency and audit compliance.

Current Status: Django backend infrastructure complete with comprehensive models, migrations, and API endpoints. All 9 core modules implemented with proper relationships and audit trails.

User Preferences

Preferred communication style: Simple, everyday language.

System Architecture

Frontend Architecture

  • Framework: React 18 with TypeScript
  • Routing: Wouter for client-side routing
  • UI Components: Radix UI primitives with shadcn/ui component library
  • Styling: Tailwind CSS with CSS variables for theming
  • State Management: TanStack Query (React Query) for server state
  • Forms: React Hook Form with Zod validation
  • Build Tool: Vite with TypeScript support

Backend Architecture

  • Framework: Django 4.2 with Python 3.11
  • Database ORM: Django ORM with PostgreSQL
  • Authentication: Django built-in authentication with custom User model
  • API Design: RESTful JSON API endpoints with Django views
  • Architecture: Modular Django apps for each accounting function
  • Session Management: Django sessions with database storage

Database Architecture

  • Database: PostgreSQL (via Neon Database serverless)
  • Schema Management: Drizzle Kit for migrations
  • Connection: Connection pooling with @neondatabase/serverless
  • Structure: Normalized relational design with foreign key constraints

Key Components

Authentication System

  • Replit OpenID Connect integration for secure authentication
  • Session-based authentication with PostgreSQL session storage
  • Role-based access control (admin, finance, auditor, project_manager)
  • Automatic session refresh and logout handling

Financial Management Modules (Django Apps)

  1. Authentication: Custom user model with roles (admin, finance, auditor, project_manager)
  2. Budgeting: Annual and project-specific budget creation with approval workflows
  3. Expenses: Detailed expense tracking with categorization and approval workflows
  4. Bank Accounts: Multi-account support with reconciliation and statement import features
  5. Donors: Donor management and grant tracking with conditionality and reporting obligations
  6. Projects: Project-based accounting with milestones, documents, and budget allocation
  7. General Ledger: Double-entry accounting system with chart of accounts and journal entries
  8. Audit Trail: Comprehensive activity logging for compliance with generic foreign keys
  9. Reports: Financial reporting with customizable templates and export capabilities

Data Models

  • Users: Authentication and role management
  • Donors: Contact and relationship management
  • Projects: Project lifecycle and budget tracking
  • Budget Categories: Hierarchical expense categorization
  • Budgets: Annual/project budgets with version control
  • Bank Accounts: Multi-account financial tracking
  • Expenses: Detailed expense records with approvals
  • Ledger Entries: Double-entry accounting records
  • Audit Trail: Immutable activity logs

UI/UX Components

  • Responsive design with mobile-first approach
  • Dark/light theme support via CSS variables
  • Accessible components using Radix UI primitives
  • Data tables with sorting, filtering, and pagination
  • Interactive dashboards with metrics and charts
  • Form validation with real-time feedback

Data Flow

Authentication Flow

  1. User initiates login via Replit Auth
  2. OpenID Connect handshake validates user identity
  3. Session created and stored in PostgreSQL
  4. User data synchronized with local user table
  5. Role-based permissions applied to API access

Financial Data Flow

  1. Budget Creation: Categories → Budgets → Approval → Activation
  2. Expense Processing: Entry → Categorization → Approval → Ledger Recording
  3. Bank Reconciliation: Transaction Import → Matching → Reconciliation
  4. Reporting: Data Aggregation → Calculations → Visualization

API Request Flow

  1. Client authentication check via session middleware
  2. Request validation using Zod schemas
  3. Database operations through Drizzle ORM
  4. Response formatting with error handling
  5. Audit trail logging for all modifications

External Dependencies

Core Dependencies

  • @neondatabase/serverless: PostgreSQL database connectivity
  • drizzle-orm: Type-safe database operations
  • @tanstack/react-query: Server state management
  • @radix-ui/*: Accessible UI component primitives
  • tailwindcss: Utility-first CSS framework
  • react-hook-form: Form state management
  • zod: Schema validation

Authentication Dependencies

  • openid-client: OpenID Connect authentication
  • passport: Authentication middleware
  • express-session: Session management
  • connect-pg-simple: PostgreSQL session store

Development Dependencies

  • vite: Development server and build tool
  • typescript: Type safety and tooling
  • tsx: TypeScript execution for development
  • esbuild: Production build optimization

Deployment Strategy

Development Environment

  • Vite development server with HMR
  • Express server with middleware integration
  • Database migrations via Drizzle Kit
  • Environment-based configuration

Production Build Process

  1. Frontend build via Vite (outputs to dist/public)
  2. Backend compilation via esbuild (outputs to dist/)
  3. Database schema deployment via Drizzle push
  4. Static file serving through Express

Environment Configuration

  • DATABASE_URL: PostgreSQL connection string
  • SESSION_SECRET: Session encryption key
  • REPLIT_DOMAINS: Allowed authentication domains
  • ISSUER_URL: OpenID Connect provider URL

Scaling Considerations

  • Connection pooling for database efficiency
  • Session storage in PostgreSQL for horizontal scaling
  • Static asset optimization through Vite
  • API rate limiting and error handling
  • Comprehensive audit logging for compliance

Recent Changes

January 29, 2025 - Django Backend Implementation Complete

✓ Implemented comprehensive Django models for all 9 core modules ✓ Created proper foreign key relationships with resolved naming conflicts
✓ Generated and applied all database migrations successfully ✓ Set up Django admin interface with custom User model ✓ Created URL routing structure for all modules with placeholder views ✓ Established API endpoints returning JSON responses ✓ Created superuser account (admin/admin) for testing ✓ Added beautiful landing page template with system overview ✓ Confirmed Django server operational with API status endpoint working

→ Next: Integrate Django backend with existing React frontend → Next: Implement comprehensive business logic in Django views → Next: Create proper authentication flow between frontend and backend