Project Structure
Key Design Points
main.go wires together the HTTP mux and the shell loop. Both run concurrently — the HTTP server is started in a goroutine and the shell blocks on stdin.
internal/database owns all SQL. Handlers and services call functions here rather than writing raw queries themselves.
internal/model contains only structs, enums, and validation. No SQL lives here.
internal/service contains business logic that spans multiple database calls. UpdatePositionByTradeList replays the full trade history to compute current positions, then writes them back to the database.
internal/handlers are thin — they decode the request, call a service or database function, and encode the response.