A comprehensive accounting application built with Django REST Framework backend and React TypeScript frontend.
- Repository: cs50w
- Branch:
web50/projects/2020/x/capstone - Course: CS50's Web Programming with Python and JavaScript
- Project: Final Capstone Project
- Author: calnet
- Year: 2025
- Customer Management: Full CRUD operations for customer accounts
- Supplier Management: Manage supplier relationships and accounts
- Banking Integration: Bank account management and reconciliation
- Chart of Accounts: Flexible account structure with nominal codes
- Transaction Management: Complete transaction processing system
- Financial Reporting: Basic reporting capabilities
- REST API: Comprehensive API with Django REST Framework
- Modern Frontend: React 18 with TypeScript and Material-UI
- Authentication: JWT-based authentication system
- Data Grid: Advanced data grid with Material-UI X
- Responsive Design: Mobile-friendly interface
- Development Scripts: Automated setup and server management
βββ backend/ # Django REST API
β βββ users/ # User management & authentication
β βββ customers/ # Customer operations
β βββ suppliers/ # Supplier management
β βββ banking/ # Bank account handling
β βββ ledgers/ # Chart of accounts
β βββ transactions/ # Transaction management
β βββ management/ # Data management utilities
β βββ backend/ # Django settings & configuration
β
βββ frontend/ # React TypeScript SPA
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ views/ # Page components
β β βββ contexts/ # React contexts
β β βββ utils/ # Utility functions
β β βββ types/ # TypeScript definitions
β β βββ services/ # API services
β β βββ layout/ # Layout components
β β βββ menu-items/ # Navigation configuration
β β βββ routes/ # Route definitions
β β βββ themes/ # Theme configuration
β β βββ ui-component/ # Base UI components
β βββ public/
β
βββ scripts/ # Development & deployment scripts
- Django 4.1+: Web framework
- Django REST Framework: API development
- SQLite: Database (development)
- JWT Authentication: Secure API access via djangorestframework-simplejwt
- CORS Headers: Cross-origin support
- Python Decouple: Environment configuration management
- React 18: UI library
- TypeScript: Type safety
- Material-UI (MUI): Component library with Data Grid
- Vite: Build tool and dev server
- Axios: HTTP client
- React Router DOM: Client-side routing
- Formik & Yup: Form handling and validation
- Emotion: CSS-in-JS styling
- Black & Autopep8: Python code formatting
- ESLint: TypeScript/JavaScript linting
- Scripts: Automated development workflows
- VS Code: Development environment with devcontainer support
- Node.js 18+ and npm
- Python 3.11+
- Git
- VS Code (recommended for development)
-
Clone the repository
git clone https://github.com/calnet/cs50w.git cd capstone -
Run setup script
chmod +x scripts/setup.sh ./scripts/setup.sh
-
Start the servers
Option A: Local Development (Manual)
# Terminal 1: Start Django backend cd backend python3 manage.py runserver 0.0.0.0:8000 # Terminal 2: Start React frontend cd frontend npm run dev -- --host 0.0.0.0 --port 5173
Option B: Using Scripts (DevContainer/Container Environment)
# For devcontainer/container environments chmod +x scripts/start-backend.sh scripts/start-frontend.sh ./scripts/start-backend.sh # Backend in background ./scripts/start-frontend.sh # Frontend in background
Note: The provided scripts are configured for container environments. For local development, use Option A or modify the script paths.
-
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- Admin Panel: http://localhost:8000/admin
-
Create virtual environment
cd backend python3 -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment
The project uses a
.envfile in the root directory for configuration. Make sure it exists with the proper Django settings:# Check if .env exists ls -la .env # Edit .env with your preferred editor if needed code .env # or nano .env, or vim .env
-
Run migrations
python3 manage.py migrate python3 manage.py createsuperuser
-
Start development server
# Start Django server on all interfaces (for container/network access) python3 manage.py runserver 0.0.0.0:8000
-
Install dependencies
cd frontend npm install -
Start development server
# Start Vite dev server on all interfaces (matching the scripts) npm run dev -- --host 0.0.0.0 --port 5173
All API endpoints (except authentication) require a valid JWT token.
# Login
POST /api/auth/token/
{
"email": "user@example.com",
"password": "password"
}
# Refresh token
POST /api/auth/token/refresh/
{
"refresh": "refresh_token_here"
}GET /api/customers/ # List customers
POST /api/customers/ # Create customer
GET /api/customers/{id}/ # Get customer
PUT /api/customers/{id}/ # Update customer
DELETE /api/customers/{id}/ # Delete customerGET /api/banking/ # List bank accounts
POST /api/banking/ # Create bank accountGET /api/suppliers/ # List suppliers
POST /api/suppliers/ # Create supplier
GET /api/suppliers/{id}/ # Get supplier
PUT /api/suppliers/{id}/ # Update supplier
DELETE /api/suppliers/{id}/ # Delete supplierGET /api/transactions/ # List transactions
POST /api/transactions/ # Create transaction
GET /api/transactions/{id}/ # Get transaction
PUT /api/transactions/{id}/ # Update transaction
DELETE /api/transactions/{id}/ # Delete transactionGET /api/layouts/ # Account layouts
GET /api/coa_categories/ # Account categories
GET /api/nominal_types/ # Nominal types
GET /api/nominal_codes/ # Nominal codesCreate a .env file in the project root directory:
DEBUG=True
SECRET_KEY=your-secret-key-here
DATABASE_URL=sqlite:///backend/db.sqlite3
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:5173
# For production
DATABASE_URL=postgresql://user:password@localhost:5432/dbnameThe frontend automatically detects the backend URL based on the environment:
- Development:
http://localhost:8000 - Production: Configure in
src/services/api.ts
cd backend
python3 manage.py test
# Or with pytest
pytestcd frontend
npm test-
Set environment variables
DEBUG=False SECRET_KEY=production-secret-key DATABASE_URL=postgresql://... ALLOWED_HOSTS=yourdomain.com
-
Install dependencies
pip install -r requirements.txt cd frontend && npm install
-
Run migrations
cd backend python3 manage.py migrate python3 manage.py collectstatic -
Build frontend
cd frontend npm run build
The project includes several automation scripts in the scripts/ directory:
setup.sh: Initial project setup and dependency installationstart-backend.sh: Start Django backend server (port 8000)start-frontend.sh: Start React frontend server (port 5173)start-servers.sh: Attempt to start both serversservers-test.sh: Run development servers in test mode
Important: These scripts are configured for DevContainer/container environments with paths like /workspaces/capstone. For local development on macOS, use the manual commands provided in the Quick Start section.
- Backend: Follow PEP 8, use Black and Autopep8 formatters
- Frontend: Use ESLint and Prettier
- TypeScript: Strict mode enabled
The project follows a clear separation between backend API and frontend SPA:
- Backend Apps: Each Django app handles a specific domain (users, customers, etc.)
- Frontend Components: Organized by feature with reusable UI components
- API Design: RESTful endpoints with consistent naming conventions
- Create feature branch:
git checkout -b dev/feature/new-feature - Make changes and commit:
git commit -m "Add new feature" - Push and create PR:
git push origin dev/feature/new-feature
- Create models in appropriate app
- Add serializers for API representation
- Create views with proper error handling
- Add URL patterns
- Write tests
- Update API documentation
- Create TypeScript interfaces
- Add API service methods
- Create React components
- Add routing if needed
- Update navigation
- Write tests
CORS Errors
- Ensure frontend URL is in
CORS_ALLOWED_ORIGINS - Check that both servers are running
Database Issues
- Run migrations:
python3 manage.py migrate - Reset database:
python3 manage.py flush
Build Errors
- Clear node_modules:
rm -rf node_modules && npm install - Clear browser cache and restart dev server
Script Permission Issues
- Make scripts executable:
chmod +x scripts/*.sh - Run setup script:
./scripts/setup.sh
Enable Django debug toolbar in development:
# backend/settings.py
if DEBUG:
INSTALLED_APPS += ['debug_toolbar']
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']For Container/DevContainer Environments:
# Start individual servers (recommended)
./scripts/start-backend.sh # Django on port 8000
./scripts/start-frontend.sh # React on port 5173
# Attempt to start both servers at once
./scripts/start-servers.sh
# Test server configuration
./scripts/servers-test.shFor Local macOS Development:
# Manual server startup (recommended for local development)
# Terminal 1: Backend
cd backend && python3 manage.py runserver 0.0.0.0:8000
# Terminal 2: Frontend
cd frontend && npm run dev -- --host 0.0.0.0 --port 5173
# Check running processes
ps aux | grep -E '(runserver|vite)'- Fork the repository
- Create your feature branch:
git checkout -b dev/feature/amazing-feature - Follow the code style guidelines
- Add tests for new functionality
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin dev/feature/amazing-feature - Create a Pull Request
- Use the provided scripts for consistent environment setup
- Follow the established project structure
- Update documentation when adding new features
- Test both backend API and frontend integration
This project is part of CS50's Web Programming with Python and JavaScript course.
For questions or issues:
- Create an issue in the repository
- Check the troubleshooting section above
- Review the development scripts for common tasks
Built with β€οΈ for CS50 Web Development Course
A comprehensive accounting application demonstrating full-stack development with Django REST Framework and React TypeScript.