Liquidity/
β
βββ π¨ frontend/ # Next.js Frontend Application
β βββ app/ # Next.js App Router
β β βββ page.tsx # Main landing page
β β βββ layout.tsx # Root layout
β β βββ globals.css # Global styles
β βββ lib/ # Utilities & API Client
β β βββ api.ts # TypeScript API client
β βββ public/ # Static assets
β βββ .env.local # Environment variables
β βββ package.json # Node.js dependencies
β βββ tsconfig.json # TypeScript config
β
βββ π§ backend/ # FastAPI Backend Application
β βββ app/ # Application code
β β βββ main.py # FastAPI app & routes
β β βββ __init__.py # Package initialization
β βββ venv/ # Python virtual environment (created by setup)
β βββ requirements.txt # Python dependencies
β βββ .env.example # Environment template
β βββ setup.sh # Backend setup script
β βββ start-backend.sh # Backend start script
β
βββ π src/ # Your existing code
β βββ solver/ # Solver module
β βββ solver.py # Liquidity solver logic
β
βββ π Documentation
β βββ README.md # Comprehensive documentation
β βββ QUICKSTART.md # Quick start guide
β βββ ARCHITECTURE.md # This file
β
βββ π Utility Scripts
β βββ start-all.sh # Start both servers
β βββ check-system.sh # System prerequisites check
β
βββ βοΈ Configuration
βββ .gitignore # Git ignore rules
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Browser β
β http://localhost:3000 β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
β HTTP Requests
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Next.js Frontend β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β React Components (page.tsx) β β
β β - UI rendering β β
β β - User interactions β β
β β - State management β β
β ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ β
β β β
β β Uses β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β API Client (lib/api.ts) β β
β β - Type-safe API calls β β
β β - Error handling β β
β β - Request/Response formatting β β
β ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ
β
β fetch() / HTTP
β http://localhost:8000/api/*
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β CORS Middleware β β
β β - Allow Next.js origin β β
β ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β API Routes (main.py) β β
β β - /health Health check β β
β β - /api/hello Sample endpoint β β
β β - /api/items Get items list β β
β β - /api/process Process item β β
β ββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ β
β β β
β β Can use β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Your Business Logic β β
β β - src/solver modules β β
β β - Database operations β β
β β - External services β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Service | URL | Purpose |
|---|---|---|
| Frontend | http://localhost:3000 |
User-facing web interface |
| Backend API | http://localhost:8000 |
REST API endpoints |
| API Docs (Swagger) | http://localhost:8000/docs |
Interactive API documentation |
| API Docs (ReDoc) | http://localhost:8000/redoc |
Alternative API documentation |
The backend is configured to accept requests from the frontend:
- Allowed Origins:
http://localhost:3000 - Allowed Methods: All (
GET,POST,PUT,DELETE, etc.) - Allowed Headers: All
- Credentials: Enabled
NEXT_PUBLIC_API_URL=http://localhost:8000API_HOST=0.0.0.0
API_PORT=8000
DEBUG=True
CORS_ORIGINS=http://localhost:3000Next.js 15 (React 19)
βββ TypeScript # Type safety
βββ Tailwind CSS # Utility-first styling
βββ App Router # File-based routing
βββ Server Components # Performance optimization
FastAPI
βββ Uvicorn # ASGI server
βββ Pydantic # Data validation
βββ Python 3.8+ # Runtime
βββ Automatic OpenAPI # API documentation
- next: React framework with SSR/SSG
- react & react-dom: UI library
- typescript: Type checking
- tailwindcss: CSS framework
- eslint: Code linting
- fastapi: Web framework
- uvicorn: ASGI server
- pydantic: Data validation
- python-dotenv: Environment variables
# Check prerequisites
./check-system.sh
# Setup backend
cd backend && ./setup.sh && cd ..
# Setup frontend (if needed)
cd frontend && npm install && cd ..# Option 1: Start both together
./start-all.sh
# Option 2: Start separately
# Terminal 1
cd backend && ./start-backend.sh
# Terminal 2
cd frontend && npm run devAdding a new API endpoint:
- Define route in
backend/app/main.py - Add method to
frontend/lib/api.ts - Use in React components
Adding a new page:
- Create
frontend/app/your-page/page.tsx - Access at
http://localhost:3000/your-page
To integrate your existing src/solver code:
# backend/app/main.py
import sys
sys.path.append('../src')
from solver.solver import YourSolverClass
@app.post("/api/solve")
async def solve_problem(data: ProblemData):
solver = YourSolverClass()
result = solver.solve(data)
return {"solution": result}- Configure production environment variables
- Set up database (PostgreSQL, MongoDB, etc.)
- Add authentication/authorization
- Implement rate limiting
- Add logging and monitoring
- Configure HTTPS/SSL
- Set up CI/CD pipeline
- Configure CORS for production domains
- Optimize build for production
- Set up error tracking (Sentry, etc.)
Frontend (Next.js)
- Vercel (recommended)
- Netlify
- AWS Amplify
- Self-hosted with PM2
Backend (FastAPI)
- Railway
- Render
- Heroku
- AWS EC2/ECS
- DigitalOcean
- Self-hosted with Nginx + Gunicorn
When adding features:
- Follow the existing code structure
- Add types to TypeScript code
- Use Pydantic models for API schemas
- Update documentation
- Test both frontend and backend