A full-stack application for managing and analyzing financial advisor data. Built with Next.js, Drizzle ORM, and PostgreSQL.
- Frontend: Next.js 14, React, TypeScript, Tailwind CSS
- Backend: Next.js API Routes
- Database: PostgreSQL, Drizzle ORM
- Dev Tools: Docker
# 1. Install dependencies
npm i
# 2. Start database
docker compose up -d
# 3. Push schema to database
npm run db:push
# 4. Start development server
npm run dev
# 5. Seed database with sample data (in another terminal)
curl -X POST http://localhost:3000/api/seedApp will be running at http://localhost:3000
Place data files in the /data directory:
| File | Description |
|---|---|
advisors.json |
Advisor records with custodian relationships |
accounts.json |
Account records with holdings |
securities.json |
Security reference data |
curl -X POST http://localhost:3000/api/seedThe script will:
- Parse and validate input files
- Populate database tables
- Calculate and output statistics:
- Total value across all accounts
- Top securities by value (risk exposure)
- Assets by custodian with advisors ranked
To test with your own data files:
# Replace sample files
cp your-advisors.json data/advisors.json
cp your-accounts.json data/accounts.json
cp your-securities.json data/securities.json
# Re-run seed
curl -X POST http://localhost:3000/api/seed| Method | Endpoint | Description |
|---|---|---|
| GET | /api/stats |
Aggregated statistics |
| GET | /api/advisors |
List all advisors |
| GET | /api/advisors/:id |
Advisor detail with accounts |
| GET | /api/accounts/:id |
Account detail with holdings |
# Get dashboard stats
curl http://localhost:3000/api/stats | jq
# Response:
# {
# "data": {
# "totalValue": 39469.51,
# "advisorCount": 1,
# "accountCount": 2
# }
# }
# Sorting
curl "http://localhost:3000/api/advisors?sortBy=name&order=desc" | jq| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run db:push |
Push schema to database |
npm run generate |
Generate migrations |
npm run lint |
Run ESLint |
npm run format |
Run Prettier |
├── data/ # Input JSON files
│ ├── advisors.json
│ ├── accounts.json
│ └── securities.json
├── src/
│ ├── app/
│ │ ├── api/ # API routes
│ │ ├── libs/ # Shared utilities (API, data, stats)
│ │ ├── components/ # Reusable building blocks
│ │ ├── shared/ # Common constants/hooks
│ │ └── page.tsx # Page UI
│ ├── components/ # React components
│ ├── db/
│ │ ├── schema.ts # Drizzle schema
│ │ ├── schema.types.ts # Schema types
│ │ └── index.ts # DB connection
│ ├── lib/ # Utilities
├── docs/
│ └── PRODUCTION_TODOS.md
Copy .env.example to .env:
cp .env.example .env| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |