A comprehensive retirement planning application with Brazilian Real (BRL) support. Built with Django REST Framework backend and Next.js 14 frontend.
- ๐ Comprehensive Calculations: Two-phase retirement planning (accumulation + sustainability)
- ๐ Interactive Charts: Beautiful visualizations with Recharts showing wealth accumulation
- ๐ฐ BRL Currency Support: Full Brazilian Real formatting and localization
- ๐ฏ Advanced Options:
- Custom inflation rates
- Annual return rates
- Monthly contribution increases
- One-time deposits and withdrawals
- ๐ฑ Responsive Design: Mobile-first approach with modern UI
- โก Real-time Updates: Instant calculations with interactive sliders
- ๐จ Modern UI: Built with Tailwind CSS and shadcn/ui components
- Python 3.10 or higher
- Node.js 18.0 or higher
- npm, yarn, or pnpm
UV is a blazingly fast Python package installer. Setup time: ~3 seconds!
# Install UV (one time)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Run automated setup
./setup-uv.shOr manually:
# Backend
cd backend
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt
python manage.py migrate
python manage.py runserverSee backend/UV_SETUP.md for detailed UV instructions.
Backend Setup (Django)
- Navigate to the backend directory:
cd backend- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run migrations:
python manage.py migrate- Start the development server:
python manage.py runserverThe API will be available at http://localhost:8000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install
# or
yarn install
# or
pnpm install- Create environment file:
echo "NEXT_PUBLIC_API_URL=http://localhost:8000" > .env.local- Start the development server:
npm run dev
# or
yarn dev
# or
pnpm devThe application will be available at http://localhost:3000
-
Configure Basic Parameters:
- Current age
- Initial investment
- Monthly contributions
- Desired retirement age
- Monthly expenses after retirement
-
Advanced Settings (Optional):
- Annual return rate (default: 10%)
- Annual inflation rate (default: 5%)
- Annual contribution increase rate
-
Add One-time Events (Optional):
- One-time deposits (e.g., inheritance, bonus)
- One-time withdrawals (e.g., emergency expenses)
-
Calculate: Click the "CALCULAR APOSENTADORIA" button to see your results
financex/
โโโ backend/ # Django REST API
โ โโโ calculator/ # Calculator app
โ โ โโโ calculations.py # Core calculation engine
โ โ โโโ serializers.py # DRF serializers
โ โ โโโ views.py # API views
โ โ โโโ urls.py # URL routing
โ โโโ financex/ # Django project settings
โ โโโ manage.py # Django management script
โ
โโโ frontend/ # Next.js application
โโโ src/
โ โโโ app/ # Next.js 14 App Router
โ โโโ components/ # React components
โ โ โโโ ui/ # shadcn/ui components
โ โ โโโ BasicInputs.tsx
โ โ โโโ AdvancedInputs.tsx
โ โ โโโ OneTimeEventsModal.tsx
โ โ โโโ RetirementChart.tsx
โ โ โโโ ResultsDisplay.tsx
โ โ โโโ RetirementCalculator.tsx
โ โโโ lib/ # Utilities and types
โ โโโ api.ts # API client
โ โโโ types.ts # TypeScript interfaces
โ โโโ utils.ts # Helper functions
โโโ package.json
The calculator uses compound interest formulas to project wealth accumulation:
Monthly Rate = (1 + Annual Rate)^(1/12) - 1
Balance = Balance ร (1 + Monthly Rate) + Monthly Contribution
Features:
- Monthly compounding
- Annual contribution increases
- One-time deposits/withdrawals
- Inflation adjustment
Calculates sustainability of retirement funds:
Balance = Balance ร (1 + Monthly Rate) - Monthly Withdrawal
Withdrawal adjusted annually for inflation
Continues until balance reaches zero or age 120.
Calculate retirement plan.
Request Body:
{
"current_age": 32,
"initial_investment": 200000.00,
"monthly_contribution": 1200.00,
"retirement_age": 65,
"monthly_expenses_retirement": 5000.00,
"annual_return_rate": 10.0,
"annual_inflation_rate": 5.0,
"annual_contribution_increase": 0.0,
"one_time_deposits": [
{"year": 2025, "month": 6, "value": 10000.00}
],
"one_time_withdrawals": []
}Response:
{
"total_accumulated": "1505154.14",
"sustainability_age": 89,
"years_of_retirement": 24,
"monthly_data": [...],
"summary": {...}
}Health check endpoint.
- Django 5.0: Web framework
- Django REST Framework: API development
- django-cors-headers: CORS support
- Python Decimal: Precise financial calculations
- Next.js 14: React framework with App Router
- TypeScript: Type safety
- Tailwind CSS: Styling
- shadcn/ui: UI components (Radix UI)
- Recharts: Data visualization
- Axios: HTTP client
- Zustand: State management
Edit backend/financex/settings.py:
ALLOWED_HOSTS: Add production domainsCORS_ALLOWED_ORIGINS: Update for production frontend URLDEBUG: Set toFalsein production
Environment variables in .env.local:
NEXT_PUBLIC_API_URL: Backend API URL
Input:
- Current age: 32
- Initial investment: R$ 200,000
- Monthly contribution: R$ 1,200
- Retirement age: 65
- Monthly expenses: R$ 5,000
- Annual return: 10%
- Annual inflation: 5%
Output:
- Total accumulated: R$ 1,505,154.14
- Sustainability age: 89 years
- Years in retirement: 24 years
- Set
DEBUG=Falsein settings - Configure database (PostgreSQL recommended)
- Collect static files:
python manage.py collectstatic - Use gunicorn or similar WSGI server
- Set up reverse proxy (nginx)
- Build the application:
npm run build - Start production server:
npm start - Or deploy to Vercel/Netlify for automatic deployment
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Built with โค๏ธ for better financial planning in Brazil.
- Inspired by InvestNews Retirement Simulator
- UI components from shadcn/ui
- Charts powered by Recharts
Note: This calculator provides estimates based on the parameters you input. Actual investment returns may vary. Always consult with a financial advisor for personalized advice.